예제 #1
0
 public IEnumerable <IUomTypeStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null)
 {
     try {
         IEnumerable <IUomTypeState> states = null;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             states = _uomTypeApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                             , n => (UomTypeMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? UomTypeMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))
                                                     , UomTypesControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         else
         {
             states = _uomTypeApplicationService.Get(UomTypesControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                     , UomTypesControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         var stateDtos = new List <IUomTypeStateDto>();
         foreach (var s in states)
         {
             var dto = s is UomTypeStateDtoWrapper ? (UomTypeStateDtoWrapper)s : new UomTypeStateDtoWrapper(s);
             if (String.IsNullOrWhiteSpace(fields))
             {
                 dto.AllFieldsReturned = true;
             }
             else
             {
                 dto.ReturnedFieldsString = fields;
             }
             stateDtos.Add(dto);
         }
         return(stateDtos);
     } catch (Exception ex) { var response = UomTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
예제 #2
0
 public void Patch(string id, [FromBody] MergePatchUomTypeDto value)
 {
     try {
         UomTypesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _uomTypeApplicationService.When(value as IMergePatchUomType);
     } catch (Exception ex) { var response = UomTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
예제 #3
0
 public void Delete(string id, string commandId, string version, string requesterId = default(string))
 {
     try {
         var value = new DeleteUomTypeDto();
         value.CommandId   = commandId;
         value.RequesterId = requesterId;
         value.Version     = (long)Convert.ChangeType(version, typeof(long));
         UomTypesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _uomTypeApplicationService.When(value as IDeleteUomType);
     } catch (Exception ex) { var response = UomTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
예제 #4
0
        public HttpResponseMessage Post([FromBody] CreateUomTypeDto value)
        {
            try {
                if (value.UomTypeId == default(string))
                {
                    throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "UomType");
                }
                _uomTypeApplicationService.When(value as ICreateUomType);
                var idObj = value.UomTypeId;

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

                UomTypesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                _uomTypeApplicationService.When(value as ICreateUomType);
            } catch (Exception ex) { var response = UomTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
예제 #8
0
 public IUomTypeStateDto Get(string id, string fields = null)
 {
     try {
         var idObj = id;
         var state = _uomTypeApplicationService.Get(idObj);
         if (state == null)
         {
             return(null);
         }
         var stateDto = new UomTypeStateDtoWrapper(state);
         if (String.IsNullOrWhiteSpace(fields))
         {
             stateDto.AllFieldsReturned = true;
         }
         else
         {
             stateDto.ReturnedFieldsString = fields;
         }
         return(stateDto);
     } catch (Exception ex) { var response = UomTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
예제 #9
0
 public Type ResolveTypeByPropertyName(string propertyName)
 {
     return(UomTypesControllerUtils.GetFilterPropertyType(propertyName));
 }