Example #1
0
 public IEnumerable <UserStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null)
 {
     try {
         IEnumerable <IUserState> states = null;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             states = _userApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver())
                                                  , UsersControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         else
         {
             states = _userApplicationService.Get(UsersControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                  , UsersControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         var stateDtos = new List <UserStateDto>();
         foreach (var s in states)
         {
             var dto = s is UserStateDto ? (UserStateDto)s : new UserStateDto((UserState)s);
             if (String.IsNullOrWhiteSpace(fields))
             {
                 dto.AllFieldsReturned = true;
             }
             else
             {
                 dto.ReturnedFieldsString = fields;
             }
             stateDtos.Add(dto);
         }
         return(stateDtos);
     } catch (Exception ex) { var response = UsersControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Example #2
0
 public IUserStateEvent GetStateEvent(string id, long version)
 {
     try {
         var idObj = id;
         return(_userApplicationService.GetStateEvent(idObj, version));
     } catch (Exception ex) { var response = UsersControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Example #3
0
 public void Patch(string id, [FromBody] MergePatchUserDto value)
 {
     try {
         UsersControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _userApplicationService.When(value as IMergePatchUser);
     } catch (Exception ex) { var response = UsersControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Example #4
0
 public void Delete(string id, string commandId, string version, string requesterId = default(string))
 {
     try {
         var value = new DeleteUserDto();
         value.CommandId   = commandId;
         value.RequesterId = requesterId;
         value.Version     = (long)Convert.ChangeType(version, typeof(long));
         UsersControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _userApplicationService.When(value as IDeleteUser);
     } catch (Exception ex) { var response = UsersControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Example #5
0
 public UserLoginStateDto GetUserLogin(string userId, string loginKey)
 {
     try {
         var state = (UserLoginState)_userApplicationService.GetUserLogin(userId, (new LoginKeyFlattenedDtoFormatter().Parse(loginKey)).ToLoginKey());
         if (state == null)
         {
             return(null);
         }
         var stateDto = new UserLoginStateDto(state);
         stateDto.AllFieldsReturned = true;
         return(stateDto);
     } catch (Exception ex) { var response = UsersControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Example #6
0
 public UserPermissionStateDto GetUserPermission(string userId, string permissionId)
 {
     try {
         var state = (UserPermissionState)_userApplicationService.GetUserPermission(userId, permissionId);
         if (state == null)
         {
             return(null);
         }
         var stateDto = new UserPermissionStateDto(state);
         stateDto.AllFieldsReturned = true;
         return(stateDto);
     } catch (Exception ex) { var response = UsersControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Example #7
0
 public IEnumerable <PropertyMetadata> GetMetadataFilteringFields()
 {
     try {
         var filtering = new List <PropertyMetadata>();
         foreach (var p in UserMetadata.Instance.Properties)
         {
             if (p.IsFilteringProperty)
             {
                 filtering.Add(p);
             }
         }
         return(filtering);
     } catch (Exception ex) { var response = UsersControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Example #8
0
 public long GetCount(string filter = null)
 {
     try
     {
         long count = 0;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             count = _userApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver()));
         }
         else
         {
             count = _userApplicationService.GetCount(UsersControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()));
         }
         return(count);
     } catch (Exception ex) { var response = UsersControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Example #9
0
 public UserStateDto Get(string id, string fields = null)
 {
     try {
         var idObj = id;
         var state = (UserState)_userApplicationService.Get(idObj);
         if (state == null)
         {
             return(null);
         }
         var stateDto = new UserStateDto(state);
         if (String.IsNullOrWhiteSpace(fields))
         {
             stateDto.AllFieldsReturned = true;
         }
         else
         {
             stateDto.ReturnedFieldsString = fields;
         }
         return(stateDto);
     } catch (Exception ex) { var response = UsersControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Example #10
0
 public Type ResolveTypeByPropertyName(string propertyName)
 {
     return(UsersControllerUtils.GetFilterPropertyType(propertyName));
 }