public void Patch(string id, [FromBody] MergePatchUomConversionDto value) { try { UomConversionsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _uomConversionApplicationService.When(value as IMergePatchUomConversion); } catch (Exception ex) { var response = UomConversionsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <IUomConversionStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null) { try { IEnumerable <IUomConversionState> states = null; if (!String.IsNullOrWhiteSpace(filter)) { states = _uomConversionApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver() , n => (UomConversionMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? UomConversionMetadata.Instance.FilteringPropertyAliasDictionary[n] : n)) , UomConversionsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } else { states = _uomConversionApplicationService.Get(UomConversionsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()) , UomConversionsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } var stateDtos = new List <IUomConversionStateDto>(); foreach (var s in states) { var dto = s is UomConversionStateDtoWrapper ? (UomConversionStateDtoWrapper)s : new UomConversionStateDtoWrapper(s); if (String.IsNullOrWhiteSpace(fields)) { dto.AllFieldsReturned = true; } else { dto.ReturnedFieldsString = fields; } stateDtos.Add(dto); } return(stateDtos); } catch (Exception ex) { var response = UomConversionsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public UomConversionStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version) { try { var idObj = UomConversionsControllerUtils.ParseIdString(id); var conv = new UomConversionStateEventDtoConverter(); var se = _uomConversionApplicationService.GetEvent(idObj, version); return(se == null ? null : conv.ToUomConversionStateEventDto(se)); } catch (Exception ex) { var response = UomConversionsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Delete(string id, string commandId, string version, string requesterId = default(string)) { try { var value = new DeleteUomConversionDto(); value.CommandId = commandId; value.RequesterId = requesterId; value.Version = (long)Convert.ChangeType(version, typeof(long)); UomConversionsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _uomConversionApplicationService.When(value as IDeleteUomConversion); } catch (Exception ex) { var response = UomConversionsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public HttpResponseMessage Post([FromBody] CreateUomConversionDto value) { try { if (value.UomConversionId == default(UomConversionId)) { throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "UomConversion"); } _uomConversionApplicationService.When(value as ICreateUomConversion); var idObj = value.UomConversionId; return(Request.CreateResponse <UomConversionId>(HttpStatusCode.Created, idObj)); } catch (Exception ex) { var response = UomConversionsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public long GetCount(string filter = null) { try { long count = 0; if (!String.IsNullOrWhiteSpace(filter)) { count = _uomConversionApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver() , n => (UomConversionMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? UomConversionMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))); } else { count = _uomConversionApplicationService.GetCount(UomConversionsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())); } return(count); } catch (Exception ex) { var response = UomConversionsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <PropertyMetadataDto> GetMetadataFilteringFields() { try { var filtering = new List <PropertyMetadataDto>(); foreach (var p in UomConversionMetadata.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 = UomConversionsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteUomConversionDto value) { try { // /////////////////////////////// if (value.Version != default(long)) { value.CommandType = CommandType.MergePatch; UomConversionsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _uomConversionApplicationService.When(value as IMergePatchUomConversion); return; } // /////////////////////////////// UomConversionsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _uomConversionApplicationService.When(value as ICreateUomConversion); } catch (Exception ex) { var response = UomConversionsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IUomConversionStateDto Get(string id, string fields = null) { try { var idObj = UomConversionsControllerUtils.ParseIdString(id); var state = _uomConversionApplicationService.Get(idObj); if (state == null) { return(null); } var stateDto = new UomConversionStateDtoWrapper(state); if (String.IsNullOrWhiteSpace(fields)) { stateDto.AllFieldsReturned = true; } else { stateDto.ReturnedFieldsString = fields; } return(stateDto); } catch (Exception ex) { var response = UomConversionsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }