public void Delete(lib.Customer customer) { var entity = _dbContext.Customer.First(c => c.FirstName.Equals(customer.FirstName) && c.LastName.Equals(customer.LastName)); _dbContext.Customer.Remove(entity); _dbContext.SaveChanges(); }
public void Add(lib.Customer customer) { _logger.Info("Adding Customer"); var entity = Mapper.MapLibCustomer(customer); _dbContext.Customer.Add(entity); }
public void Update(lib.Customer customer) { var entity = _dbContext.Customer.First(c => c.CustomerId == customer.customerID); entity.FirstName = customer.FirstName; entity.LastName = customer.LastName; _dbContext.Customer.Update(entity); _dbContext.SaveChanges(); }
/// <summary> /// Takes in customer name and returns first instance of that customer /// </summary> /// public lib.Customer SearchCustomerByName(string search) { string x = search.ToLower(); //lower cases the query and matches the query to lowercase first names if (_dbContext.Customer.Any(cust => cust.FirstName.ToLower().Equals(x))) { lib.Customer customer = Mapper.CustomerMapper(_dbContext.Customer.First(cust => cust.FirstName.ToLower().Equals(x))); return(customer); } //if cant find a customer, than display error message...need to implement try catches; else { Console.WriteLine($"\nNo customers exist with this name.\n"); return(null); } }