Exemplo n.º 1
0
 public static void CreateTask(Task task)
 {
     using (TimeTrackerDbEntities context = new TimeTrackerDbEntities())
     {
         context.Tasks.Add(task);
         context.SaveChanges();
     }
 }
Exemplo n.º 2
0
 public static void DeleteUserById(int id)
 {
     using (TimeTrackerDbEntities context = new TimeTrackerDbEntities())
     {
         var user = GetUserById(id);
         context.Users.Attach(user);
         if (user != null)
         {
             user.IsDeleted = true;
             context.SaveChanges();
         }
     }
 }
Exemplo n.º 3
0
 public static void DeleteTaskById(int id)
 {
     using (TimeTrackerDbEntities context = new TimeTrackerDbEntities())
     {
         var taskResult = GetTaskById(id);
         context.Tasks.Attach(taskResult);
         if (taskResult != null)
         {
             taskResult.IsDeleted = true;
             context.SaveChanges();
         }
     }
 }
Exemplo n.º 4
0
 public static void CreateTask(string t, string d, int s, DateTime? sd = null, DateTime? ed = null)
 {
     using (TimeTrackerDbEntities context = new TimeTrackerDbEntities())
     {
         Task task = new Task();
         task.Title = t;
         task.Description = d;
         task.StatusId = s;
         task.StartDate = sd;
         task.EndDate = ed;
         context.Tasks.Add(task);
         context.SaveChanges();
     }
 }
Exemplo n.º 5
0
        public static void AddTaskToUser(int userId, int taskId, DateTime? startDate = null, int? workedHours = null, DateTime? endDate = null)
        {
            using (TimeTrackerDbEntities context = new TimeTrackerDbEntities())
            {
                UsersTask usrTask = new UsersTask();
                usrTask.UserID = userId;
                usrTask.TaskId = taskId;
                usrTask.StartDate = startDate;
                usrTask.WorkedHours = workedHours;
                usrTask.EndDate = endDate;

                context.UsersTasks.Add(usrTask);
                context.SaveChanges();
            }
        }
Exemplo n.º 6
0
        public static void AddCardToDb(int usrId, int taskId, DateTime? startDate, TimeSpan hoursMin, string description, bool isFilled)
        {
            using (TimeTrackerDbEntities context = new TimeTrackerDbEntities())
            {
                WorkingCard wCard = new WorkingCard();
                wCard.UserId = usrId;
                wCard.TaskId = taskId;
                wCard.StartDate = DateTime.Parse(startDate.Value.ToString());
                wCard.WorkingHours = hoursMin;
                wCard.Description = description;
                wCard.IsFilled = isFilled;

                context.WorkingCard.Add(wCard);
                context.SaveChanges();
            }
        }
Exemplo n.º 7
0
 public static void UpdateTask(int id, string t, string d, int si, DateTime? sd = null)
 {
     using (TimeTrackerDbEntities context = new TimeTrackerDbEntities())
     {
         var taskResult = GetTaskById(id);
         context.Tasks.Attach(taskResult);
         if (taskResult != null)
         {
             taskResult.Title = t;
             taskResult.Description = d;
             taskResult.StatusId = si;
             taskResult.StartDate = sd;
             context.SaveChanges();
         }
     }
 }
Exemplo n.º 8
0
        public static void UpdateUsersTaskDate(int taskId, DateTime date)
        {
            using (TimeTrackerDbEntities context = new TimeTrackerDbEntities())
            {
                List<UsersTask> tasksToUpdate = (from usrTask in context.UsersTasks
                                                 where usrTask.TaskId == taskId
                                                 select usrTask).ToList<UsersTask>();

                for (int i = 0; i < tasksToUpdate.Count(); i++)
                {
                    tasksToUpdate[i].StartDate = date;
                }

                context.SaveChanges();
            }
        }
Exemplo n.º 9
0
        public static void UpdateWoringCard(WorkingCard wCard)
        {
            using (TimeTrackerDbEntities context = new TimeTrackerDbEntities())
            {
                WorkingCard result = (from card in context.WorkingCard
                                      where card.Id == wCard.Id
                                      select card).FirstOrDefault<WorkingCard>();

                result.StartDate = wCard.StartDate;

                result.WorkingHours = wCard.WorkingHours;

                result.Description = wCard.Description;

                context.SaveChanges();
            }
        }
Exemplo n.º 10
0
 public static void UpdateUser(int id, string un, string fn, string ln, string p, string e)
 {
     using (TimeTrackerDbEntities context = new TimeTrackerDbEntities())
     {
         var user = GetUserById(id);
         context.Users.Attach(user);
         if (user != null)
         {
             user.UserName = un;
             user.FirstName = fn;
             user.LastName = ln;
             user.Position = p;
             user.Email = e;
             context.SaveChanges();
         }
     }
 }
Exemplo n.º 11
0
        public static void UpdateWorkingHoursOnTask(int tskId, int hours)
        {
            Task tsk = TaskUtility.GetTaskById(tskId);
            using (TimeTrackerDbEntities context = new TimeTrackerDbEntities())
            {
                context.Tasks.Attach(tsk);
                if (hours > 0)
                {
                    tsk.WorkedHoursCurrent += hours;
                }

                context.SaveChanges();
            }
        }
Exemplo n.º 12
0
        public static void UpdateUserWorkingHoursOnTask(int usrId, int tskId, double hours)
        {
            using (TimeTrackerDbEntities context = new TimeTrackerDbEntities())
            {
                UsersTask usrTask = new UsersTask();
                usrTask = (from usrTsk in context.UsersTasks
                           where usrTsk.TaskId == tskId && usrTsk.UserID == usrId
                           select usrTsk).FirstOrDefault<UsersTask>();
                context.UsersTasks.Attach(usrTask);
                if (!usrTask.WorkedHours.HasValue)
                {
                    usrTask.WorkedHours = 0;
                }
                if (hours > 0)
                {
                    usrTask.WorkedHours += hours;
                }

                context.SaveChanges();
            }
        }