Ejemplo n.º 1
0
        public ActionResult Create(int departmentId)
        {
            var model = new CreateEmployeeViewModel();
            model.DepartmentId = departmentId;

            return View(model);
        }
Ejemplo n.º 2
0
 public ActionResult Create(int departmentId)
 {
     var viewModel = new CreateEmployeeViewModel
     {
         DepartmentId = departmentId
     };
     return View(viewModel);
 }
Ejemplo n.º 3
0
 public ActionResult Create(int id)
 {
     var model = new CreateEmployeeViewModel();
     model.DepartmentId = id;
     model.HireDate = DateTime.Today;
     if (Request.IsAjaxRequest()) return PartialView("_CreatePartial", model);
     return View(model);
 }
Ejemplo n.º 4
0
 public ActionResult Create(CreateEmployeeViewModel viewmodel)
 {
     if (ModelState.IsValid)
     {
         var dept = _db.Departments.Single(d => d.Id == viewmodel.DepartmentId);
         Employee emp = new Employee();
         emp.Name = viewmodel.Name;
         emp.HireDate = viewmodel.HireDate;
         dept.Employees.Add(emp);
         _db.Save();
         return RedirectToAction("detail", "department", new { id = viewmodel.DepartmentId });
     }
     return View(viewmodel);
 }
Ejemplo n.º 5
0
 public ActionResult Create(CreateEmployeeViewModel viewModel)
 {
     if (ModelState.IsValid)
     {
         var department = this.db.Departments.Single(d => d.Id == viewModel.DepartmentId);
         var emp = new Employee
         {
             Name = viewModel.Name,
             HireDate = viewModel.JoiningDate
         };
         department.Employees.Add(emp);
         this.db.Save();
         return RedirectToAction("Details", "Department", new { id = viewModel.DepartmentId });
     }
     return View(viewModel);
 }
        public ActionResult Create(CreateEmployeeViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var department = _db.Departments.Single(dep => dep.Id == viewModel.DepartmentId);
                var employee = new Employee() {Name = viewModel.Name};

                department.Employees.Add(employee);

                _db.Save();

                return RedirectToAction("Detail", "Department", new {Id = viewModel.DepartmentId});
            }

            return View(viewModel);
        }
Ejemplo n.º 7
0
        public ActionResult Create(CreateEmployeeViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var dept = _db.Departments.Single(x => x.Id == viewModel.DepartmentId);
                var employee = new Employee
                    {
                        Name = viewModel.Name,
                        HireDate = viewModel.HireDate
                    };
                dept.Employees.Add(employee);
                _db.Save();

                return RedirectToAction("detail", "department", new {id = viewModel.DepartmentId});
            }
            return View(viewModel);
        }
Ejemplo n.º 8
0
        public ActionResult Create(CreateEmployeeViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var department = _db.Departments.Single(d => d.Id == viewModel.DepartmentId);
                var employee = new Employee();
                employee.Name = viewModel.Name;
                employee.HireDate = viewModel.HireDate;
                department.Employees.Add(employee);

                _db.Save();

                if (Request.IsAjaxRequest()) return Json(JsonResponseFactory.SuccessResponse(), JsonRequestBehavior.DenyGet);
                return RedirectToAction("detail", "department", new { id = viewModel.DepartmentId });
            }
            if (Request.IsAjaxRequest()) return Json(JsonResponseFactory.ErrorResponse("Please review your form."), JsonRequestBehavior.DenyGet);
            return View(viewModel);
        }
Ejemplo n.º 9
0
 public ActionResult Create(CreateEmployeeViewModel model )
 {
     if (ModelState.IsValid)
     {
         var department = _db.Departments.Single(d => d.Id == model.DepartmentId);
         Employee employee = new Employee()
         {
             HireDate = model.HireDate,
             Name = model.Name
         };
         department.Employees.Add(employee);
         _db.Save();
         return RedirectToAction("detail", "department", new { depatmentId = model.DepartmentId });
     }
     else
     {
         return View(model);
     }
 }