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); }
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 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); }
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); }
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); } }
public void RemoveEmployee(Employee e) { Employees.Remove(e); }
void IDepartmentDataSource.EntryChanged(Employee obj) { Entry(obj).State = EntityState.Modified; }
public void Update(Employee updateEntity) { context.Entry(updateEntity).State = EntityState.Modified; }
public void Remove(Employee removeEntity) { context.Employees.Remove(removeEntity); }
public void Add(Employee addEntity) { context.Employees.Add(addEntity); }