Esempio n. 1
0
        public IActionResult Upsert(int?id)
        {
            ToDoList.Models.Employee EmployeeController = new ToDoList.Models.Employee();
            if (id == null) //create
            {
                return(View(EmployeeController));
            }
            EmployeeController = _unitOfWork.Employee.Get(id.GetValueOrDefault()); //edit
            if (EmployeeController == null)
            {
                return(NotFound());
            }

            return(View(EmployeeController));
        }
Esempio n. 2
0
 public IActionResult Upsert(ToDoList.Models.Employee EmployeeController) //ne radi update id je uvijek 0
 {
     if (ModelState.IsValid)
     {
         if (EmployeeController.EmployeeId == 0)
         {
             _unitOfWork.Employee.Add(EmployeeController);
         }
         else
         {
             _unitOfWork.Employee.Update(EmployeeController);
         }
         _unitOfWork.Save();
         return(RedirectToAction(nameof(Index)));
     }
     return(View(EmployeeController));
 }