public IEnumerable <IGoodIdentificationMvoStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null) { try { IEnumerable <IGoodIdentificationMvoState> states = null; if (!String.IsNullOrWhiteSpace(filter)) { states = _goodIdentificationMvoApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver() , n => (GoodIdentificationMvoMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? GoodIdentificationMvoMetadata.Instance.FilteringPropertyAliasDictionary[n] : n)) , GoodIdentificationMvosControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } else { states = _goodIdentificationMvoApplicationService.Get(GoodIdentificationMvosControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()) , GoodIdentificationMvosControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } var stateDtos = new List <IGoodIdentificationMvoStateDto>(); foreach (var s in states) { var dto = s is GoodIdentificationMvoStateDtoWrapper ? (GoodIdentificationMvoStateDtoWrapper)s : new GoodIdentificationMvoStateDtoWrapper(s); if (String.IsNullOrWhiteSpace(fields)) { dto.AllFieldsReturned = true; } else { dto.ReturnedFieldsString = fields; } stateDtos.Add(dto); } return(stateDtos); } catch (Exception ex) { var response = GoodIdentificationMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Patch(string id, [FromBody] MergePatchGoodIdentificationMvoDto value) { try { GoodIdentificationMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _goodIdentificationMvoApplicationService.When(value as IMergePatchGoodIdentificationMvo); } catch (Exception ex) { var response = GoodIdentificationMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public GoodIdentificationMvoStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version) { try { var idObj = GoodIdentificationMvosControllerUtils.ParseIdString(id); var conv = new GoodIdentificationMvoStateEventDtoConverter(); var se = _goodIdentificationMvoApplicationService.GetEvent(idObj, version); return(se == null ? null : conv.ToGoodIdentificationMvoStateEventDto(se)); } catch (Exception ex) { var response = GoodIdentificationMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Delete(string id, string commandId, string version, string requesterId = default(string)) { try { var value = new DeleteGoodIdentificationMvoDto(); value.CommandId = commandId; value.RequesterId = requesterId; value.ProductVersion = (long)Convert.ChangeType(version, typeof(long)); GoodIdentificationMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _goodIdentificationMvoApplicationService.When(value as IDeleteGoodIdentificationMvo); } catch (Exception ex) { var response = GoodIdentificationMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public HttpResponseMessage Post([FromBody] CreateGoodIdentificationMvoDto value) { try { if (value.ProductGoodIdentificationId == default(ProductGoodIdentificationId)) { throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "GoodIdentificationMvo"); } _goodIdentificationMvoApplicationService.When(value as ICreateGoodIdentificationMvo); var idObj = value.ProductGoodIdentificationId; return(Request.CreateResponse <ProductGoodIdentificationId>(HttpStatusCode.Created, idObj)); } catch (Exception ex) { var response = GoodIdentificationMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public long GetCount(string filter = null) { try { long count = 0; if (!String.IsNullOrWhiteSpace(filter)) { count = _goodIdentificationMvoApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver() , n => (GoodIdentificationMvoMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? GoodIdentificationMvoMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))); } else { count = _goodIdentificationMvoApplicationService.GetCount(GoodIdentificationMvosControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())); } return(count); } catch (Exception ex) { var response = GoodIdentificationMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <PropertyMetadataDto> GetMetadataFilteringFields() { try { var filtering = new List <PropertyMetadataDto>(); foreach (var p in GoodIdentificationMvoMetadata.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 = GoodIdentificationMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteGoodIdentificationMvoDto value) { try { // /////////////////////////////// if (value.ProductVersion != default(long)) { value.CommandType = CommandType.MergePatch; GoodIdentificationMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _goodIdentificationMvoApplicationService.When(value as IMergePatchGoodIdentificationMvo); return; } // /////////////////////////////// GoodIdentificationMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _goodIdentificationMvoApplicationService.When(value as ICreateGoodIdentificationMvo); } catch (Exception ex) { var response = GoodIdentificationMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IGoodIdentificationMvoStateDto Get(string id, string fields = null) { try { var idObj = GoodIdentificationMvosControllerUtils.ParseIdString(id); var state = _goodIdentificationMvoApplicationService.Get(idObj); if (state == null) { return(null); } var stateDto = new GoodIdentificationMvoStateDtoWrapper(state); if (String.IsNullOrWhiteSpace(fields)) { stateDto.AllFieldsReturned = true; } else { stateDto.ReturnedFieldsString = fields; } return(stateDto); } catch (Exception ex) { var response = GoodIdentificationMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public Type ResolveTypeByPropertyName(string propertyName) { return(GoodIdentificationMvosControllerUtils.GetFilterPropertyType(propertyName)); }