Esempio n. 1
0
        public JsonResult UpdatePerconalData(PersonalDataViewModel model, string avatar)
        {
            if (Roles.IsUserInRole("lector"))
            {
                var modData = new ModifyLecturerViewModel(new Lecturer
                {
                    FirstName  = model.Name,
                    LastName   = model.Surname,
                    MiddleName = model.Patronymic,
                    IsLecturerHasGraduateStudents = model.IsLecturerHasGraduateStudents,
                    IsSecretary = model.IsSecretary,
                    Skill       = model.Skill,
                    User        = new User
                    {
                        UserName     = model.UserName,
                        Avatar       = avatar,
                        About        = model.About,
                        SkypeContact = model.SkypeContact,
                        Phone        = model.Phone,
                        Email        = model.Email,
                        Id           = WebSecurity.CurrentUserId
                    },
                    Id = WebSecurity.CurrentUserId
                });

                modData.ModifyLecturer();
            }
            else
            {
                var modData = new ModifyStudentViewModel(new Student
                {
                    FirstName  = model.Name,
                    LastName   = model.Surname,
                    MiddleName = model.Patronymic,
                    User       = new User
                    {
                        UserName     = model.UserName,
                        Avatar       = avatar,
                        About        = model.About,
                        SkypeContact = model.SkypeContact,
                        Phone        = model.Phone,
                        Email        = model.Email,
                        Id           = WebSecurity.CurrentUserId
                    },
                    Id = WebSecurity.CurrentUserId
                });

                modData.ModifyStudent();
            }

            return(Json(true));
        }
Esempio n. 2
0
        public IActionResult SaveProfessorJson(ModifyLecturerViewModel model)
        {
            try
            {
                model.ModifyLecturer();

                return(Ok());
            }
            catch (Exception ex)
            {
                return(ServerError500(ex.Message));
            }
        }
Esempio n. 3
0
        public ActionResult EditProfessor(ModifyLecturerViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    model.ModifyLecturer();
                    ViewBag.ResultSuccess = true;
                }
                catch
                {
                    ModelState.AddModelError(string.Empty, string.Empty);
                }
            }

            return(null);
        }
Esempio n. 4
0
        public ActionResult EditProfessorAjax(ModifyLecturerViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var user = UsersManagementService.GetUserByName(model.Name, model.Surname, model.Patronymic);
                    if (user == null || user.Id == model.LecturerId)
                    {
                        model.ModifyLecturer();
                        return(this.Json(new { resultMessage = "Преподаватель сохранен" }));
                    }

                    ModelState.AddModelError(string.Empty, "Пользователь с таким именем уже существует");
                }
                catch
                {
                    ModelState.AddModelError(string.Empty, string.Empty);
                }
            }

            return(PartialView("_EditProfessorView", model));
        }
		public JsonResult UpdatePerconalData(PersonalDataViewModel model, string avatar)
        {
            if (Roles.IsUserInRole("lector"))
            {
                var modData = new ModifyLecturerViewModel(new Lecturer
                {
                    FirstName = model.Name,
					LastName = model.Surname,
                    MiddleName = model.Patronymic,
					IsLecturerHasGraduateStudents = model.IsLecturerHasGraduateStudents,
					IsSecretary = model.IsSecretary,
					Skill = model.Skill,
                    User = new User
                    {
                        UserName = model.UserName,
						Avatar = avatar,
						About = model.About,
						SkypeContact = model.SkypeContact,
						Phone = model.Phone,
						Email = model.Email,
                        Id = WebSecurity.CurrentUserId
                    },
                    Id = WebSecurity.CurrentUserId
                });

                modData.ModifyLecturer();
            }
            else
            {
                var modData = new ModifyStudentViewModel(new Student
                {
                    FirstName = model.Name,
					LastName = model.Surname,
                    MiddleName = model.Patronymic,
                    User = new User
                    {
                        UserName = model.UserName,
						Avatar = avatar,
						About = model.About,
						SkypeContact = model.SkypeContact,
						Phone = model.Phone,
						Email = model.Email,
                        Id = WebSecurity.CurrentUserId
                    },
                    Id = WebSecurity.CurrentUserId
                }); 
   
                modData.ModifyStudent();
            }

            return Json(true);
        }
        public ActionResult EditProfessorAjax(ModifyLecturerViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var user = UsersManagementService.GetUserByName(model.Name, model.Surname, model.Patronymic);
                    if (user == null || user.Id == model.LecturerId)
                    {
                        model.ModifyLecturer();
                        return this.Json(new { resultMessage = "Преподаватель сохранен" });
                    }

                    ModelState.AddModelError(string.Empty, "Пользователь с таким именем уже существует");
                }
                catch
                {
                    ModelState.AddModelError(string.Empty, string.Empty);
                }
            }

            return PartialView("_EditProfessorView", model);
        }
        public ActionResult EditProfessor(ModifyLecturerViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    model.ModifyLecturer();
                    ViewBag.ResultSuccess = true;
                }
                catch
                {
                    ModelState.AddModelError(string.Empty, string.Empty);
                }
            }

            return null;
        }