public EmployeeBase_vm EmployeeAdd(EmployeeAdd_vm newEmployee) { // Attempt to add the new item var addedItem = ds.Employees.Add(Mapper.Map <EmployeeAdd_vm, Employee>(newEmployee)); ds.SaveChanges(); // If successful, return the added item, mapped to a view model object return((addedItem == null) ? null : Mapper.Map <Employee, EmployeeBase_vm>(addedItem)); }
public ActionResult Create(EmployeeAdd_vm newEmployee) { // Validate the input if (!ModelState.IsValid) { return(View(newEmployee)); } // Process the input var addedItem = man.EmployeeAdd(newEmployee); if (addedItem == null) { return(View(newEmployee)); } else { return(RedirectToAction("details", new { id = addedItem.EmployeeId })); } }