예제 #1
0
        public static aspnet_Membership GetMembershipUserByUsername(string username)
        {
            TimeTrackerEntities entity = new TimeTrackerEntities();
            Guid id = entity.Users.First(el => el.Username == username).UserID;

            return(entity.aspnet_Membership.First(el => el.UserId == id));
        }
예제 #2
0
        public static void CreateTask(string TaskName, string Description, DateTime start, DateTime end, int estimation, string status, string[] userIds)
        {
            TimeTrackerEntities entity = new TimeTrackerEntities();
            Guid taskId = Guid.NewGuid();

            entity.AddToTasks(new Tasks()
            {
                TaskId      = taskId,
                TaskName    = TaskName,
                Description = Description,
                StartTime   = start,
                EndTime     = end,
                Estimation  = estimation,
                Status      = status,
                IsActive    = true
            });
            entity.SaveChanges();


            foreach (var user in userIds)
            {
                entity.AddToUsersTasks(new UsersTasks()
                {
                    Id     = Guid.NewGuid(),
                    UserId = Guid.Parse(user),
                    TaskId = taskId
                });
                entity.SaveChanges();
            }
        }
예제 #3
0
        public static void CreateTask(string TaskName, string Description, DateTime start, DateTime end, int estimation, string status, string[] userIds)
        {
            TimeTrackerEntities entity = new TimeTrackerEntities();
            Guid taskId = Guid.NewGuid();
            entity.AddToTasks(new Tasks()
            {
                TaskId = taskId,
                TaskName = TaskName,
                Description = Description,
                StartTime = start,
                EndTime = end,
                Estimation = estimation,
                Status = status,
                IsActive = true
            });
            entity.SaveChanges();

            foreach (var user in userIds)
            {
                entity.AddToUsersTasks(new UsersTasks()
                {
                    Id = Guid.NewGuid(),
                    UserId = Guid.Parse(user),
                    TaskId = taskId
                });
                entity.SaveChanges();
            }
        }
예제 #4
0
        public static List <WorkCards> GetCardsByUser(string username)
        {
            TimeTrackerEntities entity = new TimeTrackerEntities();
            Guid userId = entity.Users.First(el => el.Username == username).UserID;

            return(entity.WorkCards.Where(el => el.UserId == userId).ToList());
        }
예제 #5
0
 /**
  * Delete task means change its status IsActive to false
  */
 public static void DeleteTask(Guid id)
 {
     TimeTrackerEntities entity = new TimeTrackerEntities();
     Tasks task = entity.Tasks.First(el => el.TaskId == id);
     task.IsActive = false;
     entity.SaveChanges();
 }
예제 #6
0
        /**
         * Get the number of tasks assigned to a user
         */
        public static int GetUserNumberOfTasks(Guid userId)
        {
            //count userstasks by userid
            TimeTrackerEntities entity = new TimeTrackerEntities();

            return(entity.UsersTasks.Count(el => el.UserId == userId));
        }
예제 #7
0
 /**
  * Delete work card
  */
 public static void DeleteCard(Guid cardId)
 {
     TimeTrackerEntities entity = new TimeTrackerEntities();
     WorkCards card = entity.WorkCards.First(el => el.CardId == cardId);
     entity.WorkCards.DeleteObject(card);
     entity.SaveChanges();
 }
예제 #8
0
        public static JobItem GetJobItem(int jobItemId)
        {
            var ctx = new TimeTrackerEntities();

            var jobItem = ctx.DJobItems
                          .Include(x => x.DCustomer)
                          .Include(x => x.DRequestor)
                          .Include(x => x.DDeveloper)
                          .Where(x => x.DJobTimings.Any(y => DbFunctions.TruncateTime(y.StartTime.Value) == DbFunctions.TruncateTime(DateTime.Now)) || DbFunctions.TruncateTime(x.StartDate) == DbFunctions.TruncateTime(DateTime.Now));
            IQueryable <DJobItem> jobItemsToday = (from jobItems in jobItem select jobItems);

            var result = jobItemsToday.Select(x => new JobItem()
            {
                JobItemId     = x.JobItemId,
                JobTimings    = x.DJobTimings.Select(y => new JobTiming()).ToList(),
                Description   = x.Description,
                BillTo        = x.DRequestor.RequestorName,
                CustomerId    = (int)x.CustomerId,
                DeveloperCode = x.DDeveloper.DeveloperShortName,
                RequestedBy   = x.DRequestor.RequestorName
            }).FirstOrDefault(x => x.JobItemId == jobItemId);

            if (result == null)
            {
                logger.Warn("attempted to get non-existent job item. returning null");
            }

            return(result);
        }
