private DateTimeDto GetDateTime(DateTimeDto request) { var id = request?.Id; DateTimeDto ret = null; var query = DocQuery.ActiveQuery ?? Execute; DocPermissionFactory.SetSelect <DateTimeDto>(currentUser, "DateTime", request.Select); DocEntityDateTime entity = null; if (id.HasValue) { entity = DocEntityDateTime.Get(id.Value); } if (null == entity) { throw new HttpError(HttpStatusCode.NotFound, $"No DateTime 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 DateTimeDto Post(DateTimeDtoCopy request) { DateTimeDto ret = null; using (Execute) { Execute.Run(ssn => { var entity = DocEntityDateTime.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 pDateDay = entity.DateDay; var pDateMonth = entity.DateMonth; var pDateTime = entity.DateTime; var pDateYear = entity.DateYear; var copy = new DocEntityDateTime(ssn) { Hash = Guid.NewGuid() , DateDay = pDateDay , DateMonth = pDateMonth , DateTime = pDateTime , DateYear = pDateYear }; copy.SaveChanges(DocConstantPermission.ADD); ret = copy.ToDto(); }); } return(ret); }