Esempio n. 1
0
        public async Task <IActionResult> PutIncomeItem(long id, IncomeItem incomeItem)
        {
            if (id != incomeItem.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Esempio n. 2
0
        public async Task <IActionResult> Create([Bind("ID,Title,Date,Type,Price")] Income income)
        {
            if (ModelState.IsValid)
            {
                _context.Add(income);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(income));
        }