public RegisterUserResponse RegisterUser(RegisterCustomerRequest request) { var ct = request.NewCustomer; //convert Customer to DLCustomer ADL_Customer CustomerToSave; if (MockCustomer == null) { CustomerToSave = GetMappingObject().MapCustomertoDLCustomer(ct); } else { CustomerToSave = MockCustomer; } ISecurityMethods security; if (MockSecurity == null) { security = new SecurityMethods(); } else { security = MockSecurity; } //Add additional fields byte[] Salt = security.GenerateNewSalt(); CustomerToSave.Salt = Salt; CustomerToSave.PasswordNeedsChanging = false; CustomerToSave.UserName = request.UserName; CustomerToSave.PasswordHash = security.GetPasswordHash(Salt, request.Password); try { CustomerToSave.Save(); } catch (Exception e) { return(new RegisterUserResponse { CallResult = 1, Message = REGISTER_CUSTOMER_SAVE_FAILED + "\n" + e.Message, MessageType = MessageType.Error }); } return(new RegisterUserResponse { CallResult = 0 }); }
public static void UpdateSavedProductsWhenClosingApp() { try { var sortedProducts = new Dictionary <string, ProductionDetailsToSave>(); foreach (string ID in businesses.Keys) { if (!sortedProducts.ContainsKey(ID)) { var productionToSave = new ProductionDetailsToSave() { productSource = new Dictionary <string, ProductToSave>() }; foreach (ProductItem product in businesses[ID].productSource) { var productDetailsToSave = new ProductToSave(); if (product.isEnable == true) { productDetailsToSave.isEnable = "TRUE"; productDetailsToSave.icon = product.sortedStatusIcon; } else if (product.isEnable == false) { productDetailsToSave.isEnable = "FALSE"; productDetailsToSave.icon = ""; } var customerList = new List <CustomerToSave>(); foreach (Customer customer in product.customers) { var customerToSave = new CustomerToSave(); customerToSave.customer_first_name = customer.customer_first_name; customerToSave.customer_last_name = customer.customer_last_name; customerToSave.customer_uid = customer.customer_uid; customerToSave.qty = customer.qty; if (customer.borderColor == Color.Red) { customerList.Add(customerToSave); } } productDetailsToSave.customersSource = customerList; productionToSave.productSource.Add(product.item_uid, productDetailsToSave); } sortedProducts.Add(ID, productionToSave); } } SaveChanges(sortedProducts); }catch (Exception issueOnUpdateSavedProductsWhenClosingApp) { Application.Current.MainPage.DisplayAlert("Oops", issueOnUpdateSavedProductsWhenClosingApp.Message, "OK"); } }
void NavigateToSummaryPage(System.Object sender, System.EventArgs e) { try { var sortedProducts = new Dictionary <string, ProductionDetailsToSave>(); foreach (string ID in businesses.Keys) { if (!sortedProducts.ContainsKey(ID)) { var productionToSave = new ProductionDetailsToSave() { productSource = new Dictionary <string, ProductToSave>() }; foreach (ProductItem product in businesses[ID].productSource) { var productDetailsToSave = new ProductToSave(); if (product.isEnable == true) { productDetailsToSave.isEnable = "TRUE"; } else if (product.isEnable == false) { productDetailsToSave.isEnable = "FALSE"; } productDetailsToSave.icon = product.sortedStatusIcon; var customerList = new List <CustomerToSave>(); foreach (Customer customer in product.customers) { var customerToSave = new CustomerToSave(); customerToSave.customer_first_name = customer.customer_first_name; customerToSave.customer_last_name = customer.customer_last_name; customerToSave.customer_uid = customer.customer_uid; customerToSave.qty = customer.qty; if (customer.borderColor == Color.Red) { customerList.Add(customerToSave); } } productDetailsToSave.customersSource = customerList; productionToSave.productSource.Add(product.item_uid, productDetailsToSave); } sortedProducts.Add(ID, productionToSave); } } SaveChanges(sortedProducts); isProductionSave = "TRUE"; Navigation.PushModalAsync(new SummaryPage()); } catch (Exception issueOnNavigateToSummaryPage) { Application.Current.MainPage.DisplayAlert("Oops", issueOnNavigateToSummaryPage.Message, "OK"); } }