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; }); } }
public static async Task <CustomerCreditAccount> updateCustomerCreditAccountAsync(IRestDataMapper mapper, CustomerCreditAccount data) { CustomerCreditAccount reds = new CustomerCreditAccount(); if (mapper == null) { return(reds); } string url = $"customercreditac/api/v1/customercac/{data.id}"; reds = await mapper.PostDataAsync(url, data); return(reds); }