private async void SaveCustomer() { IRestDataMapper mapper = containerExtension.Resolve <IRestDataMapper>(); if (!string.IsNullOrEmpty(SelectedCustomer.name) && SelectedCustomer.id == 0) { SelectedCustomer.branch = loggedUser.LoggedUser.branch; CustomerCreditAccount ac = await CustomerCreditRestService .CreateCustomerCreditAccountAsync(mapper, new CustomerCreditAccount() { id = 0, totalCredit = 0.00m }); if (ac.id <= 0) { dialogService.ShowMsgDialog("New Customer Creation", "Can't Save Customer", MsgDialogType.error, (r) => { return; }); } SelectedCustomer.customerCreditAccount = ac; Customer c = await CustomerRestService.CreateCustomerAsync(mapper, SelectedCustomer); if (c.id > 0) { c.code = $"C{c.id}"; c = await CustomerRestService.UpdateCustomerAsync(mapper, c); if (c.id > 0 && !string.IsNullOrEmpty(c.code)) { dialogService.ShowMsgDialog("New Customer Creation", "Customer Created Successfully", MsgDialogType.infor, (r) => { LoadCustomersAsync(); NewCustomer(); }); } else { dialogService.ShowMsgDialog("New Customer Creation", "Can't Update Customer", MsgDialogType.error, (r) => { return; }); } } else { dialogService.ShowMsgDialog("New Customer Creation", "Can't Save Customer", MsgDialogType.error, (r) => { return; }); } } else { dialogService.ShowMsgDialog("New Customer Creation", "Invalid Customer Details or Already Exist Customer", MsgDialogType.warrning, (r) => { return; }); } }
private async void UpdateCustomer() { IRestDataMapper mapper = containerExtension.Resolve <IRestDataMapper>(); if (SelectedCustomer != null) { if (SelectedCustomer.id > 0) { Customer c = await CustomerRestService.UpdateCustomerAsync(mapper, SelectedCustomer); if (c != null) { if (c.id > 0) { dialogService.ShowMsgDialog("Customer Details Update", "Customer Update Successfully", MsgDialogType.infor, (r) => { LoadCustomersAsync(); NewCustomer(); }); } else { dialogService.ShowMsgDialog("Customer Details Update", "Can't Update Customer", MsgDialogType.error, (r) => { return; }); } } else { dialogService.ShowMsgDialog("Customer Details Update", "Can't Update Customer", MsgDialogType.error, (r) => { return; }); } } else { dialogService.ShowMsgDialog("Customer Details Update", "Please Select Customer Before Update", MsgDialogType.warrning, (r) => { return; }); } } else { dialogService.ShowMsgDialog("Customer Details Update", "Please Select Customer Before Update", MsgDialogType.warrning, (r) => { return; }); } }