public async Task <IActionResult> Update(SupplierUpdateViewModel model) { try { if (ModelState.IsValid) { var supplier = new SupplierUpdateDTO() { Id = model.Id, Name = model.Name, Phone = model.Phone, Address = model.Address, Email = model.Email, }; await _supplierService.Update(supplier).ConfigureAwait(true); _toastNotification.AddInfoToastMessage("Updated to:- " + model.Name); return(RedirectToAction("Index")); } } catch (Exception ex) { _toastNotification.AddErrorToastMessage(ex.Message); } return(View()); }
public async Task <ActionResult> Update(SupplierUpdateViewModel model) { try { var supplier = new SupplierUpdateDTO() { Id = model.Id, Name = model.Name, Phone = model.Phone, Address = model.Address, Email = model.Email, }; await _supplierService.Update(supplier).ConfigureAwait(true); var Supplier = await _supplierRepo.GetByNumber(supplier.Phone) ?? throw new System.Exception("Supplier Not Found."); return(Ok(CreateReponseDto(Supplier))); } catch (Exception ex) { return(BadRequest(ex.Message)); } }