private AuditDelta GetAuditDelta(AuditDelta request) { var id = request?.Id; AuditDelta ret = null; var query = DocQuery.ActiveQuery ?? Execute; DocPermissionFactory.SetSelect <AuditDelta>(currentUser, "AuditDelta", request.Select); DocEntityAuditDelta entity = null; if (id.HasValue) { entity = DocEntityAuditDelta.Get(id.Value); } if (null == entity) { throw new HttpError(HttpStatusCode.NotFound, $"No AuditDelta 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 AuditDelta Post(AuditDeltaCopy request) { AuditDelta ret = null; using (Execute) { Execute.Run(ssn => { var entity = DocEntityAuditDelta.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 pAudit = entity.Audit; var pDelta = entity.Delta; var copy = new DocEntityAuditDelta(ssn) { Hash = Guid.NewGuid() , Audit = pAudit , Delta = pDelta }; copy.SaveChanges(DocConstantPermission.ADD); ret = copy.ToDto(); }); } return(ret); }