public ActionResult EditProject(int?id)
        {
            OPTDBContext dbEntities = new OPTDBContext();
            Project      project    = dbEntities.Projects.Find(id);

            return(View(project));
        }
Exemplo n.º 2
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));
     }
 }
 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));
     }
 }
        // GET: Projects
        public ActionResult Index()
        {
            OPTDBContext   context  = new OPTDBContext();
            List <Project> projects = context.Projects.ToList();

            return(View(projects));
        }
 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()));
     }
 }
Exemplo n.º 6
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));
            }
        }
Exemplo n.º 7
0
 public ActionResult Login(LoginViewModel model)
 {
     if (!ModelState.IsValid)
     {
         TempData["login_error"] = "Please fill all the fields";
         return(View(model));
     }
     else
     {
         OPTDBContext dbEntities = new OPTDBContext();
         UserAccount  user       = dbEntities.UserAccounts.Where(account => account.Email == model.email && account.Password == model.password).SingleOrDefault();
         if (user != null)
         {
             Session["user_id"]    = user.EmployeeID;
             Session["user_email"] = user.Email;
             Session["name"]       = user.Employee.EmployeeName;
             Session["role"]       = user.Employee.Designation;
             return(RedirectToAction("Index", "Home"));
         }
         else
         {
             TempData["invalid_login"] = "******";
             return(View(model));
         }
     }
 }
 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());
 }
Exemplo n.º 9
0
        // GET: UserStories
        public ActionResult Index()
        {
            OPTDBContext     context = new OPTDBContext();
            List <UserStory> stories = context.UserStories.ToList();

            return(View(stories));
        }
Exemplo n.º 10
0
        // GET: Employee
        public ActionResult ViewAllEmployees()
        {
            OPTDBContext    context   = new OPTDBContext();
            List <Employee> employees = context.Employees.Where(model => model.Designation != "Admin").ToList();

            return(View(employees));
        }
Exemplo n.º 11
0
        public ActionResult Edit(int?id)
        {
            ViewBag.Designations = GetDesignationList();
            ViewBag.Managers     = GetManagerList();
            OPTDBContext dbEntities = new OPTDBContext();
            Employee     employee   = dbEntities.Employees.Where(model => model.EmployeeID == id).SingleOrDefault();

            return(View(employee));
        }
Exemplo n.º 12
0
        public ActionResult EditStory(int?id)
        {
            OPTDBContext          dbEntities = new OPTDBContext();
            UserStory             story      = dbEntities.UserStories.Find(id);
            List <SelectListItem> projects   = GetProjectList();

            projects.Find(p => p.Value == story.ProjectID.ToString()).Selected = true;
            ViewBag.Projects = projects;
            return(View(story));
        }
        public FileResult DownloadTaskData(int id)
        {
            OPTDBContext context       = new OPTDBContext();
            ProjectTask  projectTaskDB = context.ProjectTasks.FirstOrDefault(pt => pt.ProjectTaskID == id);
            string       fileName      = projectTaskDB.TaskData;
            string       path          = Server.MapPath("~/Content/Uploads/" + fileName);

            byte[] fileBytes = System.IO.File.ReadAllBytes(path);
            return(File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName));
            //return File(path, System.Net.Mime.MediaTypeNames.Application.Octet, fileName);
        }
 public ActionResult UploadTask(int id)
 {
     try
     {
         OPTDBContext context     = new OPTDBContext();
         ProjectTask  projectTask = context.ProjectTasks.FirstOrDefault(pt => pt.ProjectTaskID == id);
         return(View(projectTask));
     }
     catch (System.Exception)
     {
         return(View(new ProjectTask()));
     }
 }
        // GET: ProjectTasks
        public ActionResult Index()
        {
            OPTDBContext       context = new OPTDBContext();
            List <ProjectTask> projectTasks;

            if (!Session["role"].ToString().Equals("Developer") && !Session["role"].ToString().Equals("Designer"))
            {
                projectTasks = context.ProjectTasks.ToList();
            }
            else
            {
                int useID = int.Parse(Session["user_id"].ToString().Trim());
                projectTasks = context.ProjectTasks.Where(task => task.AssignedTo == useID).ToList();
            }
            return(View(projectTasks));
        }
Exemplo n.º 16
0
 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());
 }
Exemplo n.º 17
0
 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 }));
     }
 }
Exemplo n.º 19
0
        private List <SelectListItem> GetManagerList()
        {
            List <SelectListItem> managers = new List <SelectListItem>()
            {
                new SelectListItem {
                    Text = "Please select", Value = "-1", Disabled = true, Selected = true
                }
            };
            OPTDBContext    dbEntities = new OPTDBContext();
            List <Employee> dbmanagers = dbEntities.Employees.Where(employee => employee.Designation.Equals("Project Manager")).ToList();

            foreach (Employee employee in dbmanagers)
            {
                managers.Add(new SelectListItem()
                {
                    Text  = employee.EmployeeName,
                    Value = employee.EmployeeID.ToString()
                });
            }
            return(managers);
        }
Exemplo n.º 20
0
        private List <SelectListItem> GetProjectList()
        {
            List <SelectListItem> projects = new List <SelectListItem>()
            {
                new SelectListItem {
                    Text = "Please select", Value = "", Disabled = true, Selected = true
                }
            };
            OPTDBContext   dbEntities = new OPTDBContext();
            List <Project> dbprojects = dbEntities.Projects.ToList();

            foreach (Project project in dbprojects)
            {
                projects.Add(new SelectListItem()
                {
                    Text  = project.ProjectName,
                    Value = project.ProjectID.ToString()
                });
            }
            return(projects);
        }
        private List <SelectListItem> GetUserStoriesList()
        {
            List <SelectListItem> userstories = new List <SelectListItem>()
            {
                new SelectListItem {
                    Text = "Please select", Value = "", Disabled = true, Selected = true
                }
            };
            OPTDBContext     dbEntities    = new OPTDBContext();
            List <UserStory> dbuserstories = dbEntities.UserStories.ToList();

            foreach (UserStory userStory in dbuserstories)
            {
                userstories.Add(new SelectListItem()
                {
                    Text  = userStory.Story,
                    Value = userStory.UserStoryID.ToString()
                });
            }
            return(userstories);
        }
        private List <SelectListItem> GetEmployeeList()
        {
            List <SelectListItem> employees = new List <SelectListItem>()
            {
                new SelectListItem {
                    Text = "Please select", Value = "", Disabled = true, Selected = true
                }
            };
            OPTDBContext    dbEntities  = new OPTDBContext();
            List <Employee> dbemployees = dbEntities.Employees.Where(emp => emp.Designation != "Project Manager" && emp.Designation != "Business Analyst" && emp.Designation != "Admin").ToList();

            foreach (Employee employee in dbemployees)
            {
                employees.Add(new SelectListItem()
                {
                    Text  = employee.EmployeeName,
                    Value = employee.EmployeeID.ToString()
                });
            }
            return(employees);
        }
Exemplo n.º 23
0
 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());
 }