Esempio n. 1
0
 public IEnumerable <PermissionStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null)
 {
     try {
         IEnumerable <IPermissionState> states = null;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             states = _permissionApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver())
                                                        , PermissionsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         else
         {
             states = _permissionApplicationService.Get(PermissionsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                        , PermissionsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         var stateDtos = new List <PermissionStateDto>();
         foreach (var s in states)
         {
             var dto = s is PermissionStateDto ? (PermissionStateDto)s : new PermissionStateDto((PermissionState)s);
             if (String.IsNullOrWhiteSpace(fields))
             {
                 dto.AllFieldsReturned = true;
             }
             else
             {
                 dto.ReturnedFieldsString = fields;
             }
             stateDtos.Add(dto);
         }
         return(stateDtos);
     } catch (Exception ex) { var response = PermissionsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Esempio n. 2
0
 public IPermissionStateEvent GetStateEvent(string id, long version)
 {
     try {
         var idObj = id;
         return(_permissionApplicationService.GetStateEvent(idObj, version));
     } catch (Exception ex) { var response = PermissionsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Esempio n. 3
0
 public void Patch(string id, [FromBody] MergePatchPermissionDto value)
 {
     try {
         PermissionsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _permissionApplicationService.When(value as IMergePatchPermission);
     } catch (Exception ex) { var response = PermissionsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Esempio n. 4
0
 public void Delete(string id, string commandId, string version, string requesterId = default(string))
 {
     try {
         var value = new DeletePermissionDto();
         value.CommandId   = commandId;
         value.RequesterId = requesterId;
         value.Version     = (long)Convert.ChangeType(version, typeof(long));
         PermissionsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _permissionApplicationService.When(value as IDeletePermission);
     } catch (Exception ex) { var response = PermissionsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Esempio n. 5
0
 public IEnumerable <PropertyMetadata> GetMetadataFilteringFields()
 {
     try {
         var filtering = new List <PropertyMetadata>();
         foreach (var p in PermissionMetadata.Instance.Properties)
         {
             if (p.IsFilteringProperty)
             {
                 filtering.Add(p);
             }
         }
         return(filtering);
     } catch (Exception ex) { var response = PermissionsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Esempio n. 6
0
 public long GetCount(string filter = null)
 {
     try
     {
         long count = 0;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             count = _permissionApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver()));
         }
         else
         {
             count = _permissionApplicationService.GetCount(PermissionsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()));
         }
         return(count);
     } catch (Exception ex) { var response = PermissionsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Esempio n. 7
0
 public PermissionStateDto Get(string id, string fields = null)
 {
     try {
         var idObj = id;
         var state = (PermissionState)_permissionApplicationService.Get(idObj);
         if (state == null)
         {
             return(null);
         }
         var stateDto = new PermissionStateDto(state);
         if (String.IsNullOrWhiteSpace(fields))
         {
             stateDto.AllFieldsReturned = true;
         }
         else
         {
             stateDto.ReturnedFieldsString = fields;
         }
         return(stateDto);
     } catch (Exception ex) { var response = PermissionsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }