private bool UpdateAccountBalance(Account account, decimal amount, AccountingTypes type) { try { switch (type) { case AccountingTypes.Debit: account.Balance += amount; break; case AccountingTypes.Credit: account.Balance -= amount; break; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } _accountService.UpdateAccount(account); _accountService.SaveAccount(); return(true); } catch (SqlException e) { Logger.Instance.Error(e); return(false); } catch (Exception ex) { Logger.Instance.Error(ex); return(false); } }
private bool UpdateAccountBalance(Account account, decimal amount, AccountingTypes type) { try { switch (type) { case AccountingTypes.Debit: account.Balance += amount; break; case AccountingTypes.Credit: account.Balance -= amount; break; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } _db.Entry(account).State = EntityState.Modified; _db.SaveChanges(); return(true); } catch (Exception e) { Logger.Instance.Error(e); return(false); } }
public InvoiceCommand(InvoiceTypes invoiceType, string invoiceNumber, Company owner, DateTime invoiceDate, DivisionMethods divisionMethod, AccountingTypes accountType, Invoice invoiceRefrence, List<long> orderRefrences, Currency currency, Company transporter, Company supplier, string description, List<InvoiceItemCommand> list) { // TODO: Complete member initialization InvoiceType = invoiceType; InvoiceNumber = invoiceNumber; Owner = owner; InvoiceDate = invoiceDate; DivisionMethod = divisionMethod; AccountingType = accountType; InvoiceRefrence = invoiceRefrence; OrdersRefrenceId = orderRefrences; Currency = currency; Transporter = transporter; Supplier = supplier; Description = description; InvoiceItems = list; }
public Invoice(InvoiceTypes invoiceType, string invoiceNumber, Company owner, DateTime invoiceDate, DivisionMethods divisionMethod, AccountingTypes accountType, Invoice invoiceRefrence, List<Order> orderRefrences, Currency currency, bool isCreditor, Company transporter, Company supplier, string description, List<InvoiceItem> list, List<InvoiceAdditionalPrice> invoiceAdditionalPriceList, IEntityConfigurator<Invoice> invoiceConfigurator, IInvoiceDomainService invoiceDomainService, IInvoiceItemDomainService invoiceItemDomainService, IGoodUnitConvertorDomainService goodUnitConvertorDomainService, IInvoiceAdditionalPriceDomainService invoiceAdditionalPriceDomainService, IBalanceDomainService balanceDomainService) : this() { // TODO: Complete member initialization InvoiceType = invoiceType; InvoiceNumber = invoiceNumber; Owner = owner; InvoiceDate = invoiceDate; DivisionMethod = divisionMethod; AccountingType = accountType; InvoiceRefrence = invoiceRefrence; OrderRefrences = orderRefrences; Currency = currency; IsCreditor = isCreditor; Transporter = transporter; Supplier = supplier; TransporterId = Transporter == null ? (long?)null : Transporter.Id; SupplierId = Supplier == null ? (long?)null : Supplier.Id; InvoiceRefrenceId = InvoiceRefrence == null ? (long?)null : InvoiceRefrence.Id; Description = description; UpdateInvoiceItems(list, null, balanceDomainService); UpdateInvoiceAdditionalPrice(invoiceAdditionalPriceList, null); this.invoiceConfigurator = invoiceConfigurator; this.invoiceAdditionalPriceDomainService = invoiceAdditionalPriceDomainService; invoiceConfigurator.Configure(this); invoiceBaseType.ValidateType(this); checkInvoiceNumberToBeUnique(invoiceDomainService); CheckInvoiceHaveInvoiceItem(); invoiceBaseType.CheckInvoiceItemValidateQuantityAndRefrence(this, invoiceItemDomainService, goodUnitConvertorDomainService); invoiceAdditionalPriceDomainService.CalculateAdditionalPrice(this); }