public void UpdateCustomer(BookRepair_CustomerModel model) { // method for customer update var user = new UserService(_dataContext); var store = new StoreService(_dataContext); var cust = new CustomerService(_dataContext); var func = new FunctionsController(); model.Forename = func.UppercaseFirst(model.Forename); model.Surname = func.UppercaseFirst(model.Surname); // Save in database var customerId = _reporsitory.UpdateCustomer(model, cust.GetCustomerIdFromSession(), store.GetStoreId(), user.GetUserId()); // Fill class by info cust.SetGeneralCustomerInfoIntoSession(new Customer_InfoModel { Address1 = model.HouseNumber + " " + model.Addr1 + "," + model.Organization, Address2 = model.Addr2, Address3 = model.Addr3, CustomerName = model.Forename + " " + model.Surname, PostCode = model.Postcode, CustomerId = customerId, ContactMethod = model.ContactMethod }); // Update session holder //_bookStateHolder.UpdateFrom(_bookState); }
/// <summary> /// Check validation of contact methods /// </summary> /// <param name="model">Model of data</param> /// <returns>Dictionary (ElementId, Error message)</returns> public Dictionary <string, string> CheckContactMethods(BookRepair_CustomerModel model) { // Contact methods check if (string.IsNullOrEmpty(model.MobileTel) && model.ContactMethod == ContactMethod.ContactMethod.SMS) { return new Dictionary <string, string>() { { "MobileTel", "Input telephone" } } } ; if (string.IsNullOrEmpty(model.LandlineTel) && model.ContactMethod == ContactMethod.ContactMethod.Telephone) { return new Dictionary <string, string>() { { "LandlineTel", "Input telephone" } } } ; if (string.IsNullOrEmpty(model.Email) && model.ContactMethod == ContactMethod.ContactMethod.Email) { return new Dictionary <string, string>() { { "Email", "Input email" } } } ; return(null); }
public BookRepair_CustomerModel GetCustomerInfo() { var result = new BookRepair_CustomerModel(); var cust = new CustomerService(_dataContext); var model = cust.GetCustomerInfo(); // Get contact method result.ContactMethod = cust.GetContactMethod(); result.TitleName = model.TitleName; result.Forename = model.Forename; result.Surname = model.Surname; result.County = model.County; result.Town = model.Town; result.Addr1 = model.Addr1; result.Addr2 = model.Addr2; result.Addr3 = model.Addr3; result.ContactMethod = model.ContactMethod; result.MobileTel = model.MobileTel; result.LandlineTel = model.LandlineTel; result.Email = model.Email; result.Postcode = model.Postcode; if (!string.IsNullOrEmpty(model.MobileTel)) { result.ContactMethod = ContactMethod.ContactMethod.SMS; } else if (!string.IsNullOrEmpty(model.LandlineTel)) { result.ContactMethod = ContactMethod.ContactMethod.Telephone; } else if (!string.IsNullOrEmpty(model.Email)) { result.ContactMethod = ContactMethod.ContactMethod.Email; } return(result); }