示例#1
0
        public async Task <Invoice> Add(Invoice entity)
        {
            if (entity.Id == Guid.Empty)
            {
                entity.Id = Guid.NewGuid();
            }

            entity.Company = _context.Companies.First(c => c.CompanyCode == entity.CompanyCode);

            //Get the Invoice Number
            UpdateInvoiceNumber(entity);

            UpdateTotals(entity);

            await _context.Invoices.AddAsync(entity);

            await _context.SaveChangesAsync();

            return(entity);
        }
        public async Task <Company> Add(Company entity)
        {
            //Get a unique 6 digit Alpha numeric for the CompanyId column
            SetUniqueIdForCompany(entity);
            // if(entity.Id == Guid.Empty)
            //     entity.Id = Guid.NewGuid();

            await _context.Companies.AddAsync(entity);

            await _context.SaveChangesAsync();

            return(entity);
        }