Ejemplo n.º 1
0
        public ProjectListViewModel FromProject(Project project)
        {
            var context    = new LmPlatformModelsContext();
            var isAssigned = false;

            foreach (var user in context.ProjectUsers)
            {
                if (user.ProjectId == project.Id && user.UserId == WebSecurity.CurrentUserId)
                {
                    isAssigned = true;
                }
            }

            var _context  = new ProjectManagementService();
            var creatorId = project.Creator.Id;

            return(new ProjectListViewModel
            {
                Id = project.Id,
                Title =
                    string.Format("<a href=\"{0}\">{1}</a>", Url.Action("ProjectManagement", "BTS", new { id = project.Id }), project.Title),
                CreatorName = _context.GetCreatorName(creatorId),
                CreationDate = project.DateOfChange.ToShortDateString(),
                UserQuentity = _context.GetProjectUsers(project.Id).Count,
                IsAssigned = isAssigned
            });
        }
Ejemplo n.º 2
0
        public static string GetRoleName(int id)
        {
            var context = new LmPlatformModelsContext();
            var role    = context.ProjectRoles.Find(id);

            return(role.Name);
        }
Ejemplo n.º 3
0
        private void GetBugPropertyList()
        {
            var context = new LmPlatformModelsContext();

            _statuses   = context.BugStatuses.ToList();
            _severities = context.BugSeverities.ToList();
        }
Ejemplo n.º 4
0
        public static string GetProjectCreatorName(int projectId)
        {
            var context  = new LmPlatformModelsContext();
            var _context = new ProjectManagementService();
            var project  = context.Projects.Find(projectId);
            var creator  = context.Users.Find(project.CreatorId);

            return(_context.GetCreatorName(creator.Id));
        }
Ejemplo n.º 5
0
        public IList <SelectListItem> GetSymptomNames()
        {
            var symptoms = new LmPlatformModelsContext().BugSymptoms.ToList();

            return(symptoms.Select(e => new SelectListItem
            {
                Text = e.Name,
                Value = e.Id.ToString(CultureInfo.InvariantCulture)
            }).ToList());
        }
Ejemplo n.º 6
0
        public IList <SelectListItem> GetRoles()
        {
            var roles = new LmPlatformModelsContext().ProjectRoles.ToList();

            return(roles.Select(e => new SelectListItem
            {
                Text = e.Name,
                Value = e.Id.ToString(CultureInfo.InvariantCulture)
            }).ToList());
        }
Ejemplo n.º 7
0
        public string GetTasksSheetHtml(int diplomProjectId)
        {
            //todo
            var diplomProject =
                new LmPlatformModelsContext().DiplomProjects
                .Include(x => x.AssignedDiplomProjects.Select(y => y.Student.Group.Secretary.DiplomPercentagesGraphs))
                .Single(x => x.DiplomProjectId == diplomProjectId);

            return(diplomProject.AssignedDiplomProjects.Count == 1 ?
                   Word.DiplomProjectToDocView(diplomProject.AssignedDiplomProjects.First()) :
                   Word.DiplomProjectToDocView(diplomProject));
        }
        private int GetSeverityIdByName(string name)
        {
            var context    = new LmPlatformModelsContext();
            var severities = context.BugSeverities.ToList();
            var id         = 0;

            foreach (var n in severities.Where(n => n.Name == name))
            {
                id = n.Id;
            }

            return(id);
        }
Ejemplo n.º 9
0
        public static void Main(string[] args)
        {
            using var dbContext = new LmPlatformModelsContext();

            var dbSets = dbContext.GetType().GetProperties().Where(prop => prop.PropertyType.Name.Contains("DbSet"));

            var totalSets = dbSets.Count();

            var currentSets = 0;

            var sets = dbSets
                       .Select(propertyInfo => propertyInfo.GetValue(dbContext));
        }
Ejemplo n.º 10
0
        private int GetStatusIdByName(string name)
        {
            var context  = new LmPlatformModelsContext();
            var statuses = context.BugStatuses.ToList();
            var id       = 0;

            foreach (var n in statuses)
            {
                if (n.Name == name)
                {
                    id = n.Id;
                }
            }

            return(id);
        }
Ejemplo n.º 11
0
        public void GetTasksSheetDocument(int courseProjectId)
        {
            var courseProject =
                new LmPlatformModelsContext().CourseProjects
                .Include(x => x.AssignedCourseProjects.Select(y => y.Student.Group.Secretary.CoursePercentagesGraphs))
                .Single(x => x.CourseProjectId == courseProjectId);

            string docName;

            if (courseProject.AssignedCourseProjects.Count == 1)
            {
                var stud = courseProject.AssignedCourseProjects.Single().Student;
                docName = string.Format("{0}_{1}", stud.LastName, stud.FirstName);
            }
            else
            {
                docName = string.Format("{0}", courseProject.Theme);
            }

            WordCourseProject.CourseProjectToWord(docName, courseProject, Response);
        }
Ejemplo n.º 12
0
        public UserInfoViewModel(int _id)
        {
            var context = new LmPlatformModelsContext();
            var id      = context.ProjectUsers.Find(_id).UserId;

            if (context.Students.Find(id) != null)
            {
                //var creator = context.Students.Find(id);
                var creator = new Student();
                foreach (var student in context.Students)
                {
                    if (student.Id == id)
                    {
                        creator = student;
                    }
                }

                UserName        = creator.LastName + " " + creator.FirstName + " " + creator.MiddleName;
                GroupNumber     = context.Groups.Find(creator.GroupId).Name;
                ProjectQuentity = context.ProjectUsers.Select(e => e.User).Count(e => e.Id == creator.Id);
                Role            = "Студент";
            }
            else
            {
                var creator = context.Lecturers.Find(id);
                UserName        = creator.LastName + " " + creator.FirstName + " " + creator.MiddleName;
                ProjectQuentity = context.ProjectUsers.Select(e => e.User).Count(e => e.Id == creator.Id);
                Role            = "Преподаватель";

                var _context = new SubjectManagementService();
                SubjectList = new List <Subject>();
                foreach (var subject in _context.GetUserSubjects(creator.Id))
                {
                    SubjectList.Add(subject);
                }
            }
        }
Ejemplo n.º 13
0
        public SimpleMembershipInitializer()
        {
            Database.SetInitializer <LmPlatformModelsContext>(null);

            try
            {
                bool firstLoad;

                using (var context = new LmPlatformModelsContext())
                {
                    firstLoad = DataBaseInitializer.InitializeDatabase(context);
                }

                WebSecurity.InitializeDatabaseConnection("DefaultConnection", "Users", "UserId", "UserName", autoCreateTables: false);

                if (firstLoad)
                {
                    WebSecurity.CreateUserAndAccount("admin", "123456");
                    Roles.AddUserToRole("admin", "admin");
                    WebSecurity.CreateUserAndAccount("popova", "123456");
                    Roles.AddUserToRole("popova", "lector");
                    WebSecurity.CreateUserAndAccount("hawk_1", "123456");
                    Roles.AddUserToRole("hawk_1", "student");
                    WebSecurity.CreateUserAndAccount("hawk_2", "123456");
                    Roles.AddUserToRole("hawk_2", "student");
                    WebSecurity.CreateUserAndAccount("hawk_3", "123456");
                    Roles.AddUserToRole("hawk_3", "student");
                    WebSecurity.CreateUserAndAccount("hawk_4", "123456");
                    Roles.AddUserToRole("hawk_4", "student");
                    WebSecurity.CreateUserAndAccount("hawk_5", "123456");
                    Roles.AddUserToRole("hawk_5", "student");
                    WebSecurity.CreateUserAndAccount("hawk_6", "123456");
                    Roles.AddUserToRole("hawk_6", "student");
                    WebSecurity.CreateUserAndAccount("hawk_7", "123456");
                    Roles.AddUserToRole("hawk_7", "student");
                    WebSecurity.CreateUserAndAccount("hawk_8", "123456");
                    Roles.AddUserToRole("hawk_8", "student");
                    WebSecurity.CreateUserAndAccount("hawk_9", "123456");
                    Roles.AddUserToRole("hawk_9", "student");
                    WebSecurity.CreateUserAndAccount("hawk_10", "123456");
                    Roles.AddUserToRole("hawk_10", "student");
                    using (var context = new LmPlatformModelsContext())
                    {
                        context.Lecturers.Add(new Lecturer
                        {
                            Id         = 2,
                            FirstName  = "Юлия",
                            MiddleName = "Борисовна",
                            LastName   = "Попова"
                        });

                        context.Students.Add(new Student
                        {
                            Id         = 3,
                            GroupId    = 2,
                            FirstName  = "Сергей",
                            MiddleName = "Викторович",
                            LastName   = "Яцынович"
                        });

                        context.Students.Add(new Student
                        {
                            Id         = 4,
                            GroupId    = 2,
                            FirstName  = "Киррил",
                            MiddleName = "Викторович",
                            LastName   = "Андреевич"
                        });

                        context.Students.Add(new Student
                        {
                            Id         = 5,
                            GroupId    = 2,
                            FirstName  = "Петр",
                            MiddleName = "Викторович",
                            LastName   = "Петров"
                        });

                        context.Students.Add(new Student
                        {
                            Id         = 6,
                            GroupId    = 2,
                            FirstName  = "Иван",
                            MiddleName = "Иванович",
                            LastName   = "Иванов"
                        });

                        context.Students.Add(new Student
                        {
                            Id         = 7,
                            GroupId    = 2,
                            FirstName  = "Виктор",
                            MiddleName = "Викторович",
                            LastName   = "Иванченко"
                        });

                        context.Students.Add(new Student
                        {
                            Id         = 8,
                            GroupId    = 2,
                            FirstName  = "Виктор",
                            MiddleName = "Васильевич",
                            LastName   = "Шеремет"
                        });

                        context.Students.Add(new Student
                        {
                            Id         = 9,
                            GroupId    = 2,
                            FirstName  = "Андрей",
                            MiddleName = "Петрович",
                            LastName   = "Беляк"
                        });

                        context.Students.Add(new Student
                        {
                            Id         = 10,
                            GroupId    = 2,
                            FirstName  = "Екатерина",
                            MiddleName = "Ивановна",
                            LastName   = "Крузернштейн"
                        });

                        context.Students.Add(new Student
                        {
                            Id         = 11,
                            GroupId    = 2,
                            FirstName  = "Анатолий",
                            MiddleName = "Васильевич",
                            LastName   = "Шибека"
                        });

                        context.Students.Add(new Student
                        {
                            Id         = 12,
                            GroupId    = 2,
                            FirstName  = "Николай",
                            MiddleName = "Николаевич",
                            LastName   = "Гурский"
                        });

                        context.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException("Ошибка", ex);
            }
        }
Ejemplo n.º 14
0
        public string GetStatusName(int id)
        {
            var status = new LmPlatformModelsContext().BugStatuses.Find(id);

            return(status.Name);
        }
Ejemplo n.º 15
0
        public IList <SelectListItem> GetStatusNames()
        {
            var allStatuses = new LmPlatformModelsContext().BugStatuses.ToList();
            var statuses    = new List <BugStatus>();

            var userRoleOnProject =
                new ProjectManagementService().GetProjectsOfUser(WebSecurity.CurrentUserId).Single(e => e.ProjectId == ProjectId).ProjectRoleId;

            switch (userRoleOnProject)
            {
            //Роль "Разработчик"
            case 1:
                switch (StatusId)
                {
                //Статус "Обнаружена"
                case 1:
                    statuses.Add(allStatuses[0]);
                    statuses.Add(allStatuses[1]);
                    statuses.Add(allStatuses[5]);
                    break;

                //Статус "Назначена"
                case 2:
                    statuses.Add(allStatuses[1]);
                    statuses.Add(allStatuses[2]);
                    statuses.Add(allStatuses[5]);
                    break;

                //Статус "Исправлена"
                case 3:
                    statuses.Add(allStatuses[2]);
                    break;

                //Статус "Проверена"
                case 4:
                    statuses.Add(allStatuses[3]);
                    statuses.Add(allStatuses[6]);
                    break;

                //Статус "Отложена"
                case 5:
                    statuses.Add(allStatuses[4]);
                    break;

                //Статус "Отклонена"
                case 6:
                    statuses.Add(allStatuses[5]);
                    statuses.Add(allStatuses[6]);
                    break;

                //Статус "Открыта заново"
                case 8:
                    if (AssignedDeveloperId == 0)
                    {
                        statuses.Add(allStatuses[1]);
                    }

                    statuses.Add(allStatuses[7]);
                    break;
                }

                break;

            //Роль "Тестировщик"
            case 2:
                switch (StatusId)
                {
                //Статус "Обнаружена"
                case 1:
                    statuses.Add(allStatuses[0]);
                    statuses.Add(allStatuses[1]);
                    statuses.Add(allStatuses[4]);
                    statuses.Add(allStatuses[5]);
                    break;

                //Статус "Назначена"
                case 2:
                    statuses.Add(allStatuses[1]);
                    break;

                //Статус "Исправлена"
                case 3:
                    statuses.Add(allStatuses[2]);
                    statuses.Add(allStatuses[3]);
                    statuses.Add(allStatuses[4]);
                    statuses.Add(allStatuses[7]);
                    break;

                //Статус "Проверена"
                case 4:
                    statuses.Add(allStatuses[3]);
                    break;

                //Статус "Отложена"
                case 5:
                    if (AssignedDeveloperId != 0)
                    {
                        statuses.Add(allStatuses[2]);
                    }

                    statuses.Add(allStatuses[4]);
                    statuses.Add(allStatuses[5]);
                    statuses.Add(allStatuses[7]);
                    break;

                //Статус "Отклонена"
                case 6:
                    statuses.Add(allStatuses[5]);
                    statuses.Add(allStatuses[7]);
                    break;

                //Статус "Открыта заново"
                case 8:
                    if (AssignedDeveloperId != 0)
                    {
                        statuses.Add(allStatuses[2]);
                    }

                    statuses.Add(allStatuses[4]);
                    statuses.Add(allStatuses[5]);
                    statuses.Add(allStatuses[7]);
                    break;
                }

                break;

            //Роль "Руководитель проекта"
            case 3:
                switch (StatusId)
                {
                //Статус "Обнаружена"
                case 1:
                    statuses.Add(allStatuses[0]);
                    statuses.Add(allStatuses[1]);
                    statuses.Add(allStatuses[4]);
                    statuses.Add(allStatuses[5]);
                    break;

                //Статус "Назначена"
                case 2:
                    statuses.Add(allStatuses[1]);
                    break;

                //Статус "Исправлена"
                case 3:
                    statuses.Add(allStatuses[2]);
                    statuses.Add(allStatuses[4]);
                    break;

                //Статус "Проверена"
                case 4:
                    statuses.Add(allStatuses[3]);
                    statuses.Add(allStatuses[6]);
                    break;

                //Статус "Отложена"
                case 5:
                    if (AssignedDeveloperId != 0)
                    {
                        statuses.Add(allStatuses[2]);
                    }

                    statuses.Add(allStatuses[4]);
                    statuses.Add(allStatuses[5]);
                    statuses.Add(allStatuses[7]);
                    break;

                //Статус "Отклонена"
                case 6:
                    statuses.Add(allStatuses[5]);
                    statuses.Add(allStatuses[6]);
                    statuses.Add(allStatuses[7]);
                    break;

                //Статус "Открыта заново"
                case 8:
                    statuses.Add(allStatuses[1]);
                    statuses.Add(allStatuses[4]);
                    statuses.Add(allStatuses[5]);
                    statuses.Add(allStatuses[7]);
                    break;
                }

                break;
            }

            return(statuses.Select(e => new SelectListItem
            {
                Text = e.Name,
                Value = e.Id.ToString(CultureInfo.InvariantCulture)
            }).ToList());
        }
Ejemplo n.º 16
0
        private void GetStatusList()
        {
            var context = new LmPlatformModelsContext();

            _statuses = context.BugStatuses.ToList();
        }
Ejemplo n.º 17
0
        public string GetSeverityName(int id)
        {
            var severity = new LmPlatformModelsContext().BugSeverities.Find(id);

            return(severity.Name);
        }
Ejemplo n.º 18
0
        public string GetSymptomName(int id)
        {
            var symptom = new LmPlatformModelsContext().BugSymptoms.Find(id);

            return(symptom.Name);
        }