Ejemplo n.º 1
0
        public static void CheckAsTaskMainExecutive(int taskid, int userid)
        {
            Task task = ctx.Tasks.First(t => t.Id == taskid);
            User user = ctx.Users.First(u => u.Id == userid);

            if (task.ExecutiveId == userid)
            {
                task.Executive   = null;
                task.ExecutiveId = null;
            }
            else
            {
                task.Executive   = user;
                task.ExecutiveId = user.Id;
            }

            Notification notification = new Notification();

            notification.Date    = DateTime.Now;
            notification.Type    = NotificationType.CheckedAsTaskExecutive;
            notification.User    = user;
            notification.UserId  = user.Id;
            notification.Link    = "/";
            notification.Message = "User " + task.User.Username + " checked you as main executive to the task";

            ctx.SaveChanges();
        }
Ejemplo n.º 2
0
        public static void CreateTask(User user, TaskModel model)
        {
            Task task = new Task();

            task.Header  = model.Header;
            task.Content = model.Content;
            task.Price   = model.Price;


            task.TaskSubcat = ctx.TaskSubcats.First(c => c.Id == model.Subcategory.Value);

            task.User   = user;
            task.UserId = user.Id;

            ctx.Tasks.Add(task);
            ctx.SaveChanges();

            int  t1Id = ctx.Tasks.Max(t => t.Id);
            Task t1   = ctx.Tasks.First(t => t.Id == t1Id);

            User currentUser = ctx.Users.First(u => u.Id == user.Id);

            currentUser.Tasks.Add(t1);

            ctx.SaveChanges();
        }
Ejemplo n.º 3
0
        public static void RemoveTaskExecutive(int taskid)
        {
            Task task = ctx.Tasks.First(t => t.Id == taskid);

            task.ExecutiveId = null;
            task.Executive   = null;
            ctx.SaveChanges();
        }
Ejemplo n.º 4
0
        public static void CheckTaskAsSolved(int taskid)
        {
            Task task = ctx.Tasks.First(t => t.Id == taskid);

            if (task.Solved == true)
            {
                task.Solved = false;
            }
            else
            {
                task.Solved = true;
            }
            ctx.SaveChanges();
        }
Ejemplo n.º 5
0
        public static void CheckTaskAsHidden(int taskid)
        {
            Task task = ctx.Tasks.First(t => t.Id == taskid);

            if (task.Hide == null)
            {
                task.Hide = true;
            }
            else
            {
                if (task.Hide == true)
                {
                    task.Hide = false;
                }
                else
                {
                    task.Hide = true;
                }
            }

            ctx.SaveChanges();
        }
Ejemplo n.º 6
0
        public static void SubscriberTask(User sender, int taskid, int?taskprice)
        {
            Task task = ctx.Tasks.First(t => t.Id == taskid);

            if (task.TaskSubscribers == null)
            {
                task.TaskSubscribers = new List <TaskSubscriber>();
            }
            task.TaskSubscribers.Add(new TaskSubscriber()
            {
                User = sender, Price = taskprice
            });

            Notification notification = new Notification();

            notification.Date    = DateTime.Now;
            notification.Type    = NotificationType.TaskSubscribed;
            notification.User    = task.User;
            notification.UserId  = task.User.Id;
            notification.Link    = "/";
            notification.Message = "User " + sender.Username + " subscribed to your task";

            ctx.SaveChanges();
        }