Ejemplo n.º 1
0
 public void Patch(string id, [FromBody] MergePatchStatusItemDto value)
 {
     try {
         StatusItemsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _statusItemApplicationService.When(value as IMergePatchStatusItem);
     } catch (Exception ex) { var response = StatusItemsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Ejemplo n.º 2
0
 public IEnumerable <IStatusItemStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null)
 {
     try {
         IEnumerable <IStatusItemState> states = null;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             states = _statusItemApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                                , n => (StatusItemMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? StatusItemMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))
                                                        , StatusItemsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         else
         {
             states = _statusItemApplicationService.Get(StatusItemsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                        , StatusItemsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         var stateDtos = new List <IStatusItemStateDto>();
         foreach (var s in states)
         {
             var dto = s is StatusItemStateDtoWrapper ? (StatusItemStateDtoWrapper)s : new StatusItemStateDtoWrapper(s);
             if (String.IsNullOrWhiteSpace(fields))
             {
                 dto.AllFieldsReturned = true;
             }
             else
             {
                 dto.ReturnedFieldsString = fields;
             }
             stateDtos.Add(dto);
         }
         return(stateDtos);
     } catch (Exception ex) { var response = StatusItemsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Ejemplo n.º 3
0
        public HttpResponseMessage Post([FromBody] CreateStatusItemDto value)
        {
            try {
                if (value.StatusId == default(string))
                {
                    throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "StatusItem");
                }
                _statusItemApplicationService.When(value as ICreateStatusItem);
                var idObj = value.StatusId;

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

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