public IEnumerable <RolePermissionStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null)
 {
     try {
         IEnumerable <IRolePermissionState> states = null;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             states = _rolePermissionApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver())
                                                            , RolePermissionsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         else
         {
             states = _rolePermissionApplicationService.Get(RolePermissionsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                            , RolePermissionsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         var stateDtos = new List <RolePermissionStateDto>();
         foreach (var s in states)
         {
             var dto = s is RolePermissionStateDto ? (RolePermissionStateDto)s : new RolePermissionStateDto((RolePermissionState)s);
             if (String.IsNullOrWhiteSpace(fields))
             {
                 dto.AllFieldsReturned = true;
             }
             else
             {
                 dto.ReturnedFieldsString = fields;
             }
             stateDtos.Add(dto);
         }
         return(stateDtos);
     } catch (Exception ex) { var response = RolePermissionsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
 public IRolePermissionStateEvent GetStateEvent(string id, long version)
 {
     try {
         var idObj = RolePermissionsControllerUtils.ParseIdString(id);
         return(_rolePermissionApplicationService.GetStateEvent(idObj, version));
     } catch (Exception ex) { var response = RolePermissionsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
 public void Patch(string id, [FromBody] MergePatchRolePermissionDto value)
 {
     try {
         RolePermissionsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _rolePermissionApplicationService.When(value as IMergePatchRolePermission);
     } catch (Exception ex) { var response = RolePermissionsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
 public void Delete(string id, string commandId, string version, string requesterId = default(string))
 {
     try {
         var value = new DeleteRolePermissionDto();
         value.CommandId   = commandId;
         value.RequesterId = requesterId;
         value.Version     = (long)Convert.ChangeType(version, typeof(long));
         RolePermissionsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _rolePermissionApplicationService.When(value as IDeleteRolePermission);
     } catch (Exception ex) { var response = RolePermissionsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
 public IEnumerable <PropertyMetadata> GetMetadataFilteringFields()
 {
     try {
         var filtering = new List <PropertyMetadata>();
         foreach (var p in RolePermissionMetadata.Instance.Properties)
         {
             if (p.IsFilteringProperty)
             {
                 filtering.Add(p);
             }
         }
         return(filtering);
     } catch (Exception ex) { var response = RolePermissionsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
 public long GetCount(string filter = null)
 {
     try
     {
         long count = 0;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             count = _rolePermissionApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver()));
         }
         else
         {
             count = _rolePermissionApplicationService.GetCount(RolePermissionsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()));
         }
         return(count);
     } catch (Exception ex) { var response = RolePermissionsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
 public RolePermissionStateDto Get(string id, string fields = null)
 {
     try {
         var idObj = RolePermissionsControllerUtils.ParseIdString(id);
         var state = (RolePermissionState)_rolePermissionApplicationService.Get(idObj);
         if (state == null)
         {
             return(null);
         }
         var stateDto = new RolePermissionStateDto(state);
         if (String.IsNullOrWhiteSpace(fields))
         {
             stateDto.AllFieldsReturned = true;
         }
         else
         {
             stateDto.ReturnedFieldsString = fields;
         }
         return(stateDto);
     } catch (Exception ex) { var response = RolePermissionsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
 public Type ResolveTypeByPropertyName(string propertyName)
 {
     return(RolePermissionsControllerUtils.GetFilterPropertyType(propertyName));
 }