예제 #1
0
        public ActionResult EditStory(UserStory userStory)
        {
            List <SelectListItem> projects = GetProjectList();

            projects.Find(p => p.Value == userStory.ProjectID.ToString()).Selected = true;
            ViewBag.Projects = projects;
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View());
                }
                else
                {
                    using (OPTDBContext dbEntities = new OPTDBContext())
                    {
                        dbEntities.UserStories.Add(userStory);
                        dbEntities.Entry(userStory).State = System.Data.Entity.EntityState.Modified;
                        dbEntities.SaveChanges();
                    }
                    TempData["story_eidt_success"] = "sucess";
                    return(View(userStory));
                }
            }
            catch (System.Exception)
            {
                TempData["story_eidt_error"] = "failed.";
                return(View(userStory));
            }
        }
 public ActionResult EditProject(Project project)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(View());
         }
         else
         {
             using (OPTDBContext dbEntities = new OPTDBContext())
             {
                 dbEntities.Projects.Add(project);
                 dbEntities.Entry(project).State = System.Data.Entity.EntityState.Modified;
                 dbEntities.SaveChanges();
             }
             TempData["project_eidt_success"] = "Project updated successfully.";
             return(View(project));
         }
     }
     catch (System.Exception)
     {
         TempData["project_eidt_error"] = "Project record update failed.";
         return(View(project));
     }
 }
예제 #3
0
 public ActionResult Edit(Employee employee)
 {
     try
     {
         ViewBag.Designations = GetDesignationList();
         ViewBag.Managers     = GetManagerList();
         if (!ModelState.IsValid)
         {
             return(View());
         }
         else
         {
             if (employee.Designation.Equals("Project Manager"))
             {
                 employee.ManagerID = null;
             }
             using (OPTDBContext dbEntities = new OPTDBContext())
             {
                 dbEntities.Employees.Add(employee);
                 dbEntities.Entry(employee).State = System.Data.Entity.EntityState.Modified;
                 dbEntities.SaveChanges();
             }
             TempData["employee_eidt_success"] = "Employee record updated successfully.";
             return(View(employee));
         }
     }
     catch (System.Exception)
     {
         TempData["employee_eidt_error"] = "Employee record update failed.";
         return(View(employee));
     }
 }