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 <IActionResult> Update(long id) { try { var supplier = await _supplierRepo.GetById(id).ConfigureAwait(true); var model = new SupplierUpdateViewModel() { Id = supplier.Id, Name = supplier.Name, Phone = supplier.Phone, Address = supplier.Address, Email = supplier.Email }; return(View(model)); } 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)); } }
public async Task <IActionResult> Update([FromBody] SupplierUpdateViewModel supplier) { await _supplierCommandFunctionality.UpdateAsync(Mapper.Map <SupplierUpdateCommand>(supplier)); return(StatusCode(StatusCodes.Status200OK)); }