public IEnumerable <IDamageHandlingMethodStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null)
 {
     try {
         IEnumerable <IDamageHandlingMethodState> states = null;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             states = _damageHandlingMethodApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new WebApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                                          , n => (DamageHandlingMethodMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? DamageHandlingMethodMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))
                                                                  , DamageHandlingMethodsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         else
         {
             states = _damageHandlingMethodApplicationService.Get(DamageHandlingMethodsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                                  , DamageHandlingMethodsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         var stateDtos = new List <IDamageHandlingMethodStateDto>();
         foreach (var s in states)
         {
             var dto = s is DamageHandlingMethodStateDtoWrapper ? (DamageHandlingMethodStateDtoWrapper)s : new DamageHandlingMethodStateDtoWrapper(s);
             if (String.IsNullOrWhiteSpace(fields))
             {
                 dto.AllFieldsReturned = true;
             }
             else
             {
                 dto.ReturnedFieldsString = fields;
             }
             stateDtos.Add(dto);
         }
         return(stateDtos);
     } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
 public void Patch(string id, [FromBody] MergePatchDamageHandlingMethodDto value)
 {
     try {
         DamageHandlingMethodsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _damageHandlingMethodApplicationService.When(value as IMergePatchDamageHandlingMethod);
     } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
 public void Delete(string id, string commandId, string version, string requesterId = default(string))
 {
     try {
         var value = new DeleteDamageHandlingMethodDto();
         value.CommandId   = commandId;
         value.RequesterId = requesterId;
         value.Version     = (long)Convert.ChangeType(version, typeof(long));
         DamageHandlingMethodsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _damageHandlingMethodApplicationService.When(value as IDeleteDamageHandlingMethod);
     } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Esempio n. 4
0
        public HttpResponseMessage Post([FromBody] CreateDamageHandlingMethodDto value)
        {
            try {
                if (value.DamageHandlingMethodId == default(string))
                {
                    throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "DamageHandlingMethod");
                }
                _damageHandlingMethodApplicationService.When(value as ICreateDamageHandlingMethod);
                var idObj = value.DamageHandlingMethodId;

                return(Request.CreateResponse <string>(HttpStatusCode.Created, idObj));
            } catch (Exception ex) { var response = DamageHandlingMethodsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
 public long GetCount(string filter = null)
 {
     try {
         long count = 0;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             count = _damageHandlingMethodApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new WebApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                                              , n => (DamageHandlingMethodMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? DamageHandlingMethodMetadata.Instance.FilteringPropertyAliasDictionary[n] : n)));
         }
         else
         {
             count = _damageHandlingMethodApplicationService.GetCount(DamageHandlingMethodsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()));
         }
         return(count);
     } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
        public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteDamageHandlingMethodDto value)
        {
            try {
                // ///////////////////////////////
                if (value.Version != default(long))
                {
                    value.CommandType = CommandType.MergePatch;
                    DamageHandlingMethodsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                    _damageHandlingMethodApplicationService.When(value as IMergePatchDamageHandlingMethod);
                    return;
                }
                // ///////////////////////////////

                DamageHandlingMethodsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                _damageHandlingMethodApplicationService.When(value as ICreateDamageHandlingMethod);
            } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
Esempio n. 7
0
 public IEnumerable <PropertyMetadataDto> GetMetadataFilteringFields()
 {
     try {
         var filtering = new List <PropertyMetadataDto>();
         foreach (var p in DamageHandlingMethodMetadata.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 = DamageHandlingMethodsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Esempio n. 8
0
 public IDamageHandlingMethodStateDto Get(string id, string fields = null)
 {
     try {
         var idObj = id;
         var state = _damageHandlingMethodApplicationService.Get(idObj);
         if (state == null)
         {
             return(null);
         }
         var stateDto = new DamageHandlingMethodStateDtoWrapper(state);
         if (String.IsNullOrWhiteSpace(fields))
         {
             stateDto.AllFieldsReturned = true;
         }
         else
         {
             stateDto.ReturnedFieldsString = fields;
         }
         return(stateDto);
     } catch (Exception ex) { var response = DamageHandlingMethodsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
 public Type ResolveTypeByPropertyName(string propertyName)
 {
     return(DamageHandlingMethodsControllerUtils.GetFilterPropertyType(propertyName));
 }