P1_TrevorGraham/MvcStoreApplication/Repository/Repository.cs
/// <summary>
/// Attempts to add customer to db and returns whether or not it was successful
/// </summary>
/// <param name="customer"></param>
/// <returns></returns>
Attempts to add customer to db and returns whether or not it was successful
Attempts to add customer to db and returns whether or not it was successful
public bool AttemptAddCustomerToDb(Customer customer)
        {
            if (!CustomerIsInDb(customer)&&!UsernameAlreadyExists(customer.Username))
            {
                _dbContext.Customers.Add(customer);
                _dbContext.SaveChanges();
                return CustomerIsInDb(customer);
            }
            else
            {
            }
            return false;
        }
public bool AttemptAddCustomerToDb ( Customer customer ) { if ( ! CustomerIsInDb ( customer ) && ! UsernameAlreadyExists ( customer . Username ) ) { _dbContext . Customers . Add ( customer ) ; _dbContext . SaveChanges ( ) ; return CustomerIsInDb ( customer ) ; } else { } return false ; }
Attempts to add customer to db and returns whether or not it was successful
Attempts to add customer to db and returns whether or not it was successful
//if there is not a product in the db with the same id or name //add it //TODO:check if customer was already in db and give some sort of warning
None
customer
Customer
None