public ActionResult Create([Bind(Include = "FullName, Phone, Email, Position")] Employee employee) { if (ModelState.IsValid) { employees.Add(employee); return(RedirectToAction("Index")); } return(View()); }
public async Task <IActionResult> Create(Employee item) { if (item != null && ModelState.IsValid) { await EmployeeRepo.Add(item); return(RedirectToAction("Details", new { id = item.Id })); } ViewBag.FirmId = new SelectList(await FirmRepo.GetAll(), "Id", "Name", item.FirmId); return(View(item)); }
public ActionResult Add(AddEmployeeViewModel model) { if (ModelState.IsValid) { Employee employee = new Employee(); employee.FirstName = model.FirstName; employee.LastName = model.LastName; employee.Phone = model.Phone; employee.DepartmentId = model.DepartmentId; EmployeeRepo.Add(employee); return(RedirectToAction("Index")); } else { model.Departments = GetDepartmentSelectList(); return(View(model)); } }