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)); } }
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 AddNewProject(ProjectViewModel project) { try { if (!ModelState.IsValid) { return(View()); } else { OPTDBContext dbEntities = new OPTDBContext(); Project dbproject = new Project() { ProjectName = project.ProjectName, ClientName = project.ClientName, StartDate = project.StartDate, EndDate = project.EndDate, ProjectDescription = project.ProjectDescription }; dbEntities.Projects.Add(dbproject); dbEntities.SaveChanges(); TempData["newproject_success"] = "added"; return(View()); } } catch (System.Exception) { TempData["newproject_error"] = "error"; } return(View()); }
public ActionResult UploadTask(ProjectTask projectTask) { try { OPTDBContext context = new OPTDBContext(); ProjectTask projectTaskDB = context.ProjectTasks.FirstOrDefault(pt => pt.ProjectTaskID == projectTask.ProjectTaskID); projectTaskDB.TaskCompletionDesciption = string.IsNullOrEmpty(projectTask.TaskCompletionDesciption) ? "" : projectTask.TaskCompletionDesciption; HttpPostedFileBase file = Request.Files["file"]; if (file != null && file.ContentLength > 0) { string FileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "-" + file.FileName; string path = Server.MapPath("~/Content/Uploads/" + FileName); file.SaveAs(path); projectTaskDB.TaskData = FileName; } context.SaveChanges(); TempData["data_upload_ok"] = "Ok"; return(View(projectTask)); } catch (System.Exception ex) { TempData["data_upload_error"] = ex.ToString(); return(View(new ProjectTask())); } }
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)); } }
public ActionResult AddNewEmployee(EmployeeViewModel employee) { try { ViewBag.Designations = GetDesignationList(); ViewBag.Managers = GetManagerList(); if (!ModelState.IsValid) { return(View()); } else { OPTDBContext dbEntities = new OPTDBContext(); if (employee.Designation.Equals("Project Manager")) { employee.ManagerID = null; } Employee dbemployee = new Employee() { EmployeeName = employee.EmployeeName, Designation = employee.Designation, ContactNo = employee.ContactNo, EMailID = employee.EMailID, ManagerID = employee.ManagerID, SkillSets = employee.SkillSets }; dbEntities.Employees.Add(dbemployee); dbEntities.SaveChanges(); /// Create account ------ UserAccount userAccount = new UserAccount() { EmployeeID = dbemployee.EmployeeID, Email = dbemployee.EMailID, Password = "******", }; dbEntities.UserAccounts.Add(userAccount); dbEntities.SaveChanges(); TempData["newemployee_success"] = "added"; return(View()); } } catch (System.Exception) { TempData["newemployee_error"] = "error"; } return(View()); }
public ActionResult Delete(int?id) { if (id.HasValue) { OPTDBContext ctx = new OPTDBContext(); UserAccount userAccount = ctx.UserAccounts.Where(account => account.EmployeeID == id).SingleOrDefault(); Employee employee = ctx.Employees.Where(emp => emp.EmployeeID == id).SingleOrDefault(); if (userAccount != null && employee != null) { ctx.UserAccounts.Remove(userAccount); ctx.SaveChanges(); ctx.Employees.Remove(employee); ctx.SaveChanges(); } } return(RedirectToAction("ViewAllEmployees")); }
public JsonResult MarkCompleted(int task_id, int task_status) { try { OPTDBContext context = new OPTDBContext(); ProjectTask projectTask = context.ProjectTasks.FirstOrDefault(pt => pt.ProjectTaskID == task_id); if (projectTask != null) { projectTask.TaskStatus = task_status; context.SaveChanges(); return(Json(new { code = 200 })); } return(Json(new { code = 500 })); } catch (System.Exception) { return(Json(new { code = 200 })); } }
public ActionResult AddNewStory(UserStory userStory) { try { ViewBag.Projects = GetProjectList(); if (!ModelState.IsValid) { return(View()); } else { OPTDBContext dbEntities = new OPTDBContext(); dbEntities.UserStories.Add(userStory); dbEntities.SaveChanges(); TempData["newstory_success"] = "added"; } } catch (System.Exception) { TempData["newstory_error"] = "error"; } return(View()); }
public ActionResult AddNewTask(ProjectTask projectTask) { ViewBag.Employees = GetEmployeeList(); ViewBag.UserStories = GetUserStoriesList(); ViewBag.TaskTypes = GetTaskTypeList(); try { if (!ModelState.IsValid) { return(View()); } OPTDBContext dbEntities = new OPTDBContext(); dbEntities.ProjectTasks.Add(projectTask); dbEntities.SaveChanges(); TempData["newtask_success"] = "added"; } catch (System.Exception) { TempData["newtask_error"] = "error"; } return(View()); }
public ActionResult AddComment(ManagerComment managerComment) { ViewBag.TaskID = managerComment.ProjectTaskID; try { if (!ModelState.IsValid) { return(View()); } else { OPTDBContext dbEntities = new OPTDBContext(); dbEntities.ManagerComments.Add(managerComment); dbEntities.SaveChanges(); TempData["newcomment_success"] = "added"; return(View()); } } catch (System.Exception) { TempData["newcomment_error"] = "error"; } return(View()); }