Ejemplo n.º 1
0
 public IEnumerable <IMovementTypeStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null)
 {
     try {
         IEnumerable <IMovementTypeState> states = null;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             states = _movementTypeApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                                  , n => (MovementTypeMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? MovementTypeMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))
                                                          , MovementTypesControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         else
         {
             states = _movementTypeApplicationService.Get(MovementTypesControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                          , MovementTypesControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         var stateDtos = new List <IMovementTypeStateDto>();
         foreach (var s in states)
         {
             var dto = s is MovementTypeStateDtoWrapper ? (MovementTypeStateDtoWrapper)s : new MovementTypeStateDtoWrapper(s);
             if (String.IsNullOrWhiteSpace(fields))
             {
                 dto.AllFieldsReturned = true;
             }
             else
             {
                 dto.ReturnedFieldsString = fields;
             }
             stateDtos.Add(dto);
         }
         return(stateDtos);
     } catch (Exception ex) { var response = MovementTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Ejemplo n.º 2
0
 public void Patch(string id, [FromBody] MergePatchMovementTypeDto value)
 {
     try {
         MovementTypesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _movementTypeApplicationService.When(value as IMergePatchMovementType);
     } catch (Exception ex) { var response = MovementTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Ejemplo n.º 3
0
 public void Delete(string id, string commandId, string version, string requesterId = default(string))
 {
     try {
         var value = new DeleteMovementTypeDto();
         value.CommandId   = commandId;
         value.RequesterId = requesterId;
         value.Version     = (long)Convert.ChangeType(version, typeof(long));
         MovementTypesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _movementTypeApplicationService.When(value as IDeleteMovementType);
     } catch (Exception ex) { var response = MovementTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Ejemplo n.º 4
0
        public HttpResponseMessage Post([FromBody] CreateMovementTypeDto value)
        {
            try {
                if (value.MovementTypeId == default(string))
                {
                    throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "MovementType");
                }
                _movementTypeApplicationService.When(value as ICreateMovementType);
                var idObj = value.MovementTypeId;

                return(Request.CreateResponse <string>(HttpStatusCode.Created, idObj));
            } catch (Exception ex) { var response = MovementTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
Ejemplo n.º 5
0
 public long GetCount(string filter = null)
 {
     try {
         long count = 0;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             count = _movementTypeApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new WebApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                                      , n => (MovementTypeMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? MovementTypeMetadata.Instance.FilteringPropertyAliasDictionary[n] : n)));
         }
         else
         {
             count = _movementTypeApplicationService.GetCount(MovementTypesControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()));
         }
         return(count);
     } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Ejemplo n.º 6
0
 public IEnumerable <PropertyMetadataDto> GetMetadataFilteringFields()
 {
     try {
         var filtering = new List <PropertyMetadataDto>();
         foreach (var p in MovementTypeMetadata.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 = MovementTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Ejemplo n.º 7
0
        public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteMovementTypeDto value)
        {
            try {
                // ///////////////////////////////
                if (value.Version != default(long))
                {
                    value.CommandType = CommandType.MergePatch;
                    MovementTypesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                    _movementTypeApplicationService.When(value as IMergePatchMovementType);
                    return;
                }
                // ///////////////////////////////

                MovementTypesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                _movementTypeApplicationService.When(value as ICreateMovementType);
            } catch (Exception ex) { var response = MovementTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
Ejemplo n.º 8
0
 public IMovementTypeStateDto Get(string id, string fields = null)
 {
     try {
         var idObj = id;
         var state = _movementTypeApplicationService.Get(idObj);
         if (state == null)
         {
             return(null);
         }
         var stateDto = new MovementTypeStateDtoWrapper(state);
         if (String.IsNullOrWhiteSpace(fields))
         {
             stateDto.AllFieldsReturned = true;
         }
         else
         {
             stateDto.ReturnedFieldsString = fields;
         }
         return(stateDto);
     } catch (Exception ex) { var response = MovementTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Ejemplo n.º 9
0
 public Type ResolveTypeByPropertyName(string propertyName)
 {
     return(MovementTypesControllerUtils.GetFilterPropertyType(propertyName));
 }