Example #1
0
 public IEnumerable <RoleStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null)
 {
     try {
         IEnumerable <IRoleState> states = null;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             states = _roleApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver())
                                                  , RolesControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         else
         {
             states = _roleApplicationService.Get(RolesControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                  , RolesControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         var stateDtos = new List <RoleStateDto>();
         foreach (var s in states)
         {
             var dto = s is RoleStateDto ? (RoleStateDto)s : new RoleStateDto((RoleState)s);
             if (String.IsNullOrWhiteSpace(fields))
             {
                 dto.AllFieldsReturned = true;
             }
             else
             {
                 dto.ReturnedFieldsString = fields;
             }
             stateDtos.Add(dto);
         }
         return(stateDtos);
     } catch (Exception ex) { var response = RolesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Example #2
0
 public long GetCount(string filter = null)
 {
     try
     {
         long count = 0;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             count = _roleApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver()));
         }
         else
         {
             count = _roleApplicationService.GetCount(RolesControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()));
         }
         return(count);
     } catch (Exception ex) { var response = RolesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }