public async Task <IActionResult> Create(SupplierCreateViewModel model) { try { if (ModelState.IsValid) { var supplier = new SupplierCreateDTO() { Name = model.Name, Email = model.Email, Phone = model.Phone, Address = model.Address, }; await _supplierService.Create(supplier).ConfigureAwait(true); _toastNotification.AddSuccessToastMessage("Supplier Name: - " + model.Name); return(RedirectToAction("Index")); } } catch (Exception ex) { _toastNotification.AddErrorToastMessage(ex.Message); } return(View(model)); }
public async Task <ActionResult> Create(SupplierCreateViewModel model) { try { var supplier = new SupplierCreateDTO() { Name = model.Name, Email = model.Email, Phone = model.Phone, Address = model.Address, }; await _supplierService.Create(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)); } }