Esempio n. 1
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);
                }
            }
        }