コード例 #1
0
        public RefUserProViewModel() : base()
        {
            ShlekenEntities3 db = new ShlekenEntities3();

            ProjectId = ProjecrId;
            Tasks     = db.TasksRoles.Where(t => t.RoleId == RoleId).ToList();
        }
コード例 #2
0
ファイル: MeetingService.cs プロジェクト: rmfogel/shleken
 public static List <MeetingsViewModel> GetAll(int ProjectId, MeetingsearchViewModel search)
 {
     if (search.ToDate != null)
     {
         search.ToDate = search.ToDate.Value.AddDays(1);
     }
     if (search.FromDate != null)
     {
         search.FromDate = search.FromDate.Value.AddDays(-1);
     }
     using (var db = new ShlekenEntities3())
     {
         return(db.Meetings
                .Where(i => i.Projects.AccountId == Userservice.AccountId && i.ProjectId == ProjectId &&
                       (string.IsNullOrEmpty(search.Subject) == true || i.Subject.ToLower().Contains(search.Subject.ToLower())) &&
                       (string.IsNullOrEmpty(search.Location) == true || i.Location.ToLower().Contains(search.Location.ToLower())) &&
                       (search.ToDate == null || i.Date < search.ToDate) &&
                       (search.FromDate == null || i.Date > search.FromDate)
                       )
                .ToList()
                .Select(i =>
         {
             var item = i.Map <Meetings, MeetingsViewModel>();
             return item;
         })
                .ToList());
     }
 }
コード例 #3
0
ファイル: OutcomeService.cs プロジェクト: rmfogel/shleken
        public static List <OutcomesViewModel> Get(BudgetSearchViewModel search)
        {
            if (search.ToDate != null)
            {
                search.ToDate = search.ToDate.Value.AddDays(1);
            }
            if (search.FromDate != null)
            {
                search.FromDate = search.FromDate.Value.AddDays(-1);
            }

            using (var db = new ShlekenEntities3())
            {
                return(db.Outcomes
                       .Where(i => i.Projects.AccountId == Userservice.AccountId &&
                              (search.ProjectId == 0 || i.ProjectId == search.ProjectId) &&
                              (search.ToDate == null || i.Date < search.ToDate) &&
                              (search.FromDate == null || i.Date > search.FromDate)
                              )
                       .ToList()
                       .Select(i =>
                {
                    var item = i.Map <Outcomes, OutcomesViewModel>();
                    item.ApproverName = i.Users.Name;
                    return item;
                })
                       .ToList());
            }
        }
コード例 #4
0
ファイル: TeamService.cs プロジェクト: rmfogel/shleken
        public static List <TeamsViewModel> GetAllMore180(int ProjectId)
        {
            using (var db = new ShlekenEntities3())
            {
                var datesProjects = DatesProjects(ProjectId);
                var Teams         = db.Teams
                                    .Where(i => i.Projects.AccountId == Userservice.AccountId)
                                    .ToList()
                                    .GroupBy(i => new { i.Users })
                                    .ToList();
                var listTeams = new List <TeamsViewModel>();
                foreach (var team in Teams)
                {
                    var item = new TeamsViewModel();
                    item.Name       = team.Key.Users.Name;
                    item.UserId     = team.Key.Users.Id;
                    item.UsersHours = new List <HourDate>();
                    var TeamsDate = team.GroupBy(i => i.Date);
                    foreach (var td in TeamsDate)
                    {
                        var sum = 0;
                        foreach (var t in td)
                        {
                            sum += t.Hours;
                        }
                        var UsersHours = new HourDate {
                            Date = td.Key.Date, Hour = sum, Usersname = item.Name
                        };
                        item.UsersHours.Add(UsersHours);
                    }

                    item.AllHours = new List <HourDate>();
                    foreach (var date in datesProjects)
                    {
                        var count = 1;
                        foreach (var hour in item.UsersHours)
                        {
                            if (hour.Date.Month == date.Date.Month && hour.Date.Year == date.Date.Year)
                            {
                                item.AllHours.Add(new HourDate {
                                    Hour = hour.Hour, Date = hour.Date, Id = hour.Id, Usersname = hour.Usersname
                                });
                            }
                            else
                            {
                                if (count == item.UsersHours.Count)
                                {
                                    item.AllHours.Add(new HourDate {
                                        Hour = 0, Date = date.Date, Id = 0, Usersname = hour.Usersname
                                    });
                                }
                                count++;
                            }
                        }
                    }
                    listTeams.Add(item);
                }
                return(listTeams);
            }
        }
