public void Patch(string id, [FromBody] MergePatchAttributeDto value) { try { AttributesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _attributeApplicationService.When(value as IMergePatchAttribute); } catch (Exception ex) { var response = AttributesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <AttributeStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null) { try { IEnumerable <IAttributeState> states = null; if (!String.IsNullOrWhiteSpace(filter)) { states = _attributeApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver()) , AttributesControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } else { states = _attributeApplicationService.Get(AttributesControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()) , AttributesControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } var stateDtos = new List <AttributeStateDto>(); foreach (var s in states) { var dto = s is AttributeStateDto ? (AttributeStateDto)s : new AttributeStateDto((AttributeState)s); if (String.IsNullOrWhiteSpace(fields)) { dto.AllFieldsReturned = true; } else { dto.ReturnedFieldsString = fields; } stateDtos.Add(dto); } return(stateDtos); } catch (Exception ex) { var response = AttributesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IAttributeStateEvent GetStateEvent(string id, long version) { try { var idObj = id; return(_attributeApplicationService.GetStateEvent(idObj, version)); } catch (Exception ex) { var response = AttributesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public AttributeStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version) { try { var idObj = id; var conv = new AttributeStateEventDtoConverter(); var se = _attributeApplicationService.GetEvent(idObj, version); return(se == null ? null : conv.ToAttributeStateEventDto(se)); } catch (Exception ex) { var response = AttributesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Delete(string id, string commandId, string version, string requesterId = default(string)) { try { var value = new DeleteAttributeDto(); value.CommandId = commandId; value.RequesterId = requesterId; value.Version = (long)Convert.ChangeType(version, typeof(long)); AttributesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _attributeApplicationService.When(value as IDeleteAttribute); } catch (Exception ex) { var response = AttributesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public AttributeValueStateDto GetAttributeValue(string attributeId, string value) { try { var state = (AttributeValueState)_attributeApplicationService.GetAttributeValue(attributeId, value); if (state == null) { return(null); } var stateDto = new AttributeValueStateDto(state); stateDto.AllFieldsReturned = true; return(stateDto); } catch (Exception ex) { var response = AttributesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public HttpResponseMessage Post([FromBody] CreateAttributeDto value) { try { if (value.AttributeId == default(string)) { throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "Attribute"); } _attributeApplicationService.When(value as ICreateAttribute); var idObj = value.AttributeId; return(Request.CreateResponse <string>(HttpStatusCode.Created, idObj)); } catch (Exception ex) { var response = AttributesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <PropertyMetadata> GetMetadataFilteringFields() { try { var filtering = new List <PropertyMetadata>(); foreach (var p in AttributeMetadata.Instance.Properties) { if (p.IsFilteringProperty) { filtering.Add(p); } } return(filtering); } catch (Exception ex) { var response = AttributesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public long GetCount(string filter = null) { try { long count = 0; if (!String.IsNullOrWhiteSpace(filter)) { count = _attributeApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver())); } else { count = _attributeApplicationService.GetCount(AttributesControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())); } return(count); } catch (Exception ex) { var response = AttributesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <PropertyMetadataDto> GetMetadataFilteringFields() { try { var filtering = new List <PropertyMetadataDto>(); foreach (var p in AttributeMetadata.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 = AttributesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteAttributeDto value) { try { // /////////////////////////////// if (value.Version != default(long)) { value.CommandType = CommandType.MergePatch; AttributesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _attributeApplicationService.When(value as IMergePatchAttribute); return; } // /////////////////////////////// AttributesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _attributeApplicationService.When(value as ICreateAttribute); } catch (Exception ex) { var response = AttributesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <IAttributeAliasStateDto> GetAttributeAlias(string attributeId) { try { var states = _attributeApplicationService.GetAttributeAlias(attributeId); if (states == null) { return(null); } var stateDtos = new List <IAttributeAliasStateDto>(); foreach (var s in states) { var dto = s is AttributeAliasStateDtoWrapper ? (AttributeAliasStateDtoWrapper)s : new AttributeAliasStateDtoWrapper((AttributeAliasState)s); dto.AllFieldsReturned = true; stateDtos.Add(dto); } return(stateDtos); } catch (Exception ex) { var response = AttributesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public AttributeStateDto Get(string id, string fields = null) { try { var idObj = id; var state = (AttributeState)_attributeApplicationService.Get(idObj); if (state == null) { return(null); } var stateDto = new AttributeStateDto(state); if (String.IsNullOrWhiteSpace(fields)) { stateDto.AllFieldsReturned = true; } else { stateDto.ReturnedFieldsString = fields; } return(stateDto); } catch (Exception ex) { var response = AttributesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public string GetNextId() { try { return(_attributeIdGenerator.GetNextId()); } catch (Exception ex) { var response = AttributesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }