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);
        }
예제 #2
0
        public ActionResult EditStudent(ModifyStudentViewModel model, int id)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    model.ModifyStudent();
                    ViewBag.ResultSuccess = true;
                }
                catch
                {
                    ModelState.AddModelError(string.Empty, string.Empty);
                }
            }

            return null;
        }
예제 #3
0
        public ActionResult EditStudentAjax(ModifyStudentViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var user = UsersManagementService.GetUserByName(model.Name, model.Surname, model.Patronymic);
                    if (user == null || user.Id == model.Id)
                    {
                        model.ModifyStudent();
                        return Json(new { resultMessage = "Студент сохранен" });
                    }

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

            return PartialView("_EditStudentView", model);
        }
예제 #4
0
        public ActionResult EditStudent(int id)
        {
            var student = StudentManagementService.GetStudent(id);

            if (student != null)
            {
                var model = new ModifyStudentViewModel(student);
                return PartialView("_EditStudentView", model);
            }

            return RedirectToAction("Index");
        }