public void Patch(string id, [FromBody] MergePatchShipmentTypeDto value) { try { ShipmentTypesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _shipmentTypeApplicationService.When(value as IMergePatchShipmentType); } catch (Exception ex) { var response = ShipmentTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <IShipmentTypeStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null) { try { IEnumerable <IShipmentTypeState> states = null; if (!String.IsNullOrWhiteSpace(filter)) { states = _shipmentTypeApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver() , n => (ShipmentTypeMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? ShipmentTypeMetadata.Instance.FilteringPropertyAliasDictionary[n] : n)) , ShipmentTypesControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } else { states = _shipmentTypeApplicationService.Get(ShipmentTypesControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()) , ShipmentTypesControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } var stateDtos = new List <IShipmentTypeStateDto>(); foreach (var s in states) { var dto = s is ShipmentTypeStateDtoWrapper ? (ShipmentTypeStateDtoWrapper)s : new ShipmentTypeStateDtoWrapper(s); if (String.IsNullOrWhiteSpace(fields)) { dto.AllFieldsReturned = true; } else { dto.ReturnedFieldsString = fields; } stateDtos.Add(dto); } return(stateDtos); } catch (Exception ex) { var response = ShipmentTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public HttpResponseMessage Post([FromBody] CreateShipmentTypeDto value) { try { if (value.ShipmentTypeId == default(string)) { throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "ShipmentType"); } _shipmentTypeApplicationService.When(value as ICreateShipmentType); var idObj = value.ShipmentTypeId; return(Request.CreateResponse <string>(HttpStatusCode.Created, idObj)); } catch (Exception ex) { var response = ShipmentTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public long GetCount(string filter = null) { try { long count = 0; if (!String.IsNullOrWhiteSpace(filter)) { count = _shipmentTypeApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new WebApiControllerTypeConverter(), new PropertyTypeResolver() , n => (ShipmentTypeMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? ShipmentTypeMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))); } else { count = _shipmentTypeApplicationService.GetCount(ShipmentTypesControllerUtils.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 ShipmentTypeMetadata.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 = ShipmentTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteShipmentTypeDto value) { try { // /////////////////////////////// if (value.Version != default(long)) { value.CommandType = CommandType.MergePatch; ShipmentTypesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _shipmentTypeApplicationService.When(value as IMergePatchShipmentType); return; } // /////////////////////////////// ShipmentTypesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _shipmentTypeApplicationService.When(value as ICreateShipmentType); } catch (Exception ex) { var response = ShipmentTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IShipmentTypeStateDto Get(string id, string fields = null) { try { var idObj = id; var state = _shipmentTypeApplicationService.Get(idObj); if (state == null) { return(null); } var stateDto = new ShipmentTypeStateDtoWrapper(state); if (String.IsNullOrWhiteSpace(fields)) { stateDto.AllFieldsReturned = true; } else { stateDto.ReturnedFieldsString = fields; } return(stateDto); } catch (Exception ex) { var response = ShipmentTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public Type ResolveTypeByPropertyName(string propertyName) { return(ShipmentTypesControllerUtils.GetFilterPropertyType(propertyName)); }