Exemplo n.º 1
0
        public async Task <ServiceResponse <int> > Create(Debt newDebt)
        {
            await _context.AddAsync(newDebt);

            if (await _context.SaveChangesAsync() > 0)
            {
                return(new ServiceResponse <int>(newDebt.Id));
            }
            else
            {
                return(new ServiceResponse <int>("Error when trying to create a debt."));
            }
        }
Exemplo n.º 2
0
        public async Task <ServiceResponse <int> > Create(Installment newInstallment)
        {
            newInstallment.Debt = await _context.Debts.FirstOrDefaultAsync(d => d.Id == newInstallment.DebtId);

            await _context.AddAsync(newInstallment);

            if (await _context.SaveChangesAsync() > 0)
            {
                return(new ServiceResponse <int>(newInstallment.Id));
            }
            else
            {
                return(new ServiceResponse <int>("Error when trying to create a debt."));
            }
        }