Ejemplo n.º 1
0
 public IActionResult Upsert(Category category)
 {
     if (ModelState.IsValid)
     {
         if (category.Id == 0)
         {
             _unitOfWork.Category.Add(category);
         }
         else
         {
             _unitOfWork.Category.Update(category);
         }
         _unitOfWork.Save();
         return(RedirectToAction(nameof(Index)));
     }
     return(View(category));
 }
Ejemplo n.º 2
0
 public IActionResult Upsert(CoverType coverType)
 {
     if (ModelState.IsValid)
     {
         var parameter = new DynamicParameters();
         parameter.Add("@Name", coverType.Name);
         if (coverType.Id == 0)
         {
             _unitOfWork.SP_Call.Execute(SD.Proc_CoverType_Create, parameter);
         }
         else
         {
             parameter.Add("@Id", coverType.Id);
             _unitOfWork.SP_Call.Execute(SD.Proc_CoverType_Update, parameter);
         }
         _unitOfWork.Save();
         return(RedirectToAction(nameof(Index)));
     }
     return(View(coverType));
 }