public ActionResult EditRole(int id) { if (!ModelState.IsValid) { return(RedirectToAction("Roles")); } var role = _rolesHandler.FindById(id); if (role != null) { return(View(ConvertToModel(role))); } return(RedirectToAction("Roles")); }
public ActionResult EditUser(int id) { ViewBag.Positions = new PositionsHandler().PositionsSelectList(); ViewBag.Roles = new RolesHandler().RolesSelectList(); if (ModelState.IsValid) { var user = _usersHandler.FindById(id); if (user != null) { return(View(ConvertToModel(user))); } } return(RedirectToAction("Users")); }
public DocumentView GetDocumentView(int id) { var documentView = new DocumentView(); if (id == null) { throw new NullReferenceException(); } var document = _documentsHandler.FindById(id); documentView.Id = document.Id; documentView.Name = document.Name; documentView.Text = document.Text; var steps = new List <Step>(((StepsRepositoryHandler)_stepsHandler) .GetDocumentSteps(document.Id)); var path = new StringBuilder(); foreach (var step in steps) { string fullName = step.User == null ? "Неизвестный" : step.User.FirstName + " " + step.User.LastName + " " + step.User.Patronymic; var status = step.Status == true ? "Подписано" : step.Status == false ? "Отклонено" : "Не подписано"; path.Append("<span>" + fullName + "-" + status + "</span></br>"); } documentView.Path = path.ToString(); return(documentView); }
public ActionResult FillDocument(int id) { var template = _templatesRepositoryHandler.FindById(id); template = new HtmlDocumentHandler(GetUserName()).ConvertView(template); ViewBag.FullName = GetUserName(); return(View(DocumentTemplateController.ConvertToModel(template))); }
public void Sign(int documentId) { var currentStep = _currentStepsHandler.GetDocumentStep(documentId); if (currentStep != null) { _currentStepsHandler.Remove(currentStep); var steps = _stepsHandler.GetDocumentSteps(documentId); var oldStep = _stepsHandler.FindById(currentStep.StepId); if (steps.Any()) { oldStep.Status = true; _stepsHandler.Update(oldStep); var newStep = steps.FirstOrDefault(x => x.SerialNumber == oldStep.SerialNumber + 1); if (newStep != null) { if (newStep.User != null) { _currentStepsHandler.Add(new CurrentStep { StepId = newStep.Id, DocumentId = documentId, UserId = newStep.User.Id }); } } else { var document = _documentsHandler.FindById(documentId); document.Status = true; _documentsHandler.Update(document); } } } }
public ActionResult EditPosition(int id) { var position = _positionsHandler.FindById(id); return(View(ConvertToModel(position))); }
public ActionResult EditDocumentType(int id) { var type = _typesHandler.FindById(id); return(View(ConvertToModel(type))); }
public void ParseInputToDocument(object[] inputs) { var insertsList = DynamicJsonConverter.Convert(inputs); var newDocument = new Document(); var templateIdPair = insertsList.FirstOrDefault(x => x.Item1 == "Id"); if (templateIdPair == null) { throw new NullReferenceException(); } var namePair = insertsList.FirstOrDefault(x => x.Item1 == "DocName"); var templateId = int.Parse(templateIdPair.Item2); var template = _templatesHandler.FindById(templateId); newDocument.Type = template.Type; var user = _usersHandler.FindById(_userId); newDocument.User = user; newDocument.Name = namePair.Item2; newDocument.DateTime = DateTime.Now; newDocument.Text = CreateDocumentText(template.Text, insertsList.Where(x => !x.Item1.Contains("*")).ToList()); _documentsHandler.Add(newDocument); var a = ((DocumentsRepositoryHandler)_documentsHandler) .GetUserDocumentByTime(_userId, newDocument.DateTime); newDocument = (_documentsHandler as DocumentsRepositoryHandler) .GetUserDocumentByTime(_userId, newDocument.DateTime); var usersIds = CreateDocumentPath(template.PositionsPath, insertsList.Where(x => x.Item1.Contains("*")).ToList()); if (usersIds == null) { throw new ArgumentNullException(); } var serialNumber = 1; var steps = new List <Step>(); foreach (var id in usersIds) { _stepsHandler.Add( new Step { User = _usersHandler.FindById(id), SerialNumber = serialNumber++, Document = newDocument }); } var firstStep = ((StepsRepositoryHandler)_stepsHandler) .GetDocumentSteps(newDocument.Id) .FirstOrDefault(x => x.SerialNumber == 1); _currentStepsHandler.Add( new CurrentStep { StepId = firstStep.Id, UserId = firstStep.User.Id, DocumentId = newDocument.Id }); }