public ActionResult ShowDocument(Guid id, bool isAfterView = false) { var previousModelState = TempData["ModelState"] as ModelStateDictionary; if (previousModelState != null) { foreach (KeyValuePair <string, ModelState> kvp in previousModelState) { if (!ModelState.ContainsKey(kvp.Key)) { ModelState.Add(kvp.Key, kvp.Value); } } } DocumentTable docuTable = _DocumentService.Find(id); ProcessView process = _ProcessService.FindView(docuTable.ProcessTableId); if (docuTable == null || process == null || docuTable.isShow(isAfterView) == false) { return(RedirectToAction("PageNotFound", "Error")); } _ReviewDocLogService.SaveDomain(new ReviewDocLogTable { DocumentTableId = id }); EmplTable emplTable = _EmplService.FirstOrDefault(x => x.ApplicationUserId == docuTable.ApplicationUserCreatedId); ApplicationUser userTable = _AccountService.Find(docuTable.ApplicationUserCreatedId); if (emplTable == null || userTable == null) { return(HttpNotFound()); } object viewModel = InitialViewShowDocument(id, process, docuTable, userTable, emplTable); return(View(viewModel)); }
// GET api/<controller> public void Get(int id, string companyId) { IEmailService _Emailservice = DependencyResolver.Current.GetService <IEmailService>(); IDocumentService _Documentservice = DependencyResolver.Current.GetService <IDocumentService>(); IReviewDocLogService _ReviewDocLogService = DependencyResolver.Current.GetService <IReviewDocLogService>(); var allDocument = _Documentservice.GetPartial(x => x.CompanyTable.AliasCompanyName == companyId); if (allDocument == null) { return; } switch (id) { case 1: foreach (var document in allDocument) { var users = _Documentservice.GetUsersSLAStatus(document, SLAStatusList.Warning); foreach (var user in users) { _Emailservice.SendSLAWarningEmail(document, user.UserId); } } break; case 2: foreach (var document in allDocument) { var users = _Documentservice.GetUsersSLAStatus(document, SLAStatusList.Disturbance); foreach (var user in users) { _Emailservice.SendSLADisturbanceEmail(document, user.UserId); } } break; case 3: foreach (var document in allDocument) { if (document.DocumentState == Models.Repository.DocumentState.Closed || document.DocumentState == Models.Repository.DocumentState.Cancelled || document.DocumentState == Models.Repository.DocumentState.Completed || document.DocumentState == Models.Repository.DocumentState.Created) { IEnumerable <ReviewDocLogTable> reviewDocuments = _ReviewDocLogService.GetPartial(x => x.DocumentTableId == document.Id); if (reviewDocuments != null) { foreach (var reviewTable in reviewDocuments) { if (reviewTable.CreatedDate <= DateTime.UtcNow.AddMonths(-2)) { reviewTable.isArchive = true; _ReviewDocLogService.SaveDomain(reviewTable); } } } } } break; } }