Ejemplo n.º 1
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);
 }
        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.º 3
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);
 }
Ejemplo n.º 4
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.º 5
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.º 6
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);
     }
 }
Ejemplo n.º 7
0
 public void RemoveEmployee(Employee e)
 {
     Employees.Remove(e);
 }
Ejemplo n.º 8
0
 void IDepartmentDataSource.EntryChanged(Employee obj)
 {
     Entry(obj).State = EntityState.Modified;
 }
Ejemplo n.º 9
0
 public void Update(Employee updateEntity)
 {
     context.Entry(updateEntity).State = EntityState.Modified;
 }
Ejemplo n.º 10
0
 public void Remove(Employee removeEntity)
 {
     context.Employees.Remove(removeEntity);
 }
Ejemplo n.º 11
0
 public void Add(Employee addEntity)
 {
     context.Employees.Add(addEntity);
 }