Exemplo n.º 1
0
 public void SavePosition(Positions position)
 {
     if(position.ID == 0)
     {
         context.Positions.Add(position);
     }
     else
     {
         context.Entry(position).State = EntityState.Modified;
     }
     context.SaveChanges();
 }
Exemplo n.º 2
0
 public ActionResult edit(Positions position)
 {
     if(ModelState.IsValid)
     {
         try
         {
             repository.SavePosition(position);
         }
         catch(Exception ex)
         {
             ModelState.AddModelError("", ex.Message);
         }
     }
     if(ModelState.IsValid)
     {
         return RedirectToAction("list");
     }
     return View();
 }