Beispiel #1
0
        public static ProTask GetTask(int Id)
        {
            ApplicationDbContext db = new ApplicationDbContext();
            ProTask proTask         = db.ProTasks.Find(Id);

            db.Dispose();
            if (proTask == null)
            {
                return(null);
            }
            return(proTask);
        }
Beispiel #2
0
        public static void Assign(int id, string DeveloperId)
        {
            ApplicationDbContext db = new ApplicationDbContext();
            ProTask proTask         = GetTask(id);

            if (proTask != null)
            {
                proTask.UserId = DeveloperId;
                db.SaveChanges();
                db.Dispose();
            }
        }
Beispiel #3
0
        public static void Edit(int id, string taskName, string taskContent, string userId, DateTime deadline, Priority priority, double completedPercentage)
        {
            ApplicationDbContext db = new ApplicationDbContext();
            ProTask proTask         = GetTask(id);
            var     user            = db.Users.Find(userId);

            if (proTask != null)
            {
                proTask.UserName            = user.UserName;
                proTask.Name                = taskName;
                proTask.Content             = taskContent;
                proTask.UserId              = userId;
                proTask.Deadline            = deadline;
                proTask.Priority            = priority;
                proTask.CompletedPercentage = completedPercentage;
                db.Entry(proTask).State     = EntityState.Modified;
                db.SaveChanges();
                db.Dispose();
            }
        }
Beispiel #4
0
        public static void Create(int projectId, string Name, string Content, string userId, DateTime deadline, Priority priority, string Comment)
        {
            ApplicationDbContext db = new ApplicationDbContext();
            var     user            = db.Users.Find(userId);
            ProTask proTask         = new ProTask
            {
                Name        = Name,
                Content     = Content,
                UserName    = user.UserName,
                ProjectId   = projectId,
                UserId      = userId,
                CreatedTime = DateTime.Now,
                Deadline    = deadline,
                Priority    = priority,
                Comment     = Comment
            };

            db.ProTasks.Add(proTask);
            db.SaveChanges();
            db.Dispose();
        }