public void Add(PartInvoice invoice) { if (invoice == null) { throw new ArgumentException(); } }
public void Add(PartInvoice invoice) { string _ConnectionString = ConfigurationManager.ConnectionStrings["appDatabase"].ConnectionString; using (SqlConnection _Connection = new SqlConnection(_ConnectionString)) { SqlCommand _Command = new SqlCommand { Connection = _Connection, CommandType = CommandType.StoredProcedure, CommandText = "PMS_AddPartInvoice" }; SqlParameter _StockCodeParameter = new SqlParameter("@StockCode", SqlDbType.VarChar, 50) { Value = invoice.StockCode }; _Command.Parameters.Add(_StockCodeParameter); SqlParameter QuantityParameter = new SqlParameter("@Quantity", SqlDbType.Int) { Value = invoice.Quantity }; _Command.Parameters.Add(QuantityParameter); SqlParameter CustomerIDParameter = new SqlParameter("@CustomerID", SqlDbType.Int) { Value = invoice.CustomerID }; _Command.Parameters.Add(CustomerIDParameter); _Connection.Open(); _Command.ExecuteNonQuery(); } }
public void Add(PartInvoice invoice) { if (PartInvoiceDataStore.partInvoices is null) { PartInvoiceDataStore.partInvoices = new List <PartInvoice>(); } PartInvoiceDataStore.partInvoices.Add(invoice); }
private void AddPartInvoiceToRepository(string stockCode, int quantity, int customerId) { PartInvoice _PartInvoice = new PartInvoice { StockCode = stockCode, Quantity = quantity, CustomerID = customerId }; PartInvoiceRepository.Add(_PartInvoice); }
public CreatePartInvoiceResult CreatePartInvoice(string stockCode, int quantity, string customerName) { // This method calls to external services (Database, Webservice). It is better to have try catch to handle exceptions. try { // Changed: Add validation for customerName. if (string.IsNullOrEmpty(stockCode) || string.IsNullOrEmpty(customerName)) { return(new CreatePartInvoiceResult(false)); } if (quantity <= 0) { return(new CreatePartInvoiceResult(false)); } Customer _Customer = __CustomerRepositoryDB.GetByName(customerName); // Changed: Validate Customer in case of customer not found. if (_Customer == null || _Customer.ID <= 0) { return(new CreatePartInvoiceResult(false)); } int _Availability = __IPartAvailabilityService.GetAvailability(stockCode); if (_Availability <= 0) { return(new CreatePartInvoiceResult(false)); } PartInvoice _PartInvoice = new PartInvoice { StockCode = stockCode, Quantity = quantity, CustomerID = _Customer.ID }; __PartInvoiceRepositoryDB.Add(_PartInvoice); return(new CreatePartInvoiceResult(true)); } catch (Exception) { // Logging return(new CreatePartInvoiceResult(false)); } }
public CreatePartInvoiceResult CreatePartInvoice(string stockCode, int quantity, string customerName) { if (string.IsNullOrEmpty(stockCode)) { return(new CreatePartInvoiceResult(false)); } if (quantity <= 0) { return(new CreatePartInvoiceResult(false)); } Customer _Customer = Connection.GetCustomer(customerName); if (_Customer.ID <= 0) { return(new CreatePartInvoiceResult(false)); } int _Availability = ServiceClient.GetAvailability(stockCode); if (_Availability <= 0) { return(new CreatePartInvoiceResult(false)); } PartInvoice _PartInvoice = new PartInvoice { StockCode = stockCode, Quantity = quantity, CustomerID = _Customer.ID }; Connection.AddPartInvoice(_PartInvoice); return(new CreatePartInvoiceResult(true)); }
public void AddPartInvoice(PartInvoice partInvoice) { }
public AddPartInvoiceQuery(PartInvoice invoice) : this(invoice.StockCode, invoice.Quantity, invoice.CustomerID) { }
public void AddPartInvoice(PartInvoice partInvoice) { PartInvoiceRepositoryDB _PartInvoiceRepository = new PartInvoiceRepositoryDB(); _PartInvoiceRepository.Add(partInvoice); }