public async Task <IActionResult> Edit(byte id, [Bind("Id,Name,Description,Rate")] Criteria criteria)
        {
            if (id != criteria.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(criteria);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CriteriaExists(criteria.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(criteria));
        }
Exemple #2
0
 public bool CriteriaEdit(Criteria criteria)
 {
     using (var db = new ScheduleKSTUContext())
     {
         using (var dbContextTransaction = db.Database.BeginTransaction())
         {
             try
             {
                 db.Update(criteria);
                 db.SaveChanges();
             }
             catch (Exception ex)
             {
                 dbContextTransaction.Rollback();
                 throw ex;
             }
         }
     }
     return(true);
 }