public IEnumerable <IShipmentStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null) { try { IEnumerable <IShipmentState> states = null; if (!String.IsNullOrWhiteSpace(filter)) { states = _shipmentApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver() , n => (ShipmentMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? ShipmentMetadata.Instance.FilteringPropertyAliasDictionary[n] : n)) , ShipmentsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } else { states = _shipmentApplicationService.Get(ShipmentsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()) , ShipmentsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } var stateDtos = new List <IShipmentStateDto>(); foreach (var s in states) { var dto = s is ShipmentStateDtoWrapper ? (ShipmentStateDtoWrapper)s : new ShipmentStateDtoWrapper(s); if (String.IsNullOrWhiteSpace(fields)) { dto.AllFieldsReturned = true; } else { dto.ReturnedFieldsString = fields; } stateDtos.Add(dto); } return(stateDtos); } catch (Exception ex) { var response = ShipmentsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Patch(string id, [FromBody] MergePatchShipmentDto value) { try { ShipmentsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _shipmentApplicationService.When(value as IMergePatchShipment); } catch (Exception ex) { var response = ShipmentsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public ShipmentStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version) { try { var idObj = id; var conv = new ShipmentStateEventDtoConverter(); var se = _shipmentApplicationService.GetEvent(idObj, version); return(se == null ? null : conv.ToShipmentStateEventDto(se)); } catch (Exception ex) { var response = ShipmentsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IItemIssuanceStateDto GetItemIssuance(string shipmentId, string itemIssuanceSeqId) { try { var state = (ItemIssuanceState)_shipmentApplicationService.GetItemIssuance(shipmentId, itemIssuanceSeqId); if (state == null) { return(null); } var stateDto = new ItemIssuanceStateDtoWrapper(state); stateDto.AllFieldsReturned = true; return(stateDto); } catch (Exception ex) { var response = ShipmentsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IShipmentReceiptImageStateDto GetShipmentReceiptImage(string shipmentId, string shipmentReceiptReceiptSeqId, string sequenceId) { try { var state = (ShipmentReceiptImageState)_shipmentApplicationService.GetShipmentReceiptImage(shipmentId, shipmentReceiptReceiptSeqId, sequenceId); if (state == null) { return(null); } var stateDto = new ShipmentReceiptImageStateDtoWrapper(state); stateDto.AllFieldsReturned = true; return(stateDto); } catch (Exception ex) { var response = ShipmentsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public HttpResponseMessage Post([FromBody] CreateShipmentDto value) { try { if (value.ShipmentId == default(string)) { throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "Shipment"); } _shipmentApplicationService.When(value as ICreateShipment); var idObj = value.ShipmentId; return(Request.CreateResponse <string>(HttpStatusCode.Created, idObj)); } catch (Exception ex) { var response = ShipmentsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void ConfirmAllItemsIssued(string id, [FromBody] ShipmentCommandDtos.ConfirmAllItemsIssuedRequestContent content) { try { var cmd = content.ToConfirmAllItemsIssued(); var idObj = id; if (cmd.ShipmentId == null) { cmd.ShipmentId = idObj; } else if (!cmd.ShipmentId.Equals(idObj)) { throw DomainError.Named("inconsistentId", "Argument Id {0} NOT equals body Id {1}", id, cmd.ShipmentId); } _shipmentApplicationService.When(cmd); } catch (Exception ex) { var response = ShipmentsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public long GetCount(string filter = null) { try { long count = 0; if (!String.IsNullOrWhiteSpace(filter)) { count = _shipmentApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new WebApiControllerTypeConverter(), new PropertyTypeResolver() , n => (ShipmentMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? ShipmentMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))); } else { count = _shipmentApplicationService.GetCount(ShipmentsControllerUtils.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 ShipmentMetadata.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 = ShipmentsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteShipmentDto value) { try { // /////////////////////////////// if (value.Version != default(long)) { value.CommandType = CommandType.MergePatch; ShipmentsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _shipmentApplicationService.When(value as IMergePatchShipment); return; } // /////////////////////////////// ShipmentsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _shipmentApplicationService.When(value as ICreateShipment); } catch (Exception ex) { var response = ShipmentsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <IItemIssuanceStateDto> GetItemIssuances(string shipmentId) { try { var states = _shipmentApplicationService.GetItemIssuances(shipmentId); if (states == null) { return(null); } var stateDtos = new List <IItemIssuanceStateDto>(); foreach (var s in states) { var dto = s is ItemIssuanceStateDtoWrapper ? (ItemIssuanceStateDtoWrapper)s : new ItemIssuanceStateDtoWrapper((IItemIssuanceState)s); dto.AllFieldsReturned = true; stateDtos.Add(dto); } return(stateDtos); } catch (Exception ex) { var response = ShipmentsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IShipmentStateDto Get(string id, string fields = null) { try { var idObj = id; var state = _shipmentApplicationService.Get(idObj); if (state == null) { return(null); } var stateDto = new ShipmentStateDtoWrapper(state); if (String.IsNullOrWhiteSpace(fields)) { stateDto.AllFieldsReturned = true; } else { stateDto.ReturnedFieldsString = fields; } return(stateDto); } catch (Exception ex) { var response = ShipmentsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public Type ResolveTypeByPropertyName(string propertyName) { return(ShipmentsControllerUtils.GetFilterPropertyType(propertyName)); }