예제 #9
0
 /**
  * Delete user means change his status IsActive to false
  */
 public static void DeleteUser(string username)
 {
     TimeTrackerEntities entity = new TimeTrackerEntities();
     Guid id = entity.aspnet_Users.First(el => el.UserName == username).UserId;
     Users user = entity.Users.First(el => el.UserID == id);
     user.IsActive = false;
     entity.SaveChanges();
 }
예제 #10
0
        /**
         * Delete task means change its status IsActive to false
         */
        public static void DeleteTask(Guid id)
        {
            TimeTrackerEntities entity = new TimeTrackerEntities();
            Tasks task = entity.Tasks.First(el => el.TaskId == id);

            task.IsActive = false;
            entity.SaveChanges();
        }
예제 #11
0
        /**
         * Delete work card
         */
        public static void DeleteCard(Guid cardId)
        {
            TimeTrackerEntities entity = new TimeTrackerEntities();
            WorkCards           card   = entity.WorkCards.First(el => el.CardId == cardId);

            entity.WorkCards.DeleteObject(card);
            entity.SaveChanges();
        }
예제 #12
0
        /**
         * Delete user means change his status IsActive to false
         */
        public static void DeleteUser(string username)
        {
            TimeTrackerEntities entity = new TimeTrackerEntities();
            Guid  id   = entity.aspnet_Users.First(el => el.UserName == username).UserId;
            Users user = entity.Users.First(el => el.UserID == id);

            user.IsActive = false;
            entity.SaveChanges();
        }
예제 #13
0
        public static List <Users> GetUsersByTaskId(Guid taskId)
        {
            TimeTrackerEntities entity = new TimeTrackerEntities();
            List <UsersTasks>   all    = entity.UsersTasks.Select(el => el).Where(el => el.TaskId == taskId).ToList();

            List <Guid> userIds = all.Select(el => el.UserId).ToList();

            return(entity.Users.Select(el => el).Where(id => userIds.Contains(id.UserID) && id.IsActive).ToList());
        }
예제 #14
0
 /**
  * Edit work card
  */
 public static void EditCard(Guid cardId, DateTime start, int duration, string comment)
 {
     TimeTrackerEntities entity = new TimeTrackerEntities();
     WorkCards card = entity.WorkCards.First(el => el.CardId == cardId);
     card.StartTime = start;
     card.Duration = duration;
     card.LogComment = comment;
     entity.SaveChanges();
 }
예제 #15
0
        /**
         * Edit work card
         */
        public static void EditCard(Guid cardId, DateTime start, int duration, string comment)
        {
            TimeTrackerEntities entity = new TimeTrackerEntities();
            WorkCards           card   = entity.WorkCards.First(el => el.CardId == cardId);

            card.StartTime  = start;
            card.Duration   = duration;
            card.LogComment = comment;
            entity.SaveChanges();
        }
예제 #16
0
        /**
         * Get tasks by given username
         */
        public static List <Tasks> GetTasksByUser(string username)
        {
            TimeTrackerEntities entity = new TimeTrackerEntities();
            Guid userId = entity.Users.First(el => el.Username == username).UserID;

            List <UsersTasks> tasks   = entity.UsersTasks.Select(el => el).Where(item => item.UserId == userId).ToList();
            List <Guid>       taskIds = tasks.Select(el => el.TaskId).ToList();

            return(entity.Tasks.Select(el => el).Where(id => taskIds.Contains(id.TaskId) && id.IsActive).ToList());
        }
