Exemplo n.º 1
0
        public ActionResult CandidateDocuments(CandidateDocumentsModel model)
        {
            //, IEnumerable<HttpPostedFileBase> files
            string error = String.Empty;
            string SPPath = AuthenticationService.CurrentUser.Id.ToString();

            if (model.DeleteAttachmentId == 0)
            {
                ModelState.Clear();
                //кадровик не может менять список документов после выгрузки кандидата в 1С
                if (model.IsSave && model.SendTo1C.HasValue)
                {
                    ModelState.AddModelError("SendTo1C", "Кандидат выгружен в 1С! Изменение перечня документов для подписи не возможно!");
                }
                else
                {
                    if (AuthenticationService.CurrentUser.UserRole == UserRole.PersonnelManager && !EmploymentBl.IsUnlimitedEditAvailable())
                    {
                        model = EmploymentBl.GetCandidateDocumentsModel(model.UserId);
                        ModelState.AddModelError("SendTo1C", "У вас нет прав для редактирования данных!");
                    }
                    else
                    {
                        string str = model.IsSave ? "Список документов для подписи сформирован! Если список документов сформирован впервые или был изменен, то будет отправлено сообщение руководителю!" : "Файл загружен!";
                        EmploymentBl.SaveCandidateDocumentsAttachments(model, out error);
                        model = EmploymentBl.GetCandidateDocumentsModel(model.UserId);
                        ModelState.AddModelError("SendTo1C", string.IsNullOrEmpty(error) ? str : error);
                    }
                }

                if (Session["CandidateDocumentsM" + SPPath] != null)
                    Session.Remove("CandidateDocumentsM" + SPPath);
                if (Session["CandidateDocumentsM" + SPPath] == null)
                    Session.Add("CandidateDocumentsM" + SPPath, model);

                if (Session["CandidateDocumentsMS" + SPPath] != null)
                    Session.Remove("CandidateDocumentsMS" + SPPath);
                if (Session["CandidateDocumentsMS" + SPPath] == null)
                {
                    ModelStateDictionary mst = ModelState;
                    Session.Add("CandidateDocumentsMS" + SPPath, mst);
                }
            }
            else
            {
                if (AuthenticationService.CurrentUser.UserRole == UserRole.PersonnelManager && !EmploymentBl.IsUnlimitedEditAvailable())
                {
                    ModelState.AddModelError("SendTo1C", "У вас нет прав для редактирования данных!");
                    model = EmploymentBl.GetCandidateDocumentsModel(model.UserId);
                }
                else
                {
                    //DeleteAttacmentModel modelDel = new DeleteAttacmentModel { Id = model.DeleteAttachmentId };
                    //EmploymentBl.DeleteAttachment(modelDel);
                    EmploymentBl.DeleteCandidateDocument(model, out error);
                    model = EmploymentBl.GetCandidateDocumentsModel(model.UserId);
                    ModelState.AddModelError("SendTo1C", error);
                }

                if (Session["CandidateDocumentsMS" + SPPath] != null)
                    Session.Remove("CandidateDocumentsMS" + SPPath);
                if (Session["CandidateDocumentsMS" + SPPath] == null)
                {
                    ModelStateDictionary mst = ModelState;
                    Session.Add("CandidateDocumentsMS" + SPPath, mst);
                }
            }

            if (AuthenticationService.CurrentUser.UserRole == UserRole.PersonnelManager || AuthenticationService.CurrentUser.UserRole == UserRole.Manager)
                return Redirect("PersonnelInfo?id=" + model.UserId + "&IsCandidateInfoAvailable=true&IsBackgroundCheckAvailable=true&IsManagersAvailable=true&IsPersonalManagersAvailable=true&TabIndex=10");
            else
                return View(model);
        }
Exemplo n.º 2
0
        public ActionResult CandidateDocuments(int? id)
        {
            string SPPath = AuthenticationService.CurrentUser.Id.ToString();
            CandidateDocumentsModel model = new CandidateDocumentsModel();

            if (Session["CandidateDocumentsM" + SPPath] != null)
            {
                model = (CandidateDocumentsModel)Session["CandidateDocumentsM" + SPPath];
                Session.Remove("CandidateDocumentsM" + SPPath);
            }
            else
                model = EmploymentBl.GetCandidateDocumentsModel(id);

            if (Session["CandidateDocumentsMS" + SPPath] != null)
            {
                ModelState.Clear();
                for (int i = 0; i < ((ModelStateDictionary)Session["CandidateDocumentsMS" + SPPath]).Count; i++)
                {
                    ModelState.Add(((ModelStateDictionary)Session["CandidateDocumentsMS" + SPPath]).ElementAt(i));
                }
                Session.Remove("CandidateDocumentsMS" + SPPath);
            }

            if (AuthenticationService.CurrentUser.UserRole == UserRole.Candidate)
                return View(model);
            else
                return PartialView(model);
        }