コード例 #1
0
 public IActionResult Upsert(CoverType coverType)
 {
     if (ModelState.IsValid)
     {
         if (coverType.Id == 0)
         {
             _unitOfWork.CoverType.Add(coverType);
         }
         else
         {
             _unitOfWork.CoverType.Update(coverType);
         }
         _unitOfWork.Save();
         return(RedirectToAction(nameof(Index)));
     }
     return(View(coverType));
 }
コード例 #2
0
 public IActionResult Upsert(Category category)
 {
     if (ModelState.IsValid)
     {
         if (category.Id == 0)
         {
             _extendedUnitOfWork.Category.Add(category);
         }
         else
         {
             _extendedUnitOfWork.Category.Update(category);
         }
         _extendedUnitOfWork.Save();
         return(RedirectToAction(nameof(Index)));
     }
     return(View(category));
 }