예제 #17
0
 /**
  * Edit task information
  */
 public static void EditTask(Guid id, string TaskName, string Description, DateTime start, DateTime end, int estimation, string status)
 {
     TimeTrackerEntities entity = new TimeTrackerEntities();
     Tasks task = entity.Tasks.First(el => el.TaskId == id);
     task.TaskName = TaskName;
     task.Description = Description;
     task.StartTime = start;
     task.EndTime = end;
     task.Estimation = estimation;
     task.Status = status;
     entity.SaveChanges();
 }
예제 #18
0
        /**
         * Edit task information
         */
        public static void EditTask(Guid id, string TaskName, string Description, DateTime start, DateTime end, int estimation, string status)
        {
            TimeTrackerEntities entity = new TimeTrackerEntities();
            Tasks task = entity.Tasks.First(el => el.TaskId == id);

            task.TaskName    = TaskName;
            task.Description = Description;
            task.StartTime   = start;
            task.EndTime     = end;
            task.Estimation  = estimation;
            task.Status      = status;
            entity.SaveChanges();
        }
예제 #19
0
        public static int GetUserSpentTimeOnTask(Guid userId, Guid taskId)
        {
            //sum duration from workcards where taskid and userid ==
            TimeTrackerEntities entity = new TimeTrackerEntities();

            if (entity.WorkCards.Any(el => el.TaskId == taskId && el.UserId == userId) == false)
            {
                return(0);
            }
            else
            {
                return(entity.WorkCards.Where(el => el.TaskId == taskId && el.UserId == userId).Sum(el => el.Duration));
            }
        }
예제 #20
0
 /**
  * Create work card for a given task by the logged in user
  */
 public static void CreateCard(Guid taskId, Guid userId, DateTime start, int duration, string logComment)
 {
     TimeTrackerEntities entity = new TimeTrackerEntities();
     entity.AddToWorkCards(new WorkCards()
     {
         CardId = Guid.NewGuid(),
         UserId = userId,
         TaskId = taskId,
         StartTime = DateTime.Now,
         Duration = duration,
         LogComment = logComment
     });
     entity.SaveChanges();
 }
예제 #21
0
        /**
         * Get the number of logged hours for an user
         */
        public static int GetUserSpentTime(Guid userId)
        {
            //sum duration from workcards by userid
            TimeTrackerEntities entity = new TimeTrackerEntities();

            if (entity.WorkCards.Any(el => el.UserId == userId) == false)
            {
                return(0);
            }
            else
            {
                return(entity.WorkCards.Where(el => el.UserId == userId).Sum(el => el.Duration));
            }
        }
예제 #22
0
 public static void CreateUser(string Username, string FirstName, string LastName, string Position)
 {
     TimeTrackerEntities entity = new TimeTrackerEntities();
     aspnet_Users user = entity.aspnet_Users.First(el => el.UserName == Username);
     entity.AddToUsers(new Users()
     {
        Username = Username,
        UserID = user.UserId,
        FirstName = FirstName,
        LastName = LastName,
        Position = Position,
        IsActive = true
     });
     entity.SaveChanges();
 }
예제 #23
0
        /**
         * Create work card for a given task by the logged in user
         */
        public static void CreateCard(Guid taskId, Guid userId, DateTime start, int duration, string logComment)
        {
            TimeTrackerEntities entity = new TimeTrackerEntities();

            entity.AddToWorkCards(new WorkCards()
            {
                CardId     = Guid.NewGuid(),
                UserId     = userId,
                TaskId     = taskId,
                StartTime  = DateTime.Now,
                Duration   = duration,
                LogComment = logComment
            });
            entity.SaveChanges();
        }
예제 #24
0
        public static void CreateUser(string Username, string FirstName, string LastName, string Position)
        {
            TimeTrackerEntities entity = new TimeTrackerEntities();
            aspnet_Users        user   = entity.aspnet_Users.First(el => el.UserName == Username);

            entity.AddToUsers(new Users()
            {
                Username  = Username,
                UserID    = user.UserId,
                FirstName = FirstName,
                LastName  = LastName,
                Position  = Position,
                IsActive  = true
            });
            entity.SaveChanges();
        }
예제 #25
0
        public static DateTime StartTiming(int jobTimingId)
        {
            var startTime = DateTime.Now;

            var ctx    = new TimeTrackerEntities();
            var timing = ctx.DJobTimings.FirstOrDefault(x => x.JobTimingId == jobTimingId);

            if (timing != null)
            {
                timing.StartTime = startTime;
                timing.IsRunning = true;
                ctx.SaveChanges();
                return(startTime);
            }

            throw new Exception("Could not start Timing!");
        }
예제 #26
0
        public static JobTiming CreateNewJobTiming(int jobItemId, int developerId)
        {
            var ctx       = new TimeTrackerEntities();
            var newTiming = new DJobTiming
            {
                JobItemId   = jobItemId,
                DeveloperId = developerId,
            };

            ctx.DJobTimings.Add(newTiming);
            ctx.SaveChanges();

            JobTiming newJobTiming = new JobTiming()
            {
                DeveloperId = newTiming.DeveloperId,
                JobTimingId = newTiming.JobTimingId,
                JobItemId   = newTiming.JobItemId,
                IsRunning   = newTiming.IsRunning
            };

            return(newJobTiming);
        }
예제 #27
0
 /**
  * Edit user information, username cannot be edited
  */
 public static void EditUser(string username, string FirstName, string LastName, string email, string password)
 {
     TimeTrackerEntities entity = new TimeTrackerEntities();
     Users user = entity.Users.First(el => el.Username == username);
     aspnet_Membership membershipUser = entity.aspnet_Membership.First(el => el.UserId == user.UserID);
     if (FirstName != "")
     {
         user.FirstName = FirstName;
     }
     if (LastName != "")
     {
         user.LastName = LastName;
     }
     if (email != "")
     {
         membershipUser.Email = email;
     }
     if (password != "")
     {
         membershipUser.Password = password;
     }
     entity.SaveChanges();
 }
예제 #28
0
        public static List <JobItem> GetDailyItems()
        {
            //test comment.//testing github connection
            var ctx = new TimeTrackerEntities();

            var jobsWithTimingToday = ctx.DJobItems
                                      .Include(x => x.DCustomer)
                                      .Include(x => x.DRequestor)
                                      .Include(x => x.DDeveloper)
                                      .Where(x => x.DJobTimings.Any(y => DbFunctions.TruncateTime(y.StartTime.Value) == DbFunctions.TruncateTime(DateTime.Now)) || DbFunctions.TruncateTime(x.StartDate) == DbFunctions.TruncateTime(DateTime.Now));
            IQueryable <DJobItem> jobItemsToday = (from jobItems in jobsWithTimingToday select jobItems);

            var result = jobItemsToday.Select(x => new JobItem()
            {
                JobItemId  = x.JobItemId,
                JobTimings = x.DJobTimings.Select(y => new JobTiming()
                {
                    DeveloperId = y.DeveloperId,
                    EndTime     = y.EndTime,
                    IsRunning   = y.IsRunning,
                    JobItemId   = y.JobItemId,
                    JobTimingId = y.JobTimingId,
                    StartTime   = y.StartTime
                }).ToList(),
                Description   = x.Description,
                BillTo        = x.DRequestor.RequestorName,
                CustomerId    = (int)x.CustomerId,
                DeveloperCode = x.DDeveloper.DeveloperShortName,
                RequestedBy   = x.DRequestor.RequestorName,
                StartDate     = x.StartDate,
                EndDate       = x.EndDate
            }).ToList();

            result.ForEach(x => x.StartActiveTimer());

            return(result);
        }
예제 #29
0
        /**
         * Edit user information, username cannot be edited
         */
        public static void EditUser(string username, string FirstName, string LastName, string email, string password)
        {
            TimeTrackerEntities entity       = new TimeTrackerEntities();
            Users             user           = entity.Users.First(el => el.Username == username);
            aspnet_Membership membershipUser = entity.aspnet_Membership.First(el => el.UserId == user.UserID);

            if (FirstName != "")
            {
                user.FirstName = FirstName;
            }
            if (LastName != "")
            {
                user.LastName = LastName;
            }
            if (email != "")
            {
                membershipUser.Email = email;
            }
            if (password != "")
            {
                membershipUser.Password = password;
            }
            entity.SaveChanges();
        }
예제 #30
0
        public static int GetNumberOfUsersPerTask(Guid taskId)
        {
            TimeTrackerEntities entity = new TimeTrackerEntities();

            return(entity.UsersTasks.Count(el => el.TaskId == taskId));
        }
예제 #31
0
 public static int GetUserSpentTimeOnTask(Guid userId, Guid taskId)
 {
     //sum duration from workcards where taskid and userid ==
     TimeTrackerEntities entity = new TimeTrackerEntities();
     if (entity.WorkCards.Any(el => el.TaskId == taskId && el.UserId == userId) == false)
     {
         return 0;
     }
     else
     {
         return entity.WorkCards.Where(el => el.TaskId == taskId && el.UserId == userId).Sum(el => el.Duration);
     }
 }
예제 #32
0
        public static DDeveloper getDeveloperById(int devId)
        {
            var ctx = new TimeTrackerEntities();

            return(ctx.DDevelopers.FirstOrDefault(x => x.DeveloperId == devId));
        }
예제 #33
0
        /**
         * Get all the users from the database
         */
        public static List <Users> GetUsers()
        {
            TimeTrackerEntities entity = new TimeTrackerEntities();

            return(entity.Users.ToList());
        }
예제 #34
0
 /**
  * Get all the tasks, active and inactive
  */
 public static List<Tasks> GetTasks()
 {
     TimeTrackerEntities entity = new TimeTrackerEntities();
     return entity.Tasks.ToList();
 }
예제 #35
0
 public static List<WorkCards> GetCardsByUser(string username)
 {
     TimeTrackerEntities entity = new TimeTrackerEntities();
     Guid userId = entity.Users.First(el => el.Username == username).UserID;
     return entity.WorkCards.Where(el => el.UserId == userId).ToList();
 }
예제 #36
0
 /**
  * Get all the users from the database
  */
 public static List<Users> GetUsers()
 {
     TimeTrackerEntities entity = new TimeTrackerEntities();
     return entity.Users.ToList();
 }
예제 #37
0
        public static Users GetUserByUsername(string username)
        {
            TimeTrackerEntities entity = new TimeTrackerEntities();

            return(entity.Users.First(el => el.Username == username));
        }
예제 #38
0
 /**
  * Get all active users from the database
  */
 public static List<Users> GetAllUsers()
 {
     TimeTrackerEntities entity = new TimeTrackerEntities();
     return entity.Users.Where(el => el.IsActive).ToList();
 }
예제 #39
0
 public static aspnet_Membership GetMembershipUserByUsername(string username)
 {
     TimeTrackerEntities entity = new TimeTrackerEntities();
     Guid id = entity.Users.First(el => el.Username == username).UserID;
     return entity.aspnet_Membership.First(el => el.UserId == id);
 }
예제 #40
0
 public static Users GetUserByUsername(string username)
 {
     TimeTrackerEntities entity = new TimeTrackerEntities();
     return entity.Users.First(el => el.Username == username);
 }
예제 #41
0
        /**
         * Get tasks by given username
         */
        public static List<Tasks> GetTasksByUser(string username)
        {
            TimeTrackerEntities entity = new TimeTrackerEntities();
            Guid userId = entity.Users.First(el => el.Username == username).UserID;

            List<UsersTasks> tasks = entity.UsersTasks.Select(el => el).Where(item => item.UserId == userId).ToList();
            List<Guid> taskIds = tasks.Select(el => el.TaskId).ToList();
            return entity.Tasks.Select(el => el).Where(id => taskIds.Contains(id.TaskId) && id.IsActive).ToList();
        }
예제 #42
0
 /**
  * Get the number of logged hours for an user
  */
 public static int GetUserSpentTime(Guid userId)
 {
     //sum duration from workcards by userid
     TimeTrackerEntities entity = new TimeTrackerEntities();
     if (entity.WorkCards.Any(el => el.UserId == userId) == false)
     {
         return 0;
     }
     else
     {
         return entity.WorkCards.Where(el => el.UserId == userId).Sum(el => el.Duration);
     }
 }
예제 #43
0
 /**
  * Get the number of tasks assigned to a user
  */
 public static int GetUserNumberOfTasks(Guid userId)
 {
     //count userstasks by userid
     TimeTrackerEntities entity = new TimeTrackerEntities();
     return entity.UsersTasks.Count(el => el.UserId == userId);
 }
예제 #44
0
        public static List<Users> GetUsersByTaskId(Guid taskId)
        {
            TimeTrackerEntities entity = new TimeTrackerEntities();
            List<UsersTasks> all = entity.UsersTasks.Select(el => el).Where(el => el.TaskId == taskId).ToList();

            List<Guid> userIds = all.Select(el => el.UserId).ToList();
            return entity.Users.Select(el => el).Where(id => userIds.Contains(id.UserID) && id.IsActive).ToList();
        }
예제 #45
0
        public static Tasks GetTaskById(Guid id)
        {
            TimeTrackerEntities entity = new TimeTrackerEntities();

            return(entity.Tasks.First(el => el.TaskId == id));
        }
예제 #46
0
 public static WorkCards GetCardById(Guid cardId)
 {
     TimeTrackerEntities entity = new TimeTrackerEntities();
     return entity.WorkCards.First(el => el.CardId == cardId);
 }
예제 #47
0
        /**
         * Get all active users from the database
         */
        public static List <Users> GetAllUsers()
        {
            TimeTrackerEntities entity = new TimeTrackerEntities();

            return(entity.Users.Where(el => el.IsActive).ToList());
        }
예제 #48
0
 public static List<aspnet_Users> GetAllMembershipUsers()
 {
     TimeTrackerEntities entity = new TimeTrackerEntities();
     return entity.aspnet_Users.ToList();
 }
예제 #49
0
 public static Tasks GetTaskById(Guid id)
 {
     TimeTrackerEntities entity = new TimeTrackerEntities();
     return entity.Tasks.First(el => el.TaskId == id);
 }
예제 #50
0
        public static List <aspnet_Users> GetAllMembershipUsers()
        {
            TimeTrackerEntities entity = new TimeTrackerEntities();

            return(entity.aspnet_Users.ToList());
        }
예제 #51
0
        /**
         * Get all the tasks, active and inactive
         */
        public static List <Tasks> GetTasks()
        {
            TimeTrackerEntities entity = new TimeTrackerEntities();

            return(entity.Tasks.ToList());
        }
예제 #52
0
        public static List <DCustomer> GetCustomers()
        {
            var ctx = new TimeTrackerEntities();

            return(ctx.DCustomers.OrderBy(x => x.CustomerName).ToList());
        }
예제 #53
0
 public static List<Tasks> GetAllTasks()
 {
     TimeTrackerEntities entity = new TimeTrackerEntities();
     return entity.Tasks.Where(el => el.IsActive).ToList();
 }
예제 #54
0
        public static List <DRequestor> GetRequestors()
        {
            var ctx = new TimeTrackerEntities();

            return(ctx.DRequestors.OrderBy(x => x.RequestorName).ToList());
        }
예제 #55
0
 public static int GetNumberOfUsersPerTask(Guid taskId)
 {
     TimeTrackerEntities entity = new TimeTrackerEntities();
     return entity.UsersTasks.Count(el => el.TaskId == taskId);
 }