public async Task <Customer> updateCustomer(CustomerProfile request) { var customer = await _context.Customers.SingleOrDefaultAsync(c => c.Id == request.CustomerId); if (customer == null) { throw new NotFoundException(nameof(Customer), request.CustomerId); } customer.City = request.Address.City.ToUpperInvariant(); customer.Country = request.Address.Country.ToFirstLetterUpper(); customer.Streetaddress = request.Address.StreetAdress.ToFirstLetterUpper(); // customer.Zipcode = request.Address.ZipCode; // customer.CountryCode = request.Address.CountryCode.ToUpperInvariant(); customer.Gender = request.Gender; customer.Birthday = request.Birthday; customer.Surname = request.Surname.ToFirstLetterUpper(); customer.Givenname = request.GivenName.ToFirstLetterUpper(); customer.Emailaddress = request.EmailAdress.ToFirstLetterUpper(); customer.Telephonenumber = request.TelephoneNumber; //customer.Telephonecountrycode = request.TelephoneCountryCode; //customer.NationalId = request.NationalId; _context.Customers.Update(customer); await _context.SaveChangesAsync(); // throw new Exception("Successfully updated the customers profile."); // return new BaseResult { IsSuccess = true, Success = "Successfully updated the customers profile." }; return(customer); }
public async Task <CustomerProfile> GetCustomIDandEmail(GetCustomerQuery request) { Customer customer; if (!string.IsNullOrEmpty(request.CustomerEmail)) { customer = await _context.Customers.SingleOrDefaultAsync(c => c.Emailaddress == request.CustomerEmail); } else { customer = await _context.Customers.SingleOrDefaultAsync(c => c.Id == request.CustomerId); } if (customer == null) { throw new NotFoundException(nameof(Customer), request.CustomerId); } var model = new CustomerProfile { CustomerId = customer.Id, TelephoneNumber = customer.Telephonenumber, //TelephoneCountryCode = customer.Telephonecountrycode, //NationalId = customer.NationalId, Surname = customer.Surname, EmailAdress = customer.Emailaddress, GivenName = customer.Givenname, Birthday = customer.Birthday, Gender = customer.Gender, Address = new CustomerAddress { //CountryCode = customer.CountryCode, Country = customer.Country, City = customer.City, StreetAdress = customer.Streetaddress, // ZipCode = customer.Zipcode } }; return(model); }
public async Task <bool> CreateUser(CustomerProfile request, string accountNumber, string userEmail) { Customer customer = new Customer { CustAccNumber = accountNumber, Cust_acc_type = request.AccountType, BVNNumber = request.BVNNumber, Givenname = request.GivenName.ToFirstLetterUpper(), Surname = request.Surname.ToFirstLetterUpper(), Gender = request.Gender, CreatedBy = userEmail, OtherNames = request.OtherNames, City = request.Address.City.ToUpperInvariant(), Country = request.Address.Country.ToFirstLetterUpper(), Streetaddress = request.Address.StreetAdress.ToFirstLetterUpper(), Emailaddress = request.EmailAdress.ToFirstLetterUpper(), Birthday = request.Birthday, Telephonenumber = request.TelephoneNumber, }; var account = new Account { Balance = 0m, Created = DateTime.Now, AccountNumber = accountNumber, CustId = customer.Id }; _context.Customers.Add(customer); _context.Accounts.Add(account); //_context.SaveChanges(); var result = await _context.SaveChangesAsync(); //var disposition = new Disposition //{ // CustomerId = customer.Id, // AccountId = account.Id, // Type = DispositionType.Owner //}; //_context.Dispositions.Add(disposition); // var result = await _context.SaveChangesAsync(); //if (result == 1) //{ // // throw new Exception("Successfully registred customer"); // //return new BaseResult { IsSuccess = true, Success = "Successfully registred customer" }; //} //else //{ // // throw new Exception("Successfully registred customer"); // // throw new Exception("An error occured while registrering the customer, try again shortly."); //} // throw new Exception("An error occured while registrering the customer, try again shortly."); // return new BaseResult { IsSuccess = false, Success = "An error occured while registrering the customer, try again shortly." }; return(true); }
public async Task <bool> CreateCustomer(CustomerProfile request, string accountNumber, string loginAdmin) { var customer = new Customer { CustAccNumber = accountNumber, Cust_acc_type = request.AccountType, BVNNumber = request.BVNNumber, ImageThumbnailUrl = request.CustImageThumbnailUrl, UploadDocument = request.ScannThumbnailUrl, ImageUrl = request.ImageUrl, Givenname = request.GivenName.ToFirstLetterUpper(), Surname = request.Surname.ToFirstLetterUpper(), Gender = request.Gender, CreatedBy = loginAdmin, OtherNames = request.OtherNames, City = request.Address.City.ToUpperInvariant(), Country = request.Address.Country.ToFirstLetterUpper(), Streetaddress = request.Address.StreetAdress.ToFirstLetterUpper(), Emailaddress = request.EmailAdress.ToFirstLetterUpper(), // CountryCode = request.Address.CountryCode.ToUpperInvariant(), //Zipcode = request.Address.ZipCode, Birthday = request.Birthday, //NationalId = request.NationalId, //Telephonecountrycode = request.TelephoneCountryCode, Telephonenumber = request.TelephoneNumber, }; var account = new Account { Balance = 0m, Created = DateTime.Now, Frequency = AccountFrequency.Monthly, AccountNumber = accountNumber, CustId = customer.Id }; _context.Customers.Add(customer); _context.Accounts.Add(account); //_context.SaveChanges(); var result = await _context.SaveChangesAsync(); //var disposition = new Disposition //{ // CustomerId = customer.Id, // AccountId = account.Id, // Type = DispositionType.Owner //}; //_context.Dispositions.Add(disposition); // var result = await _context.SaveChangesAsync(); //if (result == 1) //{ // // throw new Exception("Successfully registred customer"); // //return new BaseResult { IsSuccess = true, Success = "Successfully registred customer" }; //} //else //{ // // throw new Exception("Successfully registred customer"); // // throw new Exception("An error occured while registrering the customer, try again shortly."); //} // throw new Exception("An error occured while registrering the customer, try again shortly."); // return new BaseResult { IsSuccess = false, Success = "An error occured while registrering the customer, try again shortly." }; return(true); }