public void Patch(string id, [FromBody] MergePatchShipmentMethodTypeDto value) { try { ShipmentMethodTypesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _shipmentMethodTypeApplicationService.When(value as IMergePatchShipmentMethodType); } catch (Exception ex) { var response = ShipmentMethodTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <IShipmentMethodTypeStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null) { try { IEnumerable <IShipmentMethodTypeState> states = null; if (!String.IsNullOrWhiteSpace(filter)) { states = _shipmentMethodTypeApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver() , n => (ShipmentMethodTypeMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? ShipmentMethodTypeMetadata.Instance.FilteringPropertyAliasDictionary[n] : n)) , ShipmentMethodTypesControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } else { states = _shipmentMethodTypeApplicationService.Get(ShipmentMethodTypesControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()) , ShipmentMethodTypesControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } var stateDtos = new List <IShipmentMethodTypeStateDto>(); foreach (var s in states) { var dto = s is ShipmentMethodTypeStateDtoWrapper ? (ShipmentMethodTypeStateDtoWrapper)s : new ShipmentMethodTypeStateDtoWrapper(s); if (String.IsNullOrWhiteSpace(fields)) { dto.AllFieldsReturned = true; } else { dto.ReturnedFieldsString = fields; } stateDtos.Add(dto); } return(stateDtos); } catch (Exception ex) { var response = ShipmentMethodTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public ShipmentMethodTypeStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version) { try { var idObj = id; var conv = new ShipmentMethodTypeStateEventDtoConverter(); var se = _shipmentMethodTypeApplicationService.GetEvent(idObj, version); return(se == null ? null : conv.ToShipmentMethodTypeStateEventDto(se)); } catch (Exception ex) { var response = ShipmentMethodTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Delete(string id, string commandId, string version, string requesterId = default(string)) { try { var value = new DeleteShipmentMethodTypeDto(); value.CommandId = commandId; value.RequesterId = requesterId; value.Version = (long)Convert.ChangeType(version, typeof(long)); ShipmentMethodTypesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _shipmentMethodTypeApplicationService.When(value as IDeleteShipmentMethodType); } catch (Exception ex) { var response = ShipmentMethodTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public HttpResponseMessage Post([FromBody] CreateShipmentMethodTypeDto value) { try { if (value.ShipmentMethodTypeId == default(string)) { throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "ShipmentMethodType"); } _shipmentMethodTypeApplicationService.When(value as ICreateShipmentMethodType); var idObj = value.ShipmentMethodTypeId; return(Request.CreateResponse <string>(HttpStatusCode.Created, idObj)); } catch (Exception ex) { var response = ShipmentMethodTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public long GetCount(string filter = null) { try { long count = 0; if (!String.IsNullOrWhiteSpace(filter)) { count = _shipmentMethodTypeApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver() , n => (ShipmentMethodTypeMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? ShipmentMethodTypeMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))); } else { count = _shipmentMethodTypeApplicationService.GetCount(ShipmentMethodTypesControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())); } return(count); } catch (Exception ex) { var response = ShipmentMethodTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <PropertyMetadataDto> GetMetadataFilteringFields() { try { var filtering = new List <PropertyMetadataDto>(); foreach (var p in ShipmentMethodTypeMetadata.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 = ShipmentMethodTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteShipmentMethodTypeDto value) { try { // /////////////////////////////// if (value.Version != default(long)) { value.CommandType = CommandType.MergePatch; ShipmentMethodTypesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _shipmentMethodTypeApplicationService.When(value as IMergePatchShipmentMethodType); return; } // /////////////////////////////// ShipmentMethodTypesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _shipmentMethodTypeApplicationService.When(value as ICreateShipmentMethodType); } catch (Exception ex) { var response = ShipmentMethodTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IShipmentMethodTypeStateDto Get(string id, string fields = null) { try { var idObj = id; var state = _shipmentMethodTypeApplicationService.Get(idObj); if (state == null) { return(null); } var stateDto = new ShipmentMethodTypeStateDtoWrapper(state); if (String.IsNullOrWhiteSpace(fields)) { stateDto.AllFieldsReturned = true; } else { stateDto.ReturnedFieldsString = fields; } return(stateDto); } catch (Exception ex) { var response = ShipmentMethodTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }