Exemple #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));
        }
        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();
            }
        }
Exemple #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();
            }
        }
        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());
        }
Exemple #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();
 }
Exemple #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));
        }
Exemple #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();
 }
Exemple #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);
        }
Exemple #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();
 }
        /**
         * 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();
        }
        /**
         * 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();
        }
Exemple #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();
        }
Exemple #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());
        }
Exemple #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();
 }
        /**
         * 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();
        }
        /**
         * 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());
        }
Exemple #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();
 }
        /**
         * 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();
        }
Exemple #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));
            }
        }
Exemple #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();
 }
Exemple #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));
            }
        }
Exemple #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();
 }
        /**
         * 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();
        }
Exemple #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();
        }
Exemple #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!");
        }
Exemple #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);
        }
Exemple #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();
 }
Exemple #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);
        }
Exemple #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();
        }
        public static int GetNumberOfUsersPerTask(Guid taskId)
        {
            TimeTrackerEntities entity = new TimeTrackerEntities();

            return(entity.UsersTasks.Count(el => el.TaskId == taskId));
        }
Exemple #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);
     }
 }
Exemple #32
0
        public static DDeveloper getDeveloperById(int devId)
        {
            var ctx = new TimeTrackerEntities();

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

            return(entity.Users.ToList());
        }
Exemple #34
0
 /**
  * Get all the tasks, active and inactive
  */
 public static List<Tasks> GetTasks()
 {
     TimeTrackerEntities entity = new TimeTrackerEntities();
     return entity.Tasks.ToList();
 }
Exemple #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();
 }
Exemple #36
0
 /**
  * Get all the users from the database
  */
 public static List<Users> GetUsers()
 {
     TimeTrackerEntities entity = new TimeTrackerEntities();
     return entity.Users.ToList();
 }
Exemple #37
0
        public static Users GetUserByUsername(string username)
        {
            TimeTrackerEntities entity = new TimeTrackerEntities();

            return(entity.Users.First(el => el.Username == username));
        }
Exemple #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();
 }
Exemple #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);
 }
Exemple #40
0
 public static Users GetUserByUsername(string username)
 {
     TimeTrackerEntities entity = new TimeTrackerEntities();
     return entity.Users.First(el => el.Username == username);
 }
Exemple #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();
        }
Exemple #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);
     }
 }
Exemple #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);
 }
Exemple #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();
        }
        public static Tasks GetTaskById(Guid id)
        {
            TimeTrackerEntities entity = new TimeTrackerEntities();

            return(entity.Tasks.First(el => el.TaskId == id));
        }
Exemple #46
0
 public static WorkCards GetCardById(Guid cardId)
 {
     TimeTrackerEntities entity = new TimeTrackerEntities();
     return entity.WorkCards.First(el => el.CardId == cardId);
 }
Exemple #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());
        }
Exemple #48
0
 public static List<aspnet_Users> GetAllMembershipUsers()
 {
     TimeTrackerEntities entity = new TimeTrackerEntities();
     return entity.aspnet_Users.ToList();
 }
Exemple #49
0
 public static Tasks GetTaskById(Guid id)
 {
     TimeTrackerEntities entity = new TimeTrackerEntities();
     return entity.Tasks.First(el => el.TaskId == id);
 }
Exemple #50
0
        public static List <aspnet_Users> GetAllMembershipUsers()
        {
            TimeTrackerEntities entity = new TimeTrackerEntities();

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

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

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

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