示例#1
0
        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"));
        }
示例#2
0
 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"));
 }