public void Patch(string id, [FromBody] MergePatchProductCategoryMemberDto value) { try { ProductCategoryMembersControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _productCategoryMemberApplicationService.When(value as IMergePatchProductCategoryMember); } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <IProductCategoryMemberStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null) { try { IEnumerable <IProductCategoryMemberState> states = null; if (!String.IsNullOrWhiteSpace(filter)) { states = _productCategoryMemberApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new WebApiControllerTypeConverter(), new PropertyTypeResolver() , n => (ProductCategoryMemberMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? ProductCategoryMemberMetadata.Instance.FilteringPropertyAliasDictionary[n] : n)) , ProductCategoryMembersControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } else { states = _productCategoryMemberApplicationService.Get(ProductCategoryMembersControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()) , ProductCategoryMembersControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } var stateDtos = new List <IProductCategoryMemberStateDto>(); foreach (var s in states) { var dto = s is ProductCategoryMemberStateDtoWrapper ? (ProductCategoryMemberStateDtoWrapper)s : new ProductCategoryMemberStateDtoWrapper(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 ProductCategoryMemberStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version) { try { var idObj = ProductCategoryMembersControllerUtils.ParseIdString(id); var conv = new ProductCategoryMemberStateEventDtoConverter(); var se = _productCategoryMemberApplicationService.GetEvent(idObj, version); return(se == null ? null : conv.ToProductCategoryMemberStateEventDto(se)); } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public HttpResponseMessage Post([FromBody] CreateProductCategoryMemberDto value) { try { if (value.ProductCategoryMemberId == default(ProductCategoryMemberId)) { throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "ProductCategoryMember"); } _productCategoryMemberApplicationService.When(value as ICreateProductCategoryMember); var idObj = value.ProductCategoryMemberId; return(Request.CreateResponse <ProductCategoryMemberId>(HttpStatusCode.Created, idObj)); } catch (Exception ex) { var response = ProductCategoryMembersControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public long GetCount(string filter = null) { try { long count = 0; if (!String.IsNullOrWhiteSpace(filter)) { count = _productCategoryMemberApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new WebApiControllerTypeConverter(), new PropertyTypeResolver() , n => (ProductCategoryMemberMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? ProductCategoryMemberMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))); } else { count = _productCategoryMemberApplicationService.GetCount(ProductCategoryMembersControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())); } return(count); } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteProductCategoryMemberDto value) { try { // /////////////////////////////// if (value.Version != default(long)) { value.CommandType = CommandType.MergePatch; ProductCategoryMembersControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _productCategoryMemberApplicationService.When(value as IMergePatchProductCategoryMember); return; } // /////////////////////////////// ProductCategoryMembersControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _productCategoryMemberApplicationService.When(value as ICreateProductCategoryMember); } 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 ProductCategoryMemberMetadata.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 = ProductCategoryMembersControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IProductCategoryMemberStateDto Get(string id, string fields = null) { try { var idObj = ProductCategoryMembersControllerUtils.ParseIdString(id); var state = _productCategoryMemberApplicationService.Get(idObj); if (state == null) { return(null); } var stateDto = new ProductCategoryMemberStateDtoWrapper(state); if (String.IsNullOrWhiteSpace(fields)) { stateDto.AllFieldsReturned = true; } else { stateDto.ReturnedFieldsString = fields; } return(stateDto); } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public Type ResolveTypeByPropertyName(string propertyName) { return(ProductCategoryMembersControllerUtils.GetFilterPropertyType(propertyName)); }