public ActionResult Edit(Models.DepartmentView model) { if (ModelState.IsValid) { var repository = new Repository <Department>(); var department = AutoMapper.Mapper.Map <Department>(model); //var department = new Department(); //department.Name = model.Name; //department.Id = model.Id; repository.Update(department, department.Id); } else { return(View(model)); } return(RedirectToAction("Index")); }
public ActionResult Create(Models.DepartmentView model) { //check for validations if (ModelState.IsValid) { //save it in db var rep = new Repository <Department>(); //convert departmentView to department object var deparment = new Department() { Name = model.Name }; rep.Add(deparment); } else { return(View(model)); } //display confirmation or redirect return(RedirectToAction("Index")); }