public void Patch(string id, [FromBody] MergePatchWarehouseDto value) { try { WarehousesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _warehouseApplicationService.When(value as IMergePatchWarehouse); } catch (Exception ex) { var response = WarehousesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <IWarehouseStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null) { try { IEnumerable <IWarehouseState> states = null; if (!String.IsNullOrWhiteSpace(filter)) { states = _warehouseApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver()) , WarehousesControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } else { states = _warehouseApplicationService.Get(WarehousesControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()) , WarehousesControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } var stateDtos = new List <IWarehouseStateDto>(); foreach (var s in states) { var dto = s is WarehouseStateDtoWrapper ? (WarehouseStateDtoWrapper)s : new WarehouseStateDtoWrapper(s); if (String.IsNullOrWhiteSpace(fields)) { dto.AllFieldsReturned = true; } else { dto.ReturnedFieldsString = fields; } stateDtos.Add(dto); } return(stateDtos); } catch (Exception ex) { var response = WarehousesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IWarehouseStateEvent GetStateEvent(string id, long version) { try { var idObj = id; return(_warehouseApplicationService.GetStateEvent(idObj, version)); } catch (Exception ex) { var response = WarehousesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public WarehouseStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version) { try { var idObj = id; var conv = new WarehouseStateEventDtoConverter(); var se = _warehouseApplicationService.GetStateEvent(idObj, version); return(se == null ? null : conv.ToWarehouseStateEventDto(se)); } catch (Exception ex) { var response = WarehousesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Delete(string id, string commandId, string version, string requesterId = default(string)) { try { var value = new DeleteWarehouseDto(); value.CommandId = commandId; value.RequesterId = requesterId; value.Version = (long)Convert.ChangeType(version, typeof(long)); WarehousesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _warehouseApplicationService.When(value as IDeleteWarehouse); } catch (Exception ex) { var response = WarehousesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public HttpResponseMessage Post([FromBody] CreateWarehouseDto value) { try { if (value.WarehouseId == default(string)) { throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "Warehouse"); } _warehouseApplicationService.When(value as ICreateWarehouse); var idObj = value.WarehouseId; return(Request.CreateResponse <string>(HttpStatusCode.Created, idObj)); } catch (Exception ex) { var response = WarehousesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <PropertyMetadata> GetMetadataFilteringFields() { try { var filtering = new List <PropertyMetadata>(); foreach (var p in WarehouseMetadata.Instance.Properties) { if (p.IsFilteringProperty) { filtering.Add(p); } } return(filtering); } catch (Exception ex) { var response = WarehousesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public long GetCount(string filter = null) { try { long count = 0; if (!String.IsNullOrWhiteSpace(filter)) { count = _warehouseApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver())); } else { count = _warehouseApplicationService.GetCount(WarehousesControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())); } return(count); } catch (Exception ex) { var response = WarehousesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <PropertyMetadataDto> GetMetadataFilteringFields() { try { var filtering = new List <PropertyMetadataDto>(); foreach (var p in WarehouseMetadata.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 = WarehousesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteWarehouseDto value) { try { // /////////////////////////////// if (value.Version != default(long)) { value.CommandType = CommandType.MergePatch; WarehousesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _warehouseApplicationService.When(value as IMergePatchWarehouse); return; } // /////////////////////////////// WarehousesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _warehouseApplicationService.When(value as ICreateWarehouse); } catch (Exception ex) { var response = WarehousesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IWarehouseStateDto Get(string id, string fields = null) { try { var idObj = id; var state = _warehouseApplicationService.Get(idObj); if (state == null) { return(null); } var stateDto = new WarehouseStateDtoWrapper(state); if (String.IsNullOrWhiteSpace(fields)) { stateDto.AllFieldsReturned = true; } else { stateDto.ReturnedFieldsString = fields; } return(stateDto); } catch (Exception ex) { var response = WarehousesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }