Пример #1
0
        public void ModifyStudent()
        {
            var groupId = int.Parse(Group);

            StudentManagementService.UpdateStudent(
                new Student
            {
                Id         = Id,
                FirstName  = Name,
                LastName   = Surname,
                MiddleName = Patronymic,
                Email      = Email,
                Confirmed  = true,
                GroupId    = groupId,
                Group      = GroupManagementService.GetGroup(groupId),
                User       = new User
                {
                    Avatar       = Avatar,
                    UserName     = UserName,
                    About        = About,
                    SkypeContact = SkypeContact,
                    Phone        = Phone,
                    Email        = Email,
                    Id           = Id
                }
            });
        }
Пример #2
0
        public StudentMarkForDateResult GetMarksCalendarData(string dateId, string subjectId, string groupId)
        {
            try
            {
                var subjectIntId = int.Parse(subjectId);
                var dateIntId    = int.Parse(dateId);
                var visitingDate =
                    SubjectManagementService.GetScheduleVisitings(
                        new Query <LecturesScheduleVisiting>(e => e.SubjectId == subjectIntId && e.Id == dateIntId)).FirstOrDefault();

                var group = GroupManagementService.GetGroup(int.Parse(groupId));
                var model = new List <StudentMarkForDateViewData>();
                foreach (var student in group.Students.OrderBy(e => e.FullName))
                {
                    if (student.LecturesVisitMarks.Any(e => e.LecturesScheduleVisitingId == visitingDate.Id))
                    {
                        model.Add(new StudentMarkForDateViewData
                        {
                            MarkId      = student.LecturesVisitMarks.FirstOrDefault(e => e.LecturesScheduleVisitingId == visitingDate.Id).Id,
                            StudentId   = student.Id,
                            Login       = student.User.UserName,
                            StudentName = student.FullName,
                            Mark        = student.LecturesVisitMarks.FirstOrDefault(e => e.LecturesScheduleVisitingId == visitingDate.Id).Mark
                        });
                    }
                    else
                    {
                        model.Add(new StudentMarkForDateViewData
                        {
                            MarkId      = 0,
                            StudentId   = student.Id,
                            StudentName = student.FullName,
                            Login       = student.User.UserName,
                            Mark        = string.Empty
                        });
                    }
                }

                return(new StudentMarkForDateResult()
                {
                    DateId = dateIntId,
                    Date = visitingDate.Date.ToShortDateString(),
                    StudentMarkForDate = model,
                    Message = "Данные успешно загружены",
                    Code = "200"
                });
            }
            catch (Exception)
            {
                return(new StudentMarkForDateResult()
                {
                    Message = "Произошла ошибка",
                    Code = "500"
                });
            }
        }
Пример #3
0
        public ActionResult GetSideNav(int groupId)
        {
            var group    = GroupManagementService.GetGroup(groupId);
            var subjects = SubjectManagementService.GetGroupSubjects(groupId);

            var model = new ParentalViewModel(group)
            {
                Subjects = subjects
            };

            return(PartialView("_ParentalSideNavPartial", model));
        }
Пример #4
0
        public ActionResult EditGroup(int id)
        {
            var group = GroupManagementService.GetGroup(id);

            if (group != null)
            {
                var model = new GroupViewModel(group);
                return(PartialView("_EditGroupView", model));
            }

            return(RedirectToAction("Index"));
        }
Пример #5
0
        private void SaveStudent()
        {
            var user    = UsersManagementService.GetUser(UserName);
            var student = StudentManagementService.Save(new Student
            {
                Id         = user.Id,
                FirstName  = Name,
                LastName   = Surname,
                MiddleName = Patronymic,
                GroupId    = int.Parse(Group),
                Confirmed  = false
            });

            student.User  = user;
            student.Group = GroupManagementService.GetGroup(student.GroupId);
            new StudentSearchMethod().AddToIndex(student);
        }
Пример #6
0
        public JsonResult DeleteGroup(int id)
        {
            try
            {
                var group = GroupManagementService.GetGroup(id);
                if (group != null)
                {
                    if (group.Students != null && group.Students.Count > 0)
                    {
                        return(Json(new { resultMessage = "Группа содержит студентов и не может быть удалена" }));
                    }

                    GroupManagementService.DeleteGroup(id);
                    return(Json(new { resultMessage = string.Format("Группа {0} удалена", group.Name) }));
                }

                return(Json(new { resultMessage = "Группы не существует" }));
            }
            catch
            {
                return(Json(new { resultMessage = "Произошла ошибка при удалении" }));
            }
        }