Ejemplo n.º 1
0
        public JsonResult DeleteLecturer(int id)
        {
            try
            {
                var lecturer = LecturerManagementService.GetLecturer(id);

                if (lecturer != null)
                {
                    var result = LecturerManagementService.DeleteLecturer(id);

                    if (result)
                    {
                        return(Json(new { resultMessage = string.Format("Преподаватель {0} удален", lecturer.FullName) }));
                    }

                    return(Json(new { resultMessage = string.Format("Не удалось удалить преподавателя {0}", lecturer.FullName) }));
                }

                return(Json(new { resultMessage = "Удаление невозможно. Преподавателя не существует" }));
            }
            catch
            {
                return(Json(new { resultMessage = "Произошла ошибка при удалении" }));
            }
        }
Ejemplo n.º 2
0
 public PersonalDataViewModel()
 {
     if (LecturerManagementService.GetLecturer(/*todo #auth WebSecurity.CurrentUserId*/ 2) != null)
     {
         var user = LecturerManagementService.GetLecturer(/*todo #auth WebSecurity.CurrentUserId*/ 2);
         Name         = user.FirstName;
         Skill        = user.Skill;
         Surname      = user.LastName;
         Patronymic   = user.MiddleName;
         UserName     = user.User.UserName;
         Avatar       = user.User.Avatar;
         IsSecretary  = user.IsSecretary;
         About        = user.User.About;
         SkypeContact = user.User.SkypeContact;
         Phone        = user.User.Phone;
         Email        = user.User.Email;
         IsActive     = user.IsActive;
         IsLecturerHasGraduateStudents = user.IsLecturerHasGraduateStudents;
     }
     else if (StudentManagementService.GetStudent(/*todo #auth WebSecurity.CurrentUserId*/ 2) != null)
     {
         var user = StudentManagementService.GetStudent(/*todo #auth WebSecurity.CurrentUserId*/ 2);
         Name         = user.FirstName;
         Patronymic   = user.MiddleName;
         Surname      = user.LastName;
         UserName     = user.User.UserName;
         Avatar       = user.User.Avatar;
         About        = user.User.About;
         SkypeContact = user.User.SkypeContact;
         Phone        = user.User.Phone;
         Email        = user.User.Email;
     }
 }
Ejemplo n.º 3
0
        public DataTablesResult <LecturerViewModel> GetCollectionLecturers(DataTablesParam dataTableParam)
        {
            var searchString = dataTableParam.GetSearchString();

            ViewBag.EditActionLink   = "/Administration/EditProfessor";
            ViewBag.DeleteActionLink = "/Administration/DeleteLecturer";
            ViewBag.StatActionLink   = "/Administration/Attendance";
            var lecturers = LecturerManagementService.GetLecturersPageable(pageInfo: dataTableParam.ToPageInfo(), searchString: searchString);

            return(DataTableExtensions.GetResults(lecturers.Items.Select(l => LecturerViewModel.FormLecturers(l, PartialViewToString("_EditGlyphLinks", l.Id))), dataTableParam, lecturers.TotalCount));
        }
