public ActionResult Education(EducationModel model) { string error = String.Empty; string SPPath = AuthenticationService.CurrentUser.Id.ToString(); if (model.Operation == 0) { if (ValidateModel(model)) { model.IsDraft = model.IsEducationDraft; EmploymentBl.ProcessSaving<EducationModel, Education>(model, out error); model = EmploymentBl.GetEducationModel(model.UserId); ModelState.AddModelError("IsValidate", string.IsNullOrEmpty(error) ? "Данные сохранены!" : error); ViewBag.Error = error; } else { //так как при использования вкладок, страницу приходится перезагружать с потерей данных, то передаем модель с библиотекой ошибок через переменную сессии model = EmploymentBl.GetEducationModel(model.UserId); if (Session["EducationM" + SPPath] != null) Session.Remove("EducationM" + SPPath); if (Session["EducationM" + SPPath] == null) Session.Add("EducationM" + SPPath, model); } if (Session["EducationMS" + SPPath] != null) Session.Remove("EducationMS" + SPPath); if (Session["EducationMS" + SPPath] == null) { ModelStateDictionary mst = ModelState; Session.Add("EducationMS" + SPPath, mst); } } else { EmploymentBl.DeleteEducationRow(model); } if ((AuthenticationService.CurrentUser.UserRole & UserRole.PersonnelManager) > 0 && EmploymentBl.IsUnlimitedEditAvailable()) return Redirect("PersonnelInfo?id=" + model.UserId + "&IsCandidateInfoAvailable=true&IsBackgroundCheckAvailable=true&IsManagersAvailable=true&IsPersonalManagersAvailable=true&TabIndex=3"); else return model.IsFinal && !EmploymentBl.IsUnlimitedEditAvailable() ? View("EducationReadOnly", model) : View(model); }
protected bool ValidateModel(EducationModel model) { ModelState.Clear(); ValidateFileLength(model.HigherEducationDiplomaScanFile, "HigherEducationDiplomaScanFile", 5); ValidateFileLength(model.PostGraduateEducationDiplomaScanFile, "PostGraduateEducationDiplomaScanFile", 2); ValidateFileLength(model.CertificationScanFile, "CertificationScanFile", 2); ValidateFileLength(model.TrainingScanFile, "TrainingScanFile", 2); if (!model.IsEducationDraft) { //EducationModel mt = EmploymentBl.GetEducationModel(model.UserId); //if (EmploymentBl.CheckExistsEducationRecord(model.UserId, 1) != 0 && model.HigherEducationDiplomaScanFile == null && string.IsNullOrEmpty(mt.HigherEducationDiplomaScanFileName)) //{ // ModelState.AddModelError("HigherEducationDiplomaScanFile", "Не выбран файл скана документа об образовании для загрузки!"); //} //if (EmploymentBl.CheckExistsEducationRecord(model.UserId, 2) != 0 && model.PostGraduateEducationDiplomaScanFile == null && string.IsNullOrEmpty(mt.PostGraduateEducationDiplomaScanFileName)) //{ // ModelState.AddModelError("PostGraduateEducationDiplomaScanFile", "Не выбран файл скана документа об образовании для загрузки!"); //} //if (EmploymentBl.CheckExistsEducationRecord(model.UserId, 3) != 0 && model.CertificationScanFile == null && string.IsNullOrEmpty(mt.CertificationScanFileName)) //{ // ModelState.AddModelError("CertificationScanFile", "Не выбран файл скана документа об образовании для загрузки!"); //} //if (EmploymentBl.CheckExistsEducationRecord(model.UserId, 4) != 0 && model.TrainingScanFile == null && string.IsNullOrEmpty(mt.TrainingScanFileName)) //{ // ModelState.AddModelError("TrainingScanFile", "Не выбран файл скана документа об образовании для загрузки!"); //} if (!model.IsValidate) { ModelState.AddModelError("IsValidate", "Подтвердите правильность предоставленных данных! Подтвердив правильность предоставленных данных, Вы не сможете больше вносить изменения в данную часть анкеты!"); } } return ModelState.IsValid; }