private History GetHistory(History request) { var id = request?.Id; History ret = null; var query = DocQuery.ActiveQuery ?? Execute; DocPermissionFactory.SetSelect <History>(currentUser, "History", request.Select); DocEntityHistory entity = null; if (id.HasValue) { entity = DocEntityHistory.Get(id.Value); } if (null == entity) { throw new HttpError(HttpStatusCode.NotFound, $"No History found for Id {id.Value}"); } if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.VIEW)) { throw new HttpError(HttpStatusCode.Forbidden, "You do not have VIEW permission for this route."); } ret = entity?.ToDto(); return(ret); }
public History Post(HistoryCopy request) { History ret = null; using (Execute) { Execute.Run(ssn => { var entity = DocEntityHistory.Get(request?.Id); if (null == entity) { throw new HttpError(HttpStatusCode.NoContent, "The COPY request did not succeed."); } if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.ADD)) { throw new HttpError(HttpStatusCode.Forbidden, "You do not have ADD permission for this route."); } var pApp = entity.App; var pDocumentSet = entity.DocumentSet; var pImpersonation = entity.Impersonation; var pPage = entity.Page; var pURL = entity.URL; if (!DocTools.IsNullOrEmpty(pURL)) { pURL += " (Copy)"; } var pUser = entity.User; var pUserSession = entity.UserSession; var pWorkflow = entity.Workflow; var copy = new DocEntityHistory(ssn) { Hash = Guid.NewGuid() , App = pApp , DocumentSet = pDocumentSet , Impersonation = pImpersonation , Page = pPage , URL = pURL , User = pUser , UserSession = pUserSession , Workflow = pWorkflow }; copy.SaveChanges(DocConstantPermission.ADD); ret = copy.ToDto(); }); } return(ret); }