public void Patch(long?id, [FromBody] MergePatchPickwaveDto value) { try { PickwavesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _pickwaveApplicationService.When(value as IMergePatchPickwave); } catch (Exception ex) { var response = PickwavesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <IPickwaveStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null) { try { IEnumerable <IPickwaveState> states = null; if (!String.IsNullOrWhiteSpace(filter)) { states = _pickwaveApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver() , n => (PickwaveMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? PickwaveMetadata.Instance.FilteringPropertyAliasDictionary[n] : n)) , PickwavesControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } else { states = _pickwaveApplicationService.Get(PickwavesControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()) , PickwavesControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } var stateDtos = new List <IPickwaveStateDto>(); foreach (var s in states) { var dto = s is PickwaveStateDtoWrapper ? (PickwaveStateDtoWrapper)s : new PickwaveStateDtoWrapper(s); if (String.IsNullOrWhiteSpace(fields)) { dto.AllFieldsReturned = true; } else { dto.ReturnedFieldsString = fields; } stateDtos.Add(dto); } return(stateDtos); } catch (Exception ex) { var response = PickwavesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public PickwaveStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(long?id, long version) { try { var idObj = id; var conv = new PickwaveStateEventDtoConverter(); var se = _pickwaveApplicationService.GetEvent(idObj, version); return(se == null ? null : conv.ToPickwaveStateEventDto(se)); } catch (Exception ex) { var response = PickwavesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Delete(long?id, string commandId, string version, string requesterId = default(string)) { try { var value = new DeletePickwaveDto(); value.CommandId = commandId; value.RequesterId = requesterId; value.Version = (long)Convert.ChangeType(version, typeof(long)); PickwavesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _pickwaveApplicationService.When(value as IDeletePickwave); } catch (Exception ex) { var response = PickwavesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public HttpResponseMessage Post([FromBody] CreatePickwaveDto value) { try { if (value.PickwaveId == default(long?)) { throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "Pickwave"); } _pickwaveApplicationService.When(value as ICreatePickwave); var idObj = value.PickwaveId; return(Request.CreateResponse <long?>(HttpStatusCode.Created, idObj)); } catch (Exception ex) { var response = PickwavesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public long GetCount(string filter = null) { try { long count = 0; if (!String.IsNullOrWhiteSpace(filter)) { count = _pickwaveApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new WebApiControllerTypeConverter(), new PropertyTypeResolver() , n => (PickwaveMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? PickwaveMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))); } else { count = _pickwaveApplicationService.GetCount(PickwavesControllerUtils.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 PickwaveMetadata.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 = PickwavesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Put(long?id, [FromBody] CreateOrMergePatchOrDeletePickwaveDto value) { try { // /////////////////////////////// if (value.Version != default(long)) { value.CommandType = CommandType.MergePatch; PickwavesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _pickwaveApplicationService.When(value as IMergePatchPickwave); return; } // /////////////////////////////// PickwavesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _pickwaveApplicationService.When(value as ICreatePickwave); } catch (Exception ex) { var response = PickwavesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IPickwaveStateDto Get(long?id, string fields = null) { try { var idObj = id; var state = _pickwaveApplicationService.Get(idObj); if (state == null) { return(null); } var stateDto = new PickwaveStateDtoWrapper(state); if (String.IsNullOrWhiteSpace(fields)) { stateDto.AllFieldsReturned = true; } else { stateDto.ReturnedFieldsString = fields; } return(stateDto); } catch (Exception ex) { var response = PickwavesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public Type ResolveTypeByPropertyName(string propertyName) { return(PickwavesControllerUtils.GetFilterPropertyType(propertyName)); }