public async Task <IActionResult> PutIncome(int id, IncomeModel income)
        {
            if (id != income.StatementId)
            {
                return(BadRequest());
            }

            _context.Entry(income).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!IncomeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutCategory(int id, Category category)
        {
            if (id != category.CategoryId)
            {
                return(BadRequest());
            }

            _context.Entry(category).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CategoryExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <bool> Update(T value)
        {
            bool isUpdated = false;

            _entities.Attach(value);
            _context.Entry(value).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            isUpdated = true;

            return(isUpdated);
        }
示例#4
0
        public Income UpdateIncome(Income income)
        {
            Income tempIncome;

            try
            {
                tempIncome = _financeManagerContext.Incomes.Attach(income);
                _financeManagerContext.Entry(tempIncome).State = EntityState.Modified;
                _financeManagerContext.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(tempIncome);
        }
示例#5
0
        public Outgoing UpdateOutgoing(Outgoing outgoing)
        {
            Outgoing tempOutgoing;

            try
            {
                tempOutgoing = _financeManagerContext.Outgoings.Attach(outgoing);
                _financeManagerContext.Entry(tempOutgoing).State = EntityState.Modified;
                _financeManagerContext.SaveChanges();
            }
            catch (Exception ex)
            {
                tempOutgoing = null;
            }
            return(tempOutgoing);
        }