Beispiel #1
0
        public ActionResult HomeUserPage(bool? isPartial, int? userId)
        {
            var id = userId.HasValue ? userId.Value : CurrentUserId;

            var user = _accountService.GetUser(id);
            if (user == null)
            {
                return View("Login");
            }
            else
            {

                UserCommonViewModel model;
                var userMeta = user.UserMeta.FirstOrDefault();

                var studentStudentMeta = user.Student_StudentMeta.FirstOrDefault();
                string numberTasks = user.UserTask.Aggregate("", (current, task) => current + (task.TaskId + ";"));

                if (studentStudentMeta != null)
                {
                    model = new UserCommonViewModel()
                    {
                        //IsNewUser = false,
                        StudentMeta = new StudentViewModel()
                        {
                            AdmissionDate = studentStudentMeta.AdmissionDate.Year,
                            FacultyId = studentStudentMeta.FacultyId,
                            FlowId = studentStudentMeta.FlowId,
                            GraduationDate = studentStudentMeta.GraduationDate.Year,
                            MarkBookNumber = studentStudentMeta.MarkBookNumber,
                            GroupId = studentStudentMeta.GroupId,
                            IsDismissed = studentStudentMeta.IsDismissed,
                            SpecialityId = studentStudentMeta.SpecialtyId,
                            StudentCardNumber = studentStudentMeta.StudentCardNumber,
                            IdSpecialtyMeta = studentStudentMeta.IdSpecialtyMeta

                        },

                        Login = user.Login,
                        //Password = user.Password,
                        FirstName = userMeta.FirstName,
                        LastName = userMeta.LastName,
                        MiddleName = userMeta.MiddleName,
                        IsBlocked = user.BlockDate != null,
                        Phone = userMeta.Contact.PhoneNumber,
                        AdditionalPhone = userMeta.Contact.AdditionalPhoneNumber,
                        Email = userMeta.Contact.Email,
                        Skype = userMeta.Contact.Skype,
                        Tasks = numberTasks

                    };

                    ViewBag.FacultyName =
                        GetItemsOfDictionary(DictionaryTypeEnum.Факультеты)
                            .Find(p => p.Id == studentStudentMeta.FacultyId)
                            .Name;
                    Spezialnost_SpezialnostMeta meta = _adminData.GetSpezMetaInfo(studentStudentMeta.IdSpecialtyMeta);
                    ViewBag.StartYear = meta.GodPostup;
                    ViewBag.FinishYear = (meta.GodPostup + meta.SrokObuch).ToString();
                }
                else
                {
                    var prepodPrepodMeta = user.Prepod_PrepodMeta.FirstOrDefault();

                    var prepodMeta = new PrepodViewModel() { };
                    if (prepodPrepodMeta != null)
                    {
                        prepodMeta = new PrepodViewModel()
                        {
                            DegreeId = prepodPrepodMeta.DegreeId
                        };
                    }

                    model = new UserCommonViewModel()
                    {
                        IsNewUser = false,
                        PrepodMeta = prepodMeta,
                        Login = user.Login,
                        //Password = user.Password,
                        FirstName = userMeta.FirstName,
                        LastName = userMeta.LastName,
                        MiddleName = userMeta.MiddleName,
                        IsBlocked = user.BlockDate != null,
                        Phone = userMeta.Contact.PhoneNumber,
                        AdditionalPhone = userMeta.Contact.AdditionalPhoneNumber,
                        Email = userMeta.Contact.Email,
                        Skype = userMeta.Contact.Skype,
                        Tasks = numberTasks
                    };

                }

                model.IsPartialView = (isPartial.HasValue && isPartial.Value);

                return View(model);
            }
        }
Beispiel #2
0
        public ActionResult Edit(int id)
        {
            CacheService.Remove("UserData" + id + "|");
            var user = GetUserById(id);
            UserCommonViewModel model;
            var userMeta = user.UserMeta.FirstOrDefault();

            var studentStudentMeta = user.Student_StudentMeta.FirstOrDefault();
            string numberTasks = user.UserTask.Aggregate("", (current, task) => current + (task.TaskId + ";"));

            if (studentStudentMeta != null)
            {
                model = new UserCommonViewModel()
                {
                    //IsNewUser = false,
                    StudentMeta = new StudentViewModel()
                    {
                        AdmissionDate = studentStudentMeta.AdmissionDate.Year,
                        FacultyId = studentStudentMeta.FacultyId,
                        FlowId = studentStudentMeta.FlowId,
                        GraduationDate = studentStudentMeta.GraduationDate.Year,
                        MarkBookNumber = studentStudentMeta.MarkBookNumber,
                        GroupId = studentStudentMeta.GroupId,
                        IsDismissed = studentStudentMeta.IsDismissed,
                        SpecialityId = studentStudentMeta.SpecialtyId,
                        StudentCardNumber = studentStudentMeta.StudentCardNumber,
                        IdSpecialtyMeta = studentStudentMeta.IdSpecialtyMeta
                    },
                    Login = user.Login,
                    //Password = user.Password,
                    FirstName = userMeta.FirstName,
                    LastName = userMeta.LastName,
                    MiddleName = userMeta.MiddleName,
                    IsBlocked = user.BlockDate != null,
                    Phone = userMeta.Contact.PhoneNumber,
                    AdditionalPhone = userMeta.Contact.AdditionalPhoneNumber,
                    Email = userMeta.Contact.Email,
                    Skype = userMeta.Contact.Skype,
                    Tasks = numberTasks

                };
            }
            else
            {
                var prepodMeta = new PrepodViewModel() { };
                var prepodPrepodMeta = user.Prepod_PrepodMeta.FirstOrDefault();

                if (prepodPrepodMeta != null)
                {
                    prepodMeta = new PrepodViewModel()
                    {
                        DegreeId = prepodPrepodMeta.DegreeId,
                        DepartmentsIds = prepodPrepodMeta.Prepod_PrepodiCafedri.Select(dep => dep.IdCafedri).ToList(),
                        DepartmentsIdsString = prepodPrepodMeta.Prepod_PrepodiCafedri.Aggregate("", (current, depID) => current + (depID.IdCafedri + ";"))
                    };
                }

                model = new UserCommonViewModel()
                {
                    IsNewUser = false,
                    PrepodMeta = prepodMeta,
                    Login = user.Login,
                    //Password = user.Password,
                    FirstName = userMeta.FirstName,
                    LastName = userMeta.LastName,
                    MiddleName = userMeta.MiddleName,
                    IsBlocked = user.BlockDate != null,
                    Phone = userMeta.Contact.PhoneNumber,
                    AdditionalPhone = userMeta.Contact.AdditionalPhoneNumber,
                    Email = userMeta.Contact.Email,
                    Skype = userMeta.Contact.Skype,
                    Tasks = numberTasks
                };

                if (!String.IsNullOrEmpty(prepodMeta.DepartmentsIdsString))
                {
                    List<SelectList> departmentsList = new List<SelectList>();

                    foreach (var depId in prepodMeta.DepartmentsIdsString.Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries))
                    {
                        departmentsList.Add(new SelectList(GetItemsOfDictionary(DictionaryTypeEnum.Кафедры).ToList(), "Id", "Name", depId));
                    }

                    ViewBag.Dapartments = departmentsList;
                }
                else
                    ViewBag.Dapartments = new SelectList(GetItemsOfDictionary(DictionaryTypeEnum.Кафедры).ToList(), "Id", "Name");

            }

            ViewBag.Degree = new SelectList(GetItemsOfDictionary(DictionaryTypeEnum.УченаяСтепень).ToList(), "Id", "Name");
            ViewBag.Facultaty = new SelectList(GetItemsOfDictionary(DictionaryTypeEnum.Факультеты).ToList(), "Id", "Name");
            ViewBag.Speciality = new SelectList(GetItemsOfDictionary(DictionaryTypeEnum.Специальности).ToList(), "Id", "Name");
            ViewBag.Years = new SelectList(Enumerable.Range((DateTime.Now.Year - 6), 15));
            ViewBag.Number = new SelectList(Enumerable.Range(1, 8));
            ViewBag.Groups = new SelectList(GetItemsOfDictionary(DictionaryTypeEnum.Группы).ToList(), "Id", "Name");
            ViewBag.Flows = new SelectList(GetItemsOfDictionary(DictionaryTypeEnum.Потоки).ToList(), "Id", "Name");

            return View("Create", model);
        }