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(); } }
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()); }
/** * 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(); }
/** * 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)); }
/** * 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(); }
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); }
/** * 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(); }
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()); }
/** * 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()); }
/** * 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(); }
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)); } }
/** * 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(); }
/** * 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)); } }
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(); }
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!"); }
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); }
/** * 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 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); }
public static int GetNumberOfUsersPerTask(Guid taskId) { TimeTrackerEntities entity = new TimeTrackerEntities(); return(entity.UsersTasks.Count(el => el.TaskId == taskId)); }
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); } }
public static DDeveloper getDeveloperById(int devId) { var ctx = new TimeTrackerEntities(); return(ctx.DDevelopers.FirstOrDefault(x => x.DeveloperId == devId)); }
/** * Get all the users from the database */ public static List <Users> GetUsers() { TimeTrackerEntities entity = new TimeTrackerEntities(); return(entity.Users.ToList()); }
/** * Get all the tasks, active and inactive */ public static List<Tasks> GetTasks() { TimeTrackerEntities entity = new TimeTrackerEntities(); return entity.Tasks.ToList(); }
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(); }
/** * Get all the users from the database */ public static List<Users> GetUsers() { TimeTrackerEntities entity = new TimeTrackerEntities(); return entity.Users.ToList(); }
public static Users GetUserByUsername(string username) { TimeTrackerEntities entity = new TimeTrackerEntities(); return(entity.Users.First(el => el.Username == username)); }
/** * Get all active users from the database */ public static List<Users> GetAllUsers() { TimeTrackerEntities entity = new TimeTrackerEntities(); return entity.Users.Where(el => el.IsActive).ToList(); }
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 Users GetUserByUsername(string username) { TimeTrackerEntities entity = new TimeTrackerEntities(); return entity.Users.First(el => el.Username == username); }
/** * 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(); }
/** * 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); } }
/** * 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); }
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)); }
public static WorkCards GetCardById(Guid cardId) { TimeTrackerEntities entity = new TimeTrackerEntities(); return entity.WorkCards.First(el => el.CardId == cardId); }
/** * Get all active users from the database */ public static List <Users> GetAllUsers() { TimeTrackerEntities entity = new TimeTrackerEntities(); return(entity.Users.Where(el => el.IsActive).ToList()); }
public static List<aspnet_Users> GetAllMembershipUsers() { TimeTrackerEntities entity = new TimeTrackerEntities(); return entity.aspnet_Users.ToList(); }
public static Tasks GetTaskById(Guid id) { TimeTrackerEntities entity = new TimeTrackerEntities(); return entity.Tasks.First(el => el.TaskId == id); }
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()); }
public static List <DCustomer> GetCustomers() { var ctx = new TimeTrackerEntities(); return(ctx.DCustomers.OrderBy(x => x.CustomerName).ToList()); }
public static List<Tasks> GetAllTasks() { TimeTrackerEntities entity = new TimeTrackerEntities(); return entity.Tasks.Where(el => el.IsActive).ToList(); }
public static List <DRequestor> GetRequestors() { var ctx = new TimeTrackerEntities(); return(ctx.DRequestors.OrderBy(x => x.RequestorName).ToList()); }
public static int GetNumberOfUsersPerTask(Guid taskId) { TimeTrackerEntities entity = new TimeTrackerEntities(); return entity.UsersTasks.Count(el => el.TaskId == taskId); }