private async Task ValidateSupplierNumber(string phoneNumber, Supplier?supplier = null) { var CustomerByNumber = await _supplierRepo.GetByNumber(phoneNumber).ConfigureAwait(false); if (CustomerByNumber != null && CustomerByNumber != supplier) { throw new Exception("Supplier Number already registered."); } return; }
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)); } }