Пример #1
0
 public IActionResult Upsert(int?id)
 {
     BookBazar.Models.Company company = new BookBazar.Models.Company();
     if (id == null)
     {
         return(View(company));
     }
     company = _iUnitOfWork.Company.Get(id.GetValueOrDefault());
     if (company == null)
     {
         return(NotFound());
     }
     return(View(company));
 }
Пример #2
0
 public IActionResult Upsert(BookBazar.Models.Company company)
 {
     if (ModelState.IsValid)
     {
         if (company.Id == 0)
         {
             _iUnitOfWork.Company.Add(company);
         }
         else
         {
             _iUnitOfWork.Company.Update(company);
         }
         _iUnitOfWork.Save();
         return(RedirectToAction(nameof(Index)));
     }
     return(View(company));
 }