private async void SaveSupplier() { IRestDataMapper mapper = containerExtension.Resolve <IRestDataMapper>(); if (!string.IsNullOrEmpty(SelectedSupplier.name) && SelectedSupplier.id == 0) { SelectedSupplier.branch = loggedUser.LoggedUser.branch; SupplierCreditAccount ac = await SupplierCreditRestService .CreateSupplierCreditAccountAsync(mapper, new SupplierCreditAccount() { id = 0, totalCredit = 0.00m }); if (ac.id <= 0) { dialogService.ShowMsgDialog("New Supplier Creation", "Can't Save Supplier", MsgDialogType.error, (r) => { return; }); } SelectedSupplier.supplierCreditAccount = ac; Supplier c = await SupplierRestService.CreateSupplierAsync(mapper, SelectedSupplier); if (c.id > 0) { c.code = $"S{c.id}"; c = await SupplierRestService.UpdateSupplierAsync(mapper, c); if (c.id > 0 && !string.IsNullOrEmpty(c.code)) { dialogService.ShowMsgDialog("New Supplier Creation", "Supplier Created Successfully", MsgDialogType.infor, (r) => { LoadSuppliersAsync(); NewSupplier(); }); } else { dialogService.ShowMsgDialog("New Supplier Creation", "Can't Update Supplier", MsgDialogType.error, (r) => { return; }); } } else { dialogService.ShowMsgDialog("New Supplier Creation", "Can't Save Supplier", MsgDialogType.error, (r) => { return; }); } } else { dialogService.ShowMsgDialog("New Supplier Creation", "Invalid Supplier Details or Already Exist Supplier", MsgDialogType.warrning, (r) => { return; }); } }
public static async Task <SupplierCreditAccount> updateSupplierCreditAccountAsync(IRestDataMapper mapper, SupplierCreditAccount data) { SupplierCreditAccount reds = new SupplierCreditAccount(); if (mapper == null) { return(reds); } string url = $"suppliercreditac/api/v1/suppliercac/{data.id}"; reds = await mapper.PostDataAsync(url, data); return(reds); }