public IEnumerable <IMovementConfirmationLineMvoStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null) { try { IEnumerable <IMovementConfirmationLineMvoState> states = null; if (!String.IsNullOrWhiteSpace(filter)) { states = _movementConfirmationLineMvoApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver() , n => (MovementConfirmationLineMvoMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? MovementConfirmationLineMvoMetadata.Instance.FilteringPropertyAliasDictionary[n] : n)) , MovementConfirmationLineMvosControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } else { states = _movementConfirmationLineMvoApplicationService.Get(MovementConfirmationLineMvosControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()) , MovementConfirmationLineMvosControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } var stateDtos = new List <IMovementConfirmationLineMvoStateDto>(); foreach (var s in states) { var dto = s is MovementConfirmationLineMvoStateDtoWrapper ? (MovementConfirmationLineMvoStateDtoWrapper)s : new MovementConfirmationLineMvoStateDtoWrapper(s); if (String.IsNullOrWhiteSpace(fields)) { dto.AllFieldsReturned = true; } else { dto.ReturnedFieldsString = fields; } stateDtos.Add(dto); } return(stateDtos); } catch (Exception ex) { var response = MovementConfirmationLineMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Patch(string id, [FromBody] MergePatchMovementConfirmationLineMvoDto value) { try { MovementConfirmationLineMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _movementConfirmationLineMvoApplicationService.When(value as IMergePatchMovementConfirmationLineMvo); } catch (Exception ex) { var response = MovementConfirmationLineMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public MovementConfirmationLineMvoStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version) { try { var idObj = MovementConfirmationLineMvosControllerUtils.ParseIdString(id); var conv = new MovementConfirmationLineMvoStateEventDtoConverter(); var se = _movementConfirmationLineMvoApplicationService.GetEvent(idObj, version); return(se == null ? null : conv.ToMovementConfirmationLineMvoStateEventDto(se)); } catch (Exception ex) { var response = MovementConfirmationLineMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Delete(string id, string commandId, string version, string requesterId = default(string)) { try { var value = new DeleteMovementConfirmationLineMvoDto(); value.CommandId = commandId; value.RequesterId = requesterId; value.MovementConfirmationVersion = (long)Convert.ChangeType(version, typeof(long)); MovementConfirmationLineMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _movementConfirmationLineMvoApplicationService.When(value as IDeleteMovementConfirmationLineMvo); } catch (Exception ex) { var response = MovementConfirmationLineMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public HttpResponseMessage Post([FromBody] CreateMovementConfirmationLineMvoDto value) { try { if (value.MovementConfirmationLineId == default(MovementConfirmationLineId)) { throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "MovementConfirmationLineMvo"); } _movementConfirmationLineMvoApplicationService.When(value as ICreateMovementConfirmationLineMvo); var idObj = value.MovementConfirmationLineId; return(Request.CreateResponse <MovementConfirmationLineId>(HttpStatusCode.Created, idObj)); } catch (Exception ex) { var response = MovementConfirmationLineMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public long GetCount(string filter = null) { try { long count = 0; if (!String.IsNullOrWhiteSpace(filter)) { count = _movementConfirmationLineMvoApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver() , n => (MovementConfirmationLineMvoMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? MovementConfirmationLineMvoMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))); } else { count = _movementConfirmationLineMvoApplicationService.GetCount(MovementConfirmationLineMvosControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())); } return(count); } catch (Exception ex) { var response = MovementConfirmationLineMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <PropertyMetadataDto> GetMetadataFilteringFields() { try { var filtering = new List <PropertyMetadataDto>(); foreach (var p in MovementConfirmationLineMvoMetadata.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 = MovementConfirmationLineMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteMovementConfirmationLineMvoDto value) { try { // /////////////////////////////// if (value.MovementConfirmationVersion != default(long)) { value.CommandType = CommandType.MergePatch; MovementConfirmationLineMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _movementConfirmationLineMvoApplicationService.When(value as IMergePatchMovementConfirmationLineMvo); return; } // /////////////////////////////// MovementConfirmationLineMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _movementConfirmationLineMvoApplicationService.When(value as ICreateMovementConfirmationLineMvo); } catch (Exception ex) { var response = MovementConfirmationLineMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IMovementConfirmationLineMvoStateDto Get(string id, string fields = null) { try { var idObj = MovementConfirmationLineMvosControllerUtils.ParseIdString(id); var state = _movementConfirmationLineMvoApplicationService.Get(idObj); if (state == null) { return(null); } var stateDto = new MovementConfirmationLineMvoStateDtoWrapper(state); if (String.IsNullOrWhiteSpace(fields)) { stateDto.AllFieldsReturned = true; } else { stateDto.ReturnedFieldsString = fields; } return(stateDto); } catch (Exception ex) { var response = MovementConfirmationLineMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public Type ResolveTypeByPropertyName(string propertyName) { return(MovementConfirmationLineMvosControllerUtils.GetFilterPropertyType(propertyName)); }