コード例 #1
0
        public ActionResult ShowDocument(Guid id, string approveDoc, string rejectDoc, IDictionary <string, object> documentData, string lastComment = "")
        {
            DocumentTable docuTable = _DocumentService.Find(id);

            if (docuTable == null)
            {
                return(HttpNotFound());
            }

            if (lastComment != "")
            {
                _CommentService.SaveDomain(new CommentTable {
                    Comment = lastComment, DocumentTableId = id
                });
            }

            if (rejectDoc != String.Empty)
            {
                ApplicationUser userTable = _AccountService.FirstOrDefault(x => x.UserName == User.Identity.Name);
                if (userTable == null)
                {
                    return(HttpNotFound());
                }

                DateTime checkRejectDate = DateTime.UtcNow.AddMinutes(-5);
                if (!_CommentService.Contains(x => x.ApplicationUserCreatedId == userTable.Id && x.DocumentTableId == id && x.CreatedDate >= checkRejectDate))
                {
                    EmplTable   emplTable = _EmplService.FirstOrDefault(x => x.ApplicationUserId == docuTable.ApplicationUserCreatedId);
                    ProcessView process   = _ProcessService.FindView(docuTable.ProcessTableId);
                    object      viewModel = InitialViewShowDocument(id, process, docuTable, userTable, emplTable);
                    ModelState.AddModelError(string.Empty, UIElementRes.UIElement.RejectReason);

                    return(View("~/Views/Document/ShowDocument.cshtml", viewModel));
                }
            }

            ProcessTable processTable = docuTable.ProcessTable;

            if (_DocumentService.isSignDocument(id, processTable.Id))
            {
                if (approveDoc != String.Empty)
                {
                    _WorkflowService.AgreementWorkflowApprove(id, processTable.TableName, documentData);
                }
                else if (rejectDoc != String.Empty)
                {
                    _WorkflowService.AgreementWorkflowReject(id, processTable.TableName, documentData);
                }
            }
            return(RedirectToAction("Index", "Home"));
        }