Ejemplo n.º 1
0
        public InvoiceModel CreateInvoice(NewInvoiceModel invoice, int locationId)
        {
            Data.Graph.Invoice inv = new Data.Graph.Invoice();

            var account = AccountRepository.GetAccount(invoice.AccountId);

            if (account == null)
            {
                account             = new Data.Graph.Account();
                account.Name        = invoice.AccountName;
                account.AccountType = AccountTypeRepository.GetAccountType(invoice.AccountTypeId);
                AccountRepository.SaveAccount(account);
            }

            inv.Account     = account;
            inv.Color       = invoice.Color;
            inv.Location    = new Data.Graph.Location(locationId);
            inv.Make        = invoice.Make;
            inv.Model       = invoice.Model;
            inv.ReceiveDate = DateTime.Now;
            inv.StockNumber = invoice.StockNumber;
            inv.Year        = invoice.Year;
            inv.TaxRate     = (decimal)account.AccountType.TaxRate;

            InvoiceRepository.SaveInvoice(inv);
            Logger.InfoFormat("Created new invoice {0} for {1} at location id {2}", inv.Id, inv.Account.Name, locationId);

            return(Mapper.Map <Data.Graph.Invoice, InvoiceModel>(inv));
        }
Ejemplo n.º 2
0
        public AccountModel CreateAccount(AccountModel account)
        {
            var graph = new Data.Graph.Account();
            graph.AccountType = AccountTypeRepository.GetAccountType(account.AccountTypeId);
            graph.AddressLine1 = account.AddressLine1;
            graph.AddressLine2 = account.AddressLine2;
            graph.City = account.City;
            graph.Name = account.Name;
            graph.Notes = account.Notes;
            graph.PostalCode = account.PostalCode;
            graph.StateCode = account.StateCode;

            AccountRepository.SaveAccount(graph);

            return Mapper.Map<Data.Graph.Account, AccountModel>(graph);
        }
Ejemplo n.º 3
0
        public AccountModel CreateAccount(AccountModel account)
        {
            var graph = new Data.Graph.Account();

            graph.AccountType  = AccountTypeRepository.GetAccountType(account.AccountTypeId);
            graph.AddressLine1 = account.AddressLine1;
            graph.AddressLine2 = account.AddressLine2;
            graph.City         = account.City;
            graph.Name         = account.Name;
            graph.Notes        = account.Notes;
            graph.PostalCode   = account.PostalCode;
            graph.StateCode    = account.StateCode;

            AccountRepository.SaveAccount(graph);

            return(Mapper.Map <Data.Graph.Account, AccountModel>(graph));
        }
Ejemplo n.º 4
0
        public InvoiceModel CreateInvoice(NewInvoiceModel invoice, int locationId)
        {
            Data.Graph.Invoice inv = new Data.Graph.Invoice();

            var account = AccountRepository.GetAccount(invoice.AccountId);
            if (account == null)
            {
                account = new Data.Graph.Account();
                account.Name = invoice.AccountName;
                account.AccountType = AccountTypeRepository.GetAccountType(invoice.AccountTypeId);
                AccountRepository.SaveAccount(account);
            }

            inv.Account = account;
            inv.Color = invoice.Color;
            inv.Location = new Data.Graph.Location(locationId);
            inv.Make = invoice.Make;
            inv.Model = invoice.Model;
            inv.ReceiveDate = DateTime.Now;
            inv.StockNumber = invoice.StockNumber;
            inv.Year = invoice.Year;
            inv.TaxRate = (decimal)account.AccountType.TaxRate;

            InvoiceRepository.SaveInvoice(inv);
            Logger.InfoFormat("Created new invoice {0} for {1} at location id {2}", inv.Id, inv.Account.Name, locationId);

            return Mapper.Map<Data.Graph.Invoice, InvoiceModel>(inv);
        }