public IEnumerable <IAttributeAliasMvoStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null) { try { IEnumerable <IAttributeAliasMvoState> states = null; if (!String.IsNullOrWhiteSpace(filter)) { states = _attributeAliasMvoApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver() , n => (AttributeAliasMvoMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? AttributeAliasMvoMetadata.Instance.FilteringPropertyAliasDictionary[n] : n)) , AttributeAliasMvosControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } else { states = _attributeAliasMvoApplicationService.Get(AttributeAliasMvosControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()) , AttributeAliasMvosControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } var stateDtos = new List <IAttributeAliasMvoStateDto>(); foreach (var s in states) { var dto = s is AttributeAliasMvoStateDtoWrapper ? (AttributeAliasMvoStateDtoWrapper)s : new AttributeAliasMvoStateDtoWrapper(s); if (String.IsNullOrWhiteSpace(fields)) { dto.AllFieldsReturned = true; } else { dto.ReturnedFieldsString = fields; } stateDtos.Add(dto); } return(stateDtos); } catch (Exception ex) { var response = AttributeAliasMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Patch(string id, [FromBody] MergePatchAttributeAliasMvoDto value) { try { AttributeAliasMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _attributeAliasMvoApplicationService.When(value as IMergePatchAttributeAliasMvo); } catch (Exception ex) { var response = AttributeAliasMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public AttributeAliasMvoStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version) { try { var idObj = AttributeAliasMvosControllerUtils.ParseIdString(id); var conv = new AttributeAliasMvoStateEventDtoConverter(); var se = _attributeAliasMvoApplicationService.GetEvent(idObj, version); return(se == null ? null : conv.ToAttributeAliasMvoStateEventDto(se)); } catch (Exception ex) { var response = AttributeAliasMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Delete(string id, string commandId, string version, string requesterId = default(string)) { try { var value = new DeleteAttributeAliasMvoDto(); value.CommandId = commandId; value.RequesterId = requesterId; value.AttributeVersion = (long)Convert.ChangeType(version, typeof(long)); AttributeAliasMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _attributeAliasMvoApplicationService.When(value as IDeleteAttributeAliasMvo); } catch (Exception ex) { var response = AttributeAliasMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public HttpResponseMessage Post([FromBody] CreateAttributeAliasMvoDto value) { try { if (value.AttributeAliasId == default(AttributeAliasId)) { throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "AttributeAliasMvo"); } _attributeAliasMvoApplicationService.When(value as ICreateAttributeAliasMvo); var idObj = value.AttributeAliasId; return(Request.CreateResponse <AttributeAliasId>(HttpStatusCode.Created, idObj)); } catch (Exception ex) { var response = AttributeAliasMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public long GetCount(string filter = null) { try { long count = 0; if (!String.IsNullOrWhiteSpace(filter)) { count = _attributeAliasMvoApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver() , n => (AttributeAliasMvoMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? AttributeAliasMvoMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))); } else { count = _attributeAliasMvoApplicationService.GetCount(AttributeAliasMvosControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())); } return(count); } catch (Exception ex) { var response = AttributeAliasMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <PropertyMetadataDto> GetMetadataFilteringFields() { try { var filtering = new List <PropertyMetadataDto>(); foreach (var p in AttributeAliasMvoMetadata.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 = AttributeAliasMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteAttributeAliasMvoDto value) { try { // /////////////////////////////// if (value.AttributeVersion != default(long)) { value.CommandType = CommandType.MergePatch; AttributeAliasMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _attributeAliasMvoApplicationService.When(value as IMergePatchAttributeAliasMvo); return; } // /////////////////////////////// AttributeAliasMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _attributeAliasMvoApplicationService.When(value as ICreateAttributeAliasMvo); } catch (Exception ex) { var response = AttributeAliasMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IAttributeAliasMvoStateDto Get(string id, string fields = null) { try { var idObj = AttributeAliasMvosControllerUtils.ParseIdString(id); var state = _attributeAliasMvoApplicationService.Get(idObj); if (state == null) { return(null); } var stateDto = new AttributeAliasMvoStateDtoWrapper(state); if (String.IsNullOrWhiteSpace(fields)) { stateDto.AllFieldsReturned = true; } else { stateDto.ReturnedFieldsString = fields; } return(stateDto); } catch (Exception ex) { var response = AttributeAliasMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public Type ResolveTypeByPropertyName(string propertyName) { return(AttributeAliasMvosControllerUtils.GetFilterPropertyType(propertyName)); }