public void Patch(string id, [FromBody] MergePatchRoleTypeDto value) { try { RoleTypesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _roleTypeApplicationService.When(value as IMergePatchRoleType); } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <IRoleTypeStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null) { try { IEnumerable <IRoleTypeState> states = null; if (!String.IsNullOrWhiteSpace(filter)) { states = _roleTypeApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new WebApiControllerTypeConverter(), new PropertyTypeResolver() , n => (RoleTypeMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? RoleTypeMetadata.Instance.FilteringPropertyAliasDictionary[n] : n)) , RoleTypesControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } else { states = _roleTypeApplicationService.Get(RoleTypesControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()) , RoleTypesControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } var stateDtos = new List <IRoleTypeStateDto>(); foreach (var s in states) { var dto = s is RoleTypeStateDtoWrapper ? (RoleTypeStateDtoWrapper)s : new RoleTypeStateDtoWrapper(s); if (String.IsNullOrWhiteSpace(fields)) { dto.AllFieldsReturned = true; } else { dto.ReturnedFieldsString = fields; } stateDtos.Add(dto); } return(stateDtos); } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public RoleTypeStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version) { try { var idObj = id; var conv = new RoleTypeStateEventDtoConverter(); var se = _roleTypeApplicationService.GetEvent(idObj, version); return(se == null ? null : conv.ToRoleTypeStateEventDto(se)); } catch (Exception ex) { var response = RoleTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Delete(string id, string commandId, string version, string requesterId = default(string)) { try { var value = new DeleteRoleTypeDto(); value.CommandId = commandId; value.RequesterId = requesterId; value.Version = (long)Convert.ChangeType(version, typeof(long)); RoleTypesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _roleTypeApplicationService.When(value as IDeleteRoleType); } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public HttpResponseMessage Post([FromBody] CreateRoleTypeDto value) { try { if (value.RoleTypeId == default(string)) { throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "RoleType"); } _roleTypeApplicationService.When(value as ICreateRoleType); var idObj = value.RoleTypeId; return(Request.CreateResponse <string>(HttpStatusCode.Created, idObj)); } catch (Exception ex) { var response = RoleTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public long GetCount(string filter = null) { try { long count = 0; if (!String.IsNullOrWhiteSpace(filter)) { count = _roleTypeApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new WebApiControllerTypeConverter(), new PropertyTypeResolver() , n => (RoleTypeMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? RoleTypeMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))); } else { count = _roleTypeApplicationService.GetCount(RoleTypesControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())); } return(count); } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteRoleTypeDto value) { try { // /////////////////////////////// if (value.Version != default(long)) { value.CommandType = CommandType.MergePatch; RoleTypesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _roleTypeApplicationService.When(value as IMergePatchRoleType); return; } // /////////////////////////////// RoleTypesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _roleTypeApplicationService.When(value as ICreateRoleType); } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <PropertyMetadataDto> GetMetadataFilteringFields() { try { var filtering = new List <PropertyMetadataDto>(); foreach (var p in RoleTypeMetadata.Instance.Properties) { if (p.IsFilteringProperty) { var pdto = new PropertyMetadataDto(p.Name, p.TypeName, p.IsFilteringProperty, !String.IsNullOrWhiteSpace(p.SourceChainingName) ? p.SourceChainingName : (!String.IsNullOrWhiteSpace(p.DerivedFrom) ? p.DerivedFrom : p.Name)); filtering.Add(pdto); } } return(filtering); } catch (Exception ex) { var response = RoleTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IRoleTypeStateDto Get(string id, string fields = null) { try { var idObj = id; var state = _roleTypeApplicationService.Get(idObj); if (state == null) { return(null); } var stateDto = new RoleTypeStateDtoWrapper(state); if (String.IsNullOrWhiteSpace(fields)) { stateDto.AllFieldsReturned = true; } else { stateDto.ReturnedFieldsString = fields; } return(stateDto); } catch (Exception ex) { var response = RoleTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public Type ResolveTypeByPropertyName(string propertyName) { return(RoleTypesControllerUtils.GetFilterPropertyType(propertyName)); }