public IEnumerable <IPhysicalInventoryLineMvoStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null) { try { IEnumerable <IPhysicalInventoryLineMvoState> states = null; if (!String.IsNullOrWhiteSpace(filter)) { states = _physicalInventoryLineMvoApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver() , n => (PhysicalInventoryLineMvoMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? PhysicalInventoryLineMvoMetadata.Instance.FilteringPropertyAliasDictionary[n] : n)) , PhysicalInventoryLineMvosControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } else { states = _physicalInventoryLineMvoApplicationService.Get(PhysicalInventoryLineMvosControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()) , PhysicalInventoryLineMvosControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } var stateDtos = new List <IPhysicalInventoryLineMvoStateDto>(); foreach (var s in states) { var dto = s is PhysicalInventoryLineMvoStateDtoWrapper ? (PhysicalInventoryLineMvoStateDtoWrapper)s : new PhysicalInventoryLineMvoStateDtoWrapper(s); if (String.IsNullOrWhiteSpace(fields)) { dto.AllFieldsReturned = true; } else { dto.ReturnedFieldsString = fields; } stateDtos.Add(dto); } return(stateDtos); } catch (Exception ex) { var response = PhysicalInventoryLineMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Patch(string id, [FromBody] MergePatchPhysicalInventoryLineMvoDto value) { try { PhysicalInventoryLineMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _physicalInventoryLineMvoApplicationService.When(value as IMergePatchPhysicalInventoryLineMvo); } catch (Exception ex) { var response = PhysicalInventoryLineMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public PhysicalInventoryLineMvoStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version) { try { var idObj = PhysicalInventoryLineMvosControllerUtils.ParseIdString(id); var conv = new PhysicalInventoryLineMvoStateEventDtoConverter(); var se = _physicalInventoryLineMvoApplicationService.GetEvent(idObj, version); return(se == null ? null : conv.ToPhysicalInventoryLineMvoStateEventDto(se)); } catch (Exception ex) { var response = PhysicalInventoryLineMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Delete(string id, string commandId, string version, string requesterId = default(string)) { try { var value = new DeletePhysicalInventoryLineMvoDto(); value.CommandId = commandId; value.RequesterId = requesterId; value.PhysicalInventoryVersion = (long)Convert.ChangeType(version, typeof(long)); PhysicalInventoryLineMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _physicalInventoryLineMvoApplicationService.When(value as IDeletePhysicalInventoryLineMvo); } catch (Exception ex) { var response = PhysicalInventoryLineMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public HttpResponseMessage Post([FromBody] CreatePhysicalInventoryLineMvoDto value) { try { if (value.PhysicalInventoryLineId == default(PhysicalInventoryLineId)) { throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "PhysicalInventoryLineMvo"); } _physicalInventoryLineMvoApplicationService.When(value as ICreatePhysicalInventoryLineMvo); var idObj = value.PhysicalInventoryLineId; return(Request.CreateResponse <PhysicalInventoryLineId>(HttpStatusCode.Created, idObj)); } catch (Exception ex) { var response = PhysicalInventoryLineMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public long GetCount(string filter = null) { try { long count = 0; if (!String.IsNullOrWhiteSpace(filter)) { count = _physicalInventoryLineMvoApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver() , n => (PhysicalInventoryLineMvoMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? PhysicalInventoryLineMvoMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))); } else { count = _physicalInventoryLineMvoApplicationService.GetCount(PhysicalInventoryLineMvosControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())); } return(count); } catch (Exception ex) { var response = PhysicalInventoryLineMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <PropertyMetadataDto> GetMetadataFilteringFields() { try { var filtering = new List <PropertyMetadataDto>(); foreach (var p in PhysicalInventoryLineMvoMetadata.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 = PhysicalInventoryLineMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Put(string id, [FromBody] CreateOrMergePatchOrDeletePhysicalInventoryLineMvoDto value) { try { // /////////////////////////////// if (value.PhysicalInventoryVersion != default(long)) { value.CommandType = CommandType.MergePatch; PhysicalInventoryLineMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _physicalInventoryLineMvoApplicationService.When(value as IMergePatchPhysicalInventoryLineMvo); return; } // /////////////////////////////// PhysicalInventoryLineMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _physicalInventoryLineMvoApplicationService.When(value as ICreatePhysicalInventoryLineMvo); } catch (Exception ex) { var response = PhysicalInventoryLineMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IPhysicalInventoryLineMvoStateDto Get(string id, string fields = null) { try { var idObj = PhysicalInventoryLineMvosControllerUtils.ParseIdString(id); var state = _physicalInventoryLineMvoApplicationService.Get(idObj); if (state == null) { return(null); } var stateDto = new PhysicalInventoryLineMvoStateDtoWrapper(state); if (String.IsNullOrWhiteSpace(fields)) { stateDto.AllFieldsReturned = true; } else { stateDto.ReturnedFieldsString = fields; } return(stateDto); } catch (Exception ex) { var response = PhysicalInventoryLineMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public Type ResolveTypeByPropertyName(string propertyName) { return(PhysicalInventoryLineMvosControllerUtils.GetFilterPropertyType(propertyName)); }