public static void AssignTask(int id, string developerId)
        {
            DevTask devTask = GetTask(id);

            devTask.DeveloperId = developerId;
            db.SaveChanges();
        }
        public static float taskCostDeveloper(DevTask task)
        {
            var daysPassedTask = (DateTime.Now - task.DateCreated.Date).Days;
            var devAmount      = task.Developer.Salary * daysPassedTask;

            return((float)devAmount);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            DevTask devTask = db.DevTasks.Find(id);

            db.DevTasks.Remove(devTask);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public static void CreateBugNotification(DevTask task, Project project)
        {
            NotificationManager NotifiMngr = new NotificationManager(project.Id, task.Id, DateTime.Now, project.UserId, "Bug Found in task");

            db.NotificationManagers.Add(NotifiMngr);
            project.NotificationManagers.Add(NotifiMngr);
            db.SaveChanges();
        }
        //ADD TASK
        public static void AddTask(int ProjectId, string Title, string Desc, Priority pr, Status Status, DateTime DeadLine, string DevId)
        {
            Project project1 = db.Projects.FirstOrDefault(p => p.Id == ProjectId);
            DevTask devTask  = new DevTask(Title, Desc, pr, Status, DateTime.Now, DeadLine, project1.Id, DevId);

            project1.DevTasks.Add(devTask);
            db.SaveChanges();
            TaskHelper.CreateDeveloperNotification(devTask);
            db.SaveChanges();
        }
 public ActionResult AddComment(DevTask devTask)
 {
     if (ModelState.IsValid)
     {
         var updateDevTask = db.DevTasks.FirstOrDefault(x => x.Id == devTask.Id);
         updateDevTask.Comment = devTask.Comment;
         db.SaveChanges();
     }
     return(Redirect("Index"));
 }
 public ActionResult ReportABug(DevTask devTask)
 {
     if (ModelState.IsValid)
     {
         var BugReportDevTask = db.DevTasks.FirstOrDefault(x => x.Id == devTask.Id);
         BugReportDevTask.BugReport = devTask.BugReport;
         //    var project = db.Projects.FirstOrDefault(p => p.);
         TaskHelper.CreateBugNotification(BugReportDevTask, BugReportDevTask.Project);
     }
     return(Redirect("Index"));
 }
 public ActionResult Edit([Bind(Include = "Id,Name,Description,StartDate,Deadline,PercentCompleted,IsComplete,ProjectId,Priority")] DevTask devTask)
 {
     if (ModelState.IsValid)
     {
         db.Entry(devTask).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ProjectId = new SelectList(db.Projects, "Id", "Name", devTask.ProjectId);
     return(View(devTask));
 }
        public ActionResult ReportBug(int taskId, string description)
        {
            DevTask devTask = db.DevTasks.Find(taskId);

            if (devTask != null && description != null)
            {
                DevTaskHelper.SendBugReport(devTask, description);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(PartialView(devTask));
        }
        public static void CreateDeveloperNotification(DevTask newtask)
        {
            TimeSpan diff     = (newtask.Deadline).Subtract(DateTime.Now);
            int      daysleft = (int)diff.TotalDays;

            if (daysleft <= 1 && newtask.NotificationDevs == null)
            {
                NotificationDev notify = new NotificationDev("One Day left for this task", DateTime.Now, newtask.Id, newtask.DeveloperId);
                db.NotificationDevs.Add(notify);
                newtask.NotificationDevs = notify;
                newtask.Developer.NotificationDev.Add(notify);
                db.SaveChanges();
            }
        }
Пример #11
0
        public void ProjectCompletedNotification(Project project, DevTask task)
        {
            string title                 = project.Name;
            string description           = project.Description;
            List <ApplicationUser> users = db.Users.Where(u => UserManager.checkUserRole(u.Id, "Project Manager")).ToList();

            foreach (ApplicationUser projectManager in users)
            {
                if ((project.IsCompleted || task.IsComplete) || (DateTime.Now > project.Deadline && !task.IsComplete))
                {
                    Notify(title, description, project, projectManager);
                }
            }
        }
Пример #12
0
        // GET: DevTasks1/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DevTask devTask = db.DevTasks.Find(id);

            if (devTask == null)
            {
                return(HttpNotFound());
            }
            return(View(devTask));
        }
Пример #13
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DevTask devTask = db.DevTasks.Find(id);

            if (devTask == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ProjectId = new SelectList(db.Projects, "Id", "Name", devTask.ProjectId);
            return(View(devTask));
        }
Пример #14
0
 public ActionResult AssignDevs(int[] devIds, int taskId)
 {
     if (ModelState.IsValid)
     {
         DevTask devTask             = db.DevTasks.Find(taskId);
         List <ApplicationUser> devs = new List <ApplicationUser>();
         foreach (int id in devIds)
         {
             devs.Add(db.Users.Find(id));
         }
         DevTaskHelper.AssignDevsToTask(devs, devTask);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(taskId));
 }
Пример #15
0
        public ActionResult UpdateCompletion(double percent, int id)
        {
            DevTask devTask = db.DevTasks.Find(id);

            if (ModelState.IsValid)
            {
                DevTaskHelper.UpdateCompletionPercent(percent, devTask);
                db.SaveChanges();
                if (percent == 100)
                {
                    return(RedirectToAction("AddNewComment", id));
                }
                return(RedirectToAction("Index"));
            }
            return(PartialView());
        }
        public ActionResult UpdateDeveloperTask(DevTask devTask)
        {
            if (ModelState.IsValid)
            {
                var updateDevTask = db.DevTasks.FirstOrDefault(x => x.Id == devTask.Id);
                if (devTask.PercentCompleted == 100)
                {
                    updateDevTask.DateCompleted    = DateTime.Now;
                    updateDevTask.PercentCompleted = devTask.PercentCompleted;
                    updateDevTask.Status           = Status.Completed;

                    NotificationManager NotifiManager = new NotificationManager(
                        updateDevTask.ProjectId,
                        updateDevTask.Id,
                        DateTime.Now,
                        updateDevTask.Project.UserId,
                        "The Task is Completed");

                    db.NotificationManagers.Add(NotifiManager);
                    updateDevTask.Project.NotificationManagers.Add(NotifiManager);
                    updateDevTask.Project.User.NotificationManager.Add(NotifiManager);
                    db.SaveChanges();
                }
                else
                {
                    updateDevTask.Comment          = null;
                    updateDevTask.DateCompleted    = null;
                    updateDevTask.PercentCompleted = devTask.PercentCompleted;
                    if (updateDevTask.Status == Status.Completed)
                    {
                        updateDevTask.Status = Status.Assigned;
                    }
                }
                db.SaveChanges();
            }
            return(Redirect("Index"));
        }
Пример #17
0
        protected override void Seed(TaskManagerProject.Models.ApplicationDbContext context)
        {
            //  This method will be called after migrating to the latest version.
            if (!context.Roles.Any())
            {
                UserManager.createRole("Project Manager");
                UserManager.createRole("Developer");
            }

            if (!context.Users.Any())
            {
                UserManager.CreateUser("*****@*****.**");
                UserManager.CreateUser("*****@*****.**");
            }

            string PmId = context.Users.FirstOrDefault().Id;

            if (!UserManager.checkUserRole(PmId, "Project Manager"))
            {
                ApplicationUser user = context.Users.FirstOrDefault(u => u.UserName == "*****@*****.**");

                UserManager.AddUserToRole(PmId, "Project Manager");
            }

            string DeId = context.Users.FirstOrDefault().Id;

            if (!UserManager.checkUserRole(DeId, "Developer"))
            {
                ApplicationUser user = context.Users.FirstOrDefault(u => u.UserName == "*****@*****.**");

                UserManager.AddUserToRole(DeId, "Developer");
            }

            if (!context.Projects.Any())
            {
                Project firstProject  = new Project(1, "firstProject", "Our first test project", 100.00, 95.00);
                Project secondProject = new Project(2, "secondProject", "Our second test project", 500.00, 600.00);
                Project thirdProject  = new Project(3, "thirdProject", "Our third test project", 250.00, 275.00);
                Project fourthProject = new Project(4, "fourthProject", "Our fourth test project", 150.00, 130.00);

                context.Projects.Add(firstProject);
                context.Projects.Add(secondProject);
                context.Projects.Add(thirdProject);
                context.Projects.Add(fourthProject);
            }

            if (!context.DevTasks.Any())
            {
                DevTask taskOne   = dth.CreateDevTask(1, "TaskOneInFirstProject", "First class of first project", DateTime.Parse("02/02/2024"), context.Projects.FirstOrDefault().Id);
                DevTask taskTwo   = dth.CreateDevTask(2, "TaskTwoInFirstProject", "Second class of first project", DateTime.Parse("02/02/2015"), context.Projects.FirstOrDefault().Id);
                DevTask taskThree = dth.CreateDevTask(3, "TaskThreeInFirstProject", "Third class of first project", DateTime.Parse("02/02/2016"), context.Projects.FirstOrDefault().Id);
                DevTask taskFour  = dth.CreateDevTask(4, "TaskFourinFirstProject", "Fourth class of first project", DateTime.Parse("02/02/2027"), context.Projects.FirstOrDefault().Id);

                context.DevTasks.Add(taskOne);
                context.DevTasks.Add(taskTwo);
                context.DevTasks.Add(taskThree);
                context.DevTasks.Add(taskFour);
            }
            DevTask firstTask = context.DevTasks.FirstOrDefault();

            if (!context.Projects.ToList()[1].DevTasks.Any())
            {
                DevTask taskOne   = dth.CreateDevTask(5, "TaskOneInSecondProject", "First class of second project", DateTime.Parse("02/02/2024"), context.Projects.ToList()[1].Id);
                DevTask taskTwo   = dth.CreateDevTask(6, "TaskTwoInSecondProject", "Second class of second project", DateTime.Parse("02/02/2015"), context.Projects.ToList()[1].Id);
                DevTask taskThree = dth.CreateDevTask(7, "TaskOneInThirdProject", "First class of third project", DateTime.Parse("02/02/2024"), context.Projects.ToList()[2].Id);
                DevTask taskFour  = dth.CreateDevTask(8, "TaskTwoInThirdProject", "Second class of third project", DateTime.Parse("02/02/2015"), context.Projects.ToList()[2].Id);
                DevTask taskFive  = dth.CreateDevTask(9, "TaskOneInFourthProject", "First class of fourth project", DateTime.Parse("02/02/2024"), context.Projects.ToList()[3].Id);
                DevTask taskSix   = dth.CreateDevTask(10, "TaskTwoInFourthProject", "Second class of fourth project", DateTime.Parse("02/02/2015"), context.Projects.ToList()[3].Id);

                context.DevTasks.Add(taskOne);
                context.DevTasks.Add(taskTwo);
                context.DevTasks.Add(taskThree);
                context.DevTasks.Add(taskFour);
                context.DevTasks.Add(taskFive);
                context.DevTasks.Add(taskSix);
            }

            if (!context.Notifications.Any())
            {
                Notification notificationOne   = new Notification("Notification1", "first in user 1 and task 1", context.Users.First().Id, firstTask.Id, null);
                Notification notificationTwo   = new Notification("Notification2", "second in user 1 and task 1", context.Users.First().Id, firstTask.Id, null);
                Notification notificationThree = new Notification("Notification3", "first in user 1 and task 2", context.Users.First().Id, context.DevTasks.ToList()[1].Id, null);
                Notification notificationFour  = new Notification("Notification4", "second in user 1 and task 2", context.Users.First().Id, context.Projects.ToList()[1].Id, null);
                Notification notificationFive  = new Notification("Notification5", "first in user 2 and task 3", context.Users.ToList()[1].Id, context.Projects.ToList()[2].Id, null);
                Notification notificationSix   = new Notification("Notification6", "second in user 2 and task 3", context.Users.ToList()[1].Id, context.Projects.ToList()[2].Id, null);
                Notification notificationSeven = new Notification("Notification5", "first in user 2 and task 4", context.Users.ToList()[1].Id, context.Projects.ToList()[3].Id, null);
                Notification notificationEight = new Notification("Notification6", "second in user 2 and task 4", context.Users.ToList()[1].Id, context.Projects.ToList()[3].Id, null);
                context.Notifications.Add(notificationOne);
                context.Notifications.Add(notificationTwo);
                context.Notifications.Add(notificationThree);
                context.Notifications.Add(notificationFour);
                context.Notifications.Add(notificationFive);
                context.Notifications.Add(notificationSix);
                context.Notifications.Add(notificationSeven);
            }
            if (!context.Notes.Any())
            {
                foreach (DevTask d in context.DevTasks)
                {
                    string title = "First Note in " + d.Name;
                    Note   note  = new Note(title, d.Id);
                    context.Notes.Add(note);
                }
            }

            //if (firstTask.ApplicationUsers.Count() <= 0)
            //{
            //    DevTaskHelper.AssignDevsToTask(context.Users.ToList(), firstTask);
            //};

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data.
        }