コード例 #1
0
 public ActionResult Edit(int id, DepartEditForm form)
 {
     try
     {
         // TODO: Add update logic here
         if (ModelState.IsValid)
         {
             DepartmentService repo    = new DepartmentService();
             Department        oldData = repo.Get(id);
             oldData.Name        = form.Name;
             oldData.Description = form.Description;
             if (repo.Update(oldData))
             {
                 return(RedirectToAction("Details/" + id));
             }
             else
             {
                 return(View(form));
             }
         }
         else
         {
             return(View(form));
         }
     }
     catch
     {
         return(View());
     }
 }
コード例 #2
0
        // GET: Admin/Department/Edit/5
        public ActionResult Edit(int id)
        {
            DepartmentService repo   = new DepartmentService();
            Department        dep    = repo.Get(id);
            DepartEditForm    depart = new DepartEditForm(dep);

            return(View(depart));
        }