/// <summary> /// Adds a supplier to the database. This requires the Supplier's name or Country to be filled in. /// The method will invoke the SupplierAddedRequested event, which will return the user to the previous page. /// </summary> private void AddSupplier() { try { if (String.IsNullOrWhiteSpace(Supplier.Name)) { throw new ArgumentException(Properties.Resources.ErrorSupplierName); } else if (String.IsNullOrWhiteSpace(Supplier.Address.Country)) { throw new ArgumentException(Properties.Resources.ErrorSupplierCountry); } _supplierRepo.AddSupplier(Supplier); SupplierAddedRequested?.Invoke(); } catch (ArgumentException e) { ErrorHandler.ThrowError(1, $"{e.Message}"); } catch (Exception e) { Console.WriteLine(e); throw; } }
public async Task <bool> Add(SupplierVM supplierVM) { Supplier supplier = mapper.Map <Supplier>(supplierVM); return(await supplierRepo.AddSupplier(supplier)); }