public new async Task <User> Create(UserViewModel user) { var userToCreate = new User { Lastname = user.Lastname, Firstname = user.Firstname, Gender = user.Gender, Birthdate = user.Birthdate, Email = user.Email, Date_Joined = user.Date_Joined }; await _repositoryContext.User.AddAsync(userToCreate); await _repositoryContext.SaveChangesAsync(); return(userToCreate); }
public async Task <Customer> Create(CustomerViewModel customer, int BusinessID) { if (_repositoryContext.Customer.Any(x => x.Phone == customer.Phone && x.Business.ID == BusinessID)) { throw new AppException("Customer With \"" + customer.Phone + "\" Found in Database"); } var customerToCreate = new Customer { Title = customer.Title, Name = customer.Name, Platform = customer.Platform, Email = customer.Email, Phone = customer.Phone, Address = customer.Address }; await _repositoryContext.Customer.AddAsync(customerToCreate); await _repositoryContext.SaveChangesAsync(); return(customerToCreate); }