public void Patch(string id, [FromBody] MergePatchAttributeSetDto value) { try { AttributeSetsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _attributeSetApplicationService.When(value as IMergePatchAttributeSet); } catch (Exception ex) { var response = AttributeSetsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <IAttributeSetStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null) { try { IEnumerable <IAttributeSetState> states = null; if (!String.IsNullOrWhiteSpace(filter)) { states = _attributeSetApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver() , n => (AttributeSetMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? AttributeSetMetadata.Instance.FilteringPropertyAliasDictionary[n] : n)) , AttributeSetsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } else { states = _attributeSetApplicationService.Get(AttributeSetsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()) , AttributeSetsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } var stateDtos = new List <IAttributeSetStateDto>(); foreach (var s in states) { var dto = s is AttributeSetStateDtoWrapper ? (AttributeSetStateDtoWrapper)s : new AttributeSetStateDtoWrapper(s); if (String.IsNullOrWhiteSpace(fields)) { dto.AllFieldsReturned = true; } else { dto.ReturnedFieldsString = fields; } stateDtos.Add(dto); } return(stateDtos); } catch (Exception ex) { var response = AttributeSetsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IAttributeSetStateEvent GetStateEvent(string id, long version) { try { var idObj = id; return(_attributeSetApplicationService.GetStateEvent(idObj, version)); } catch (Exception ex) { var response = AttributeSetsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public AttributeSetStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version) { try { var idObj = id; var conv = new AttributeSetStateEventDtoConverter(); var se = _attributeSetApplicationService.GetEvent(idObj, version); return(se == null ? null : conv.ToAttributeSetStateEventDto(se)); } catch (Exception ex) { var response = AttributeSetsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Delete(string id, string commandId, string version, string requesterId = default(string)) { try { var value = new DeleteAttributeSetDto(); value.CommandId = commandId; value.RequesterId = requesterId; value.Version = (long)Convert.ChangeType(version, typeof(long)); AttributeSetsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _attributeSetApplicationService.When(value as IDeleteAttributeSet); } catch (Exception ex) { var response = AttributeSetsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IAttributeUseStateDto GetAttributeUse(string attributeSetId, string attributeId) { try { var state = (AttributeUseState)_attributeSetApplicationService.GetAttributeUse(attributeSetId, attributeId); if (state == null) { return(null); } var stateDto = new AttributeUseStateDtoWrapper(state); stateDto.AllFieldsReturned = true; return(stateDto); } catch (Exception ex) { var response = AttributeSetsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public HttpResponseMessage Post([FromBody] CreateAttributeSetDto value) { try { if (value.AttributeSetId == default(string)) { throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "AttributeSet"); } _attributeSetApplicationService.When(value as ICreateAttributeSet); var idObj = value.AttributeSetId; return(Request.CreateResponse <string>(HttpStatusCode.Created, idObj)); } catch (Exception ex) { var response = AttributeSetsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <PropertyMetadata> GetMetadataFilteringFields() { try { var filtering = new List <PropertyMetadata>(); foreach (var p in AttributeSetMetadata.Instance.Properties) { if (p.IsFilteringProperty) { filtering.Add(p); } } return(filtering); } catch (Exception ex) { var response = AttributeSetsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public long GetCount(string filter = null) { try { long count = 0; if (!String.IsNullOrWhiteSpace(filter)) { count = _attributeSetApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new WebApiControllerTypeConverter(), new PropertyTypeResolver() , n => (AttributeSetMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? AttributeSetMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))); } else { count = _attributeSetApplicationService.GetCount(AttributeSetsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())); } return(count); } 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 AttributeSetMetadata.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 = AttributeSetsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteAttributeSetDto value) { try { // /////////////////////////////// if (value.Version != default(long)) { value.CommandType = CommandType.MergePatch; AttributeSetsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _attributeSetApplicationService.When(value as IMergePatchAttributeSet); return; } // /////////////////////////////// AttributeSetsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _attributeSetApplicationService.When(value as ICreateAttributeSet); } catch (Exception ex) { var response = AttributeSetsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <IAttributeUseStateDto> GetAttributeUses(string attributeSetId) { try { var states = _attributeSetApplicationService.GetAttributeUses(attributeSetId); if (states == null) { return(null); } var stateDtos = new List <IAttributeUseStateDto>(); foreach (var s in states) { var dto = s is AttributeUseStateDtoWrapper ? (AttributeUseStateDtoWrapper)s : new AttributeUseStateDtoWrapper((IAttributeUseState)s); dto.AllFieldsReturned = true; stateDtos.Add(dto); } return(stateDtos); } catch (Exception ex) { var response = AttributeSetsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IAttributeSetStateDto Get(string id, string fields = null) { try { var idObj = id; var state = _attributeSetApplicationService.Get(idObj); if (state == null) { return(null); } var stateDto = new AttributeSetStateDtoWrapper(state); if (String.IsNullOrWhiteSpace(fields)) { stateDto.AllFieldsReturned = true; } else { stateDto.ReturnedFieldsString = fields; } return(stateDto); } catch (Exception ex) { var response = AttributeSetsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public Type ResolveTypeByPropertyName(string propertyName) { return(AttributeSetsControllerUtils.GetFilterPropertyType(propertyName)); }