コード例 #5
0
        public static void Delete(int id)
        {
            using (var db = new ShlekenEntities3())
            {
                var user = db.RefUserPro.Where(u => u.Id == id).FirstOrDefault();
                var item = db.Roles.Single(i => i.Id == user.RoleId);
                var list = db.Teams.ToList();
                foreach (var i in list)
                {
                    if (i.ProjectId == item.ProjectId && i.RoleId == item.Id)
                    {
                        db.Teams.Remove(i);
                        db.SaveChanges();
                    }
                }

                var TasksRoles = db.TasksRoles.ToList();
                foreach (var t in TasksRoles)
                {
                    if (t.Roles.ProjectId == item.ProjectId && t.RoleId == item.Id)
                    {
                        db.TasksRoles.Remove(t);
                        db.SaveChanges();
                    }
                }
                db.Roles.Remove(item);
                db.RefUserPro.Remove(user);
                db.SaveChanges();
            }
        }
コード例 #6
0
 public static List <RefUserProViewModel> Get(int projectId, UsersSearchViewModel search)
 {
     using (var db = new ShlekenEntities3())
     {
         var users = db.Projects.ToList().FirstOrDefault(i => i.Id == projectId).RefUserPro.ToList();
         if (!string.IsNullOrEmpty(search.Name))
         {
             users = users.Where(n => n.Users.Name.Contains(search.Name)).ToList();
         }
         if (!string.IsNullOrEmpty(search.Role))
         {
             users = users.Where(r => r.ProjecrId == projectId && r.Roles.Name == search.Role).ToList();
         }
         var u = users.ToList().Map <RefUserPro, RefUserProViewModel>();
         for (int i = 0; i < users.Count; i++)
         {
             u[i].ProjectId   = users[i].ProjecrId;
             u[i].ProjectName = users[i].Projects.Name;
             u[i].Email       = users[i].Users.Email;
             u[i].Name        = users[i].Users.Name;
             u[i].IsOwner     = db.Projects.ToList().FirstOrDefault(j => j.Id == projectId).RefUserPro.Min(o => o.Id) == users[i].Users.Id;
             u[i].Password    = users[i].Users.Password;
             u[i].Task        = db.TasksRoles.ToList().FirstOrDefault(g => g.RoleId == users[i].RoleId);
         }
         return(u);
     }
 }
コード例 #7
0
 public static void Save(List <GlobalsViewModel> models)
 {
     using (var db = new ShlekenEntities3())
     {
         if (models != null)
         {
             foreach (var model in models)
             {
                 if (model.Id > 0)
                 {
                     var item = db.Globals.Single(i => i.Projects.AccountId == Userservice.AccountId && i.Id == model.Id);
                     item = model.Map <GlobalsViewModel, Globals>(item);
                     db.SaveChanges();
                 }
                 else
                 {
                     if (model.Name != null)
                     {
                         var item = model.Map <GlobalsViewModel, Globals>();
                         db.Globals.Add(item);
                         db.SaveChanges();
                     }
                 }
             }
         }
     }
 }
コード例 #8
0
 public static void Save(List <TasksViewModel> models)
 {
     using (var db = new ShlekenEntities3())
     {
         foreach (var model in models)
         {
             if (model.Id > 0)
             {
                 var tr = model.TasksRoles;
                 model.TasksRoles = null;
                 var item = db.Tasks.SingleOrDefault(i => i.Projects.AccountId == Userservice.AccountId && i.Id == model.Id);
                 item = model.Map <TasksViewModel, Entities.Tasks>(item);
                 db.SaveChanges();
                 if (tr != null)
                 {
                     SaveRolestaks(tr, item.Id);
                 }
             }
             else
             {
                 if (model.Name != null)
                 {
                     var item = model.Map <TasksViewModel, Entities.Tasks>();
                     db.Tasks.Add(item);
                     db.SaveChanges();
                     var TasksAfterSave = db.Tasks.ToList().Last();
                     if (model.TasksRoles != null)
                     {
                         SaveRolestaks(model.TasksRoles, TasksAfterSave.Id);
                     }
                 }
             }
         }
     }
 }
コード例 #9
0
 public static List <RisksViewModel> Get(int ProjectId, RisksearchViewModel search)
 {
     using (var db = new ShlekenEntities3())
     {
         return(db.Risks
                .Where(i => i.Projects.AccountId == Userservice.AccountId && i.ProjectId == ProjectId &&
                       (string.IsNullOrEmpty(search.Name) == true || i.Name.ToLower().Contains(search.Name.ToLower())) &&
                       (search.Status == 0 || i.Status == search.Status) &&
                       (search.Priority == 0 || i.Priority == search.Priority) &&
                       (search.Probabilty == 0 || i.Probabilty == search.Probabilty) &&
                       (search.UserId == 0 || i.UserId == search.UserId)
                       )
                .ToList()
                .Select(i =>
         {
             var item = i.Map <Risks, RisksViewModel>();
             item.ProbabiltyName = i.RiskProbabilities.Name;
             item.PriorityName = i.RiskPriorities.Name;
             item.StatusName = i.RiskStatuses.Name;
             item.UsersName = i.Users.Name;
             return item;
         })
                .ToList().OrderBy(i => i.Date).ToList());
     }
 }
コード例 #10
0
 public static void SaveRolestaks(ICollection <TasksRoles> TasksRoles, int TaskId)
 {
     using (var db = new ShlekenEntities3())
     {
         foreach (var model in TasksRoles)
         {
             model.TaskId = TaskId;
             var item = db.TasksRoles.SingleOrDefault(i => i.RoleId == model.RoleId && i.TaskId == TaskId);
             if (item != null)
             {
                 item.TaskId = model.TaskId;
                 item.RoleId = model.RoleId;
                 item.Value  = model.Value;
                 db.SaveChanges();
             }
             else
             {
                 TasksRoles newItem = new TasksRoles
                 {
                     TaskId = model.TaskId,
                     RoleId = model.RoleId,
                     Value  = model.Value
                 };
                 db.TasksRoles.Add(newItem);
                 db.SaveChanges();
             }
         }
     }
 }
コード例 #11
0
 public static List <ToDoListsViewModel> GetAll(int ProjectId, ToDoListsearchViewModel search)
 {
     if (search.ToDate != null)
     {
         search.ToDate = search.ToDate.Value.AddDays(1);
     }
     if (search.FromDate != null)
     {
         search.FromDate = search.FromDate.Value.AddDays(-1);
     }
     using (var db = new ShlekenEntities3())
     {
         return(db.ToDoLists
                .Where(i => i.Projects.AccountId == Userservice.AccountId && i.ProjectId == ProjectId &&
                       (search.ToDate == null || i.Date < search.ToDate) &&
                       (search.FromDate == null || i.Date > search.FromDate) &&
                       (search.IsDone == 0 || i.IsDone == search.IsDone) &&
                       (string.IsNullOrEmpty(search.Description) == true || i.Description.ToLower().Contains(search.Description.ToLower()))
                       )
                .ToList()
                .Select(i =>
         {
             var item = i.Map <ToDoLists, ToDoListsViewModel>();
             item.Status = i.ToDoListStatuses.Name;
             return item;
         })
                .ToList());
     }
 }
コード例 #12
0
 public static List <ProjectsViewModel> Get(ProjectsSearchViewModel search, int userId)
 {
     using (var db = new ShlekenEntities3())
     {
         return(db.Projects.ToList().Where(p => p.RefUserPro.Any(r => r.UserId == userId))
                .Where(i => i.AccountId == Userservice.AccountId &&
                       (string.IsNullOrEmpty(search.Name) == true || i.Name.ToLower().Contains(search.Name.ToLower())) &&
                       //(search.OwnerId == 0 || i.OwnerId == search.OwnerId) &&
                       (search.Status == 0 || i.Status == search.Status))
                .ToList()
                .Select(i =>
         {
             var item = i.Map <Projects, ProjectsViewModel>();
             if (i.RefUserPro.Where(o => o.IsOwner == true).FirstOrDefault() == null && i.RefUserPro.ToList().FirstOrDefault() != null)
             {
                 i.RefUserPro.ToList().FirstOrDefault().IsOwner = true;
             }
             if (i.RefUserPro.Where(o => o.IsOwner == true).FirstOrDefault() != null)
             {
                 item.OwnerName = i.RefUserPro.Where(o => o.IsOwner == true).FirstOrDefault().Users.Name;
             }
             item.StatusName = i.ProjectStatuses.Name;
             return item;
         })
                .ToList());
     }
 }
コード例 #13
0
 public static List <ProjectStatusesViewModel> Get()
 {
     using (var db = new ShlekenEntities3())
     {
         return(db.ProjectStatuses
                .Map <ProjectStatuses, ProjectStatusesViewModel>());
     }
 }
コード例 #14
0
 public static List <RiskPrioritiesViewModel> Get()
 {
     using (var db = new ShlekenEntities3())
     {
         return(db.RiskPriorities
                .Map <RiskPriorities, RiskPrioritiesViewModel>());
     }
 }
コード例 #15
0
 public static List <ToDoListStatusesViewModel> Get()
 {
     using (var db = new ShlekenEntities3())
     {
         return(db.ToDoListStatuses
                .Map <ToDoListStatuses, ToDoListStatusesViewModel>());
     }
 }
コード例 #16
0
        public static List <MeetingsViewModel> GetMeetingsForUser(int id)
        {
            var db = new ShlekenEntities3();
            var lm = new List <MeetingsViewModel>();

            lm = db.Projects.Where(p => p.RefUserPro.Any(i => i.UserId == id)).ToList().SelectMany(pr => pr.Meetings.Map <Meetings, MeetingsViewModel>()).ToList();
            return(lm);
        }
コード例 #17
0
        public static List <ProjectsViewModel> GetProjectsForUsers(int id)
        {
            var t = new ShlekenEntities3().Projects.Where(p => p.RefUserPro.Any(i => i.UserId == id)).ToList().Map <Projects, ProjectsViewModel>();
            var s = new ShlekenEntities3().RefUserPro.ToList();

            //var s =  new ShlekenEntities3().Users.Where(i => i.Id == id).FirstOrDefault().RefUserPro.ToList().Select(p => p.Projects).Map<Projects, ProjectsViewModel>();
            return(new ShlekenEntities3().Projects.Where(p => p.RefUserPro.Any(i => i.UserId == id)).ToList().Map <Projects, ProjectsViewModel>());
        }
コード例 #18
0
ファイル: OutcomeService.cs プロジェクト: rmfogel/shleken
 public static void Delete(int id)
 {
     using (var db = new ShlekenEntities3())
     {
         var item = db.Outcomes.Single(i => i.Projects.AccountId == Userservice.AccountId && i.Id == id);
         db.Outcomes.Remove(item);
         db.SaveChanges();
     }
 }
コード例 #19
0
 public static void Delete(int id)
 {
     using (var db = new ShlekenEntities3())
     {
         var item = db.Users.Single(i => i.Id == id);
         db.Users.Remove(item);
         db.SaveChanges();
     }
 }
コード例 #20
0
 public static List <RolesResourcesViewModel> Get(int ProjectId)
 {
     using (var db = new ShlekenEntities3())
     {
         return(db.Roles
                .Where(i => i.Projects.AccountId == Userservice.AccountId && i.ProjectId == ProjectId)
                .Map <Roles, RolesResourcesViewModel>());
     }
 }
コード例 #21
0
 public static List <UsersViewModel> Get(int projectId)
 {
     using (var db = new ShlekenEntities3())
     {
         var t = db.Projects.ToList().FirstOrDefault(i => i.Id == projectId).RefUserPro.Select(i => i.Users).ToList();
         var s = t.Map <Users, UsersViewModel>();
         return(t.Map <Users, UsersViewModel>());
     }
 }
コード例 #22
0
 public static int countRoles(int ProjectId)
 {
     using (var db = new ShlekenEntities3())
     {
         return(db.Roles
                .Where(i => i.Projects.AccountId == Userservice.AccountId && i.ProjectId == ProjectId)
                .Count());
     }
 }
コード例 #23
0
 public static object Single(int id)
 {
     using (var db = new ShlekenEntities3())
     {
         return(db.Users.
                Single(i => i.Id == id)
                .Map <Users, UsersViewModel>());
     }
 }
コード例 #24
0
 public static object Single(int id)
 {
     using (var db = new ShlekenEntities3())
     {
         return(db.Activities
                .Single(i => i.Projects.AccountId == Userservice.AccountId && i.Id == id)
                .Map <Activities, ActivitiesViewModel>());
     }
 }
コード例 #25
0
        public static List <UsersViewModel> Get()
        {
            using (var db = new ShlekenEntities3())
            {
                return(db.Users

                       .Map <Users, UsersViewModel>());
            }
        }
コード例 #26
0
 public static List <GlobalsViewModel> Get(int ProjectId)
 {
     using (var db = new ShlekenEntities3())
     {
         return(db.Globals
                .Where(i => i.Projects.AccountId == Userservice.AccountId && i.ProjectId == ProjectId)
                .Map <Globals, GlobalsViewModel>());
     }
 }
コード例 #27
0
 public static ProjectsViewModel Single(int id)
 {
     using (var db = new ShlekenEntities3())
     {
         return(db.Projects
                .Single(i => i.AccountId == Userservice.AccountId && i.Id == id)
                .Map <Projects, ProjectsViewModel>());
     }
 }
コード例 #28
0
 public static List <ProjectsViewModel> Get()
 {
     using (var db = new ShlekenEntities3())
     {
         return(db.Projects
                .Where(i => i.AccountId == Userservice.AccountId && i.Status == 1)
                .Map <Projects, ProjectsViewModel>());
     }
 }
コード例 #29
0
 public static ProjectsViewModel Get(int Projects)
 {
     using (var db = new ShlekenEntities3())
     {
         var getProjects = db.Projects
                           .SingleOrDefault(i => i.AccountId == Userservice.AccountId && i.Id == Projects);
         var item = getProjects.Map <Projects, ProjectsViewModel>();
         return(item);
     }
 }
コード例 #30
0
 public static void SaveTeamsHoursCost(int TeamsHours, int TeamsCost, int ProjectId)
 {
     using (var db = new ShlekenEntities3())
     {
         var item = db.Projects.Single(i => i.AccountId == Userservice.AccountId && i.Id == ProjectId);
         item.TeamTotalCost  = TeamsCost;
         item.TeamTotalHours = TeamsHours;
         db.SaveChanges();
     }
 }