Ejemplo n.º 4
0
        public ActionResult EditProfessor(int id)
        {
            var lecturer = LecturerManagementService.GetLecturer(id);

            if (lecturer != null)
            {
                var model = new ModifyLecturerViewModel(lecturer);
                return(PartialView("_EditProfessorView", model));
            }

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 5
0
        private void SaveLecturer()
        {
            var user = UsersManagementService.GetUser(UserName);

            LecturerManagementService.Save(new Lecturer
            {
                Id          = user.Id,
                FirstName   = Name,
                LastName    = Surname,
                MiddleName  = Patronymic,
                IsSecretary = IsSecretary,
                IsLecturerHasGraduateStudents = IsLecturerHasGraduateStudents
            });
        }
Ejemplo n.º 6
0
        private void SaveLecturer()
        {
            var user     = UsersManagementService.GetUser(UserName);
            var lecturer = LecturerManagementService.Save(new Lecturer
            {
                Id          = user.Id,
                FirstName   = Name,
                LastName    = Surname,
                MiddleName  = Patronymic,
                IsSecretary = IsSecretary,
                IsLecturerHasGraduateStudents = IsLecturerHasGraduateStudents
            });

            lecturer.User = user;
            new LecturerSearchMethod().AddToIndex(lecturer);
        }
Ejemplo n.º 7
0
        public void ModifyLecturer()
        {
            var selectedGroups = SelectedGroupIds != null && SelectedGroupIds.Count > 0
                ? GroupManagementService.GetGroups(new Query <Group>(x => SelectedGroupIds.Contains(x.Id)))
                : new List <Group>();

            foreach (var group in GroupManagementService.GetGroups(new Query <Group>(x => x.SecretaryId == LecturerId)))
            {
                group.SecretaryId = null;
                GroupManagementService.UpdateGroup(group);
            }

            if (IsSecretary)
            {
                foreach (var group in selectedGroups)
                {
                    group.SecretaryId = LecturerId;
                    GroupManagementService.UpdateGroup(group);
                }
            }

            LecturerManagementService.UpdateLecturer(new Lecturer
            {
                Id          = LecturerId,
                FirstName   = Name,
                LastName    = Surname,
                Skill       = Skill,
                MiddleName  = Patronymic,
                IsSecretary = IsSecretary,
                IsLecturerHasGraduateStudents = IsLecturerHasGraduateStudents,
                SecretaryGroups = selectedGroups,
                IsActive        = IsActive,
                User            = new User
                {
                    Id           = LecturerId,
                    Avatar       = Avatar,
                    UserName     = UserName,
                    About        = About,
                    SkypeContact = SkypeContact,
                    Phone        = Phone,
                    Email        = Email
                }
            });
        }
Ejemplo n.º 8
0
        public IList <SelectListItem> GetLecturers()
        {
            var lecturers = new LecturerManagementService().GetLecturers();

            var lecturerList = new List <Lecturer>();

            foreach (var lecturer in lecturers)
            {
                if (ProjectManagementService.IsUserAssignedOnProject(lecturer.Id, ProjectId) == false)
                {
                    lecturerList.Add(lecturer);
                }
            }

            return(lecturerList.Select(v => new SelectListItem
            {
                Text = v.LastName + " " + v.FirstName + " " + v.MiddleName,
                Value = v.Id.ToString(CultureInfo.InvariantCulture)
            }).ToList());
        }
Ejemplo n.º 9
0
        public JsonResult GetLecturers()
        {
            var _lecturers = new LecturerManagementService().GetLecturers();

            var lecturerList = new List <Lecturer>();

            foreach (var lecturer in _lecturers)
            {
                if (ProjectManagementService.IsUserAssignedOnProject(lecturer.Id, _currentProjectId) == false)
                {
                    lecturerList.Add(lecturer);
                }
            }

            var lecturers = lecturerList.Select(v => new SelectListItem
            {
                Text  = v.FullName,
                Value = v.Id.ToString(CultureInfo.InvariantCulture)
            }).ToList();

            return(Json(new SelectList(lecturers, "Value", "Text")));
        }
Ejemplo n.º 10
0
        public List <StudentGroupUser> GetLecturerList()
        {
            LecturerList = new List <StudentGroupUser>();

            var lecturers = new LecturerManagementService().GetLecturers().ToList();
            var number    = 1;

            foreach (var lecturer in lecturers)
            {
                LecturerList.Add(new StudentGroupUser
                {
                    Number             = number,
                    Name               = lecturer.LastName + " " + lecturer.FirstName + " " + lecturer.MiddleName,
                    ProjectName        = GetProjectNameList(lecturer.Id),
                    ProjectRole        = GetProjectRoleList(lecturer.Id),
                    ProjectCreatorName = GetProjectCreatorNameList(lecturer.Id),
                    QuentityOfProjects = GetProjectNameList(lecturer.Id).Count()
                });
                number++;
            }

            //LecturerList.Sort();
            return(LecturerList);
        }