Пример #1
0
        public ActionResult Edit([Bind(Include = "Id,FirstName,LastName,Email,DateOfEmployment,DepartmentId")] EmployeeModel model)
        {
            if (ModelState.IsValid)
            {
                //new Employee()
                var employee = new Employee(model.FirstName, model.LastName, model.Email, model.DateOfEmployment, model.DepartmentId);
                service.EditEmployee(employee, model.Id);

                return(RedirectToAction("Index"));
            }
            ViewBag.DepartmentId = new SelectList(departmentService.GetAllDepartments(), "Id", "DepartmentName", model.DepartmentId);
            return(View(model));
        }
Пример #2
0
        public string Edit(EmployeeModel model)
        {
            string msg;

            if (ModelState.IsValid)
            {
                //new Employee()
                var employee = new Employee(model.FirstName, model.LastName, model.Email, model.DateOfEmployment, model.DepartmentId);
                service.EditEmployee(employee, model.Id);

                msg = "Saved Successfully";
                return(msg);
            }
            //ViewBag.DepartmentId = new SelectList(departmentService.GetAllDepartments(), "Id", "DepartmentName", model.DepartmentId);
            msg = "Saved Successfully";

            return(msg);
        }