示例#1
0
 public void Patch(string id, [FromBody] MergePatchOrganizationStructureDto value)
 {
     try {
         OrganizationStructuresControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _organizationStructureApplicationService.When(value as IMergePatchOrganizationStructure);
     } catch (Exception ex) { var response = OrganizationStructuresControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
示例#2
0
 public IEnumerable <IOrganizationStructureStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null)
 {
     try {
         IEnumerable <IOrganizationStructureState> states = null;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             states = _organizationStructureApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                                           , n => (OrganizationStructureMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? OrganizationStructureMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))
                                                                   , OrganizationStructuresControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         else
         {
             states = _organizationStructureApplicationService.Get(OrganizationStructuresControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                                   , OrganizationStructuresControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         var stateDtos = new List <IOrganizationStructureStateDto>();
         foreach (var s in states)
         {
             var dto = s is OrganizationStructureStateDtoWrapper ? (OrganizationStructureStateDtoWrapper)s : new OrganizationStructureStateDtoWrapper(s);
             if (String.IsNullOrWhiteSpace(fields))
             {
                 dto.AllFieldsReturned = true;
             }
             else
             {
                 dto.ReturnedFieldsString = fields;
             }
             stateDtos.Add(dto);
         }
         return(stateDtos);
     } catch (Exception ex) { var response = OrganizationStructuresControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
 public IOrganizationStructureStateEvent GetStateEvent(string id, long version)
 {
     try {
         var idObj = OrganizationStructuresControllerUtils.ParseIdString(id);
         return(_organizationStructureApplicationService.GetStateEvent(idObj, version));
     } catch (Exception ex) { var response = OrganizationStructuresControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
示例#4
0
 public OrganizationStructureStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version)
 {
     try {
         var idObj = OrganizationStructuresControllerUtils.ParseIdString(id);
         var conv  = new OrganizationStructureStateEventDtoConverter();
         var se    = _organizationStructureApplicationService.GetEvent(idObj, version);
         return(se == null ? null : conv.ToOrganizationStructureStateEventDto(se));
     } catch (Exception ex) { var response = OrganizationStructuresControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
示例#5
0
 public void Delete(string id, string commandId, string version, string requesterId = default(string))
 {
     try {
         var value = new DeleteOrganizationStructureDto();
         value.CommandId   = commandId;
         value.RequesterId = requesterId;
         value.Version     = (long)Convert.ChangeType(version, typeof(long));
         OrganizationStructuresControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _organizationStructureApplicationService.When(value as IDeleteOrganizationStructure);
     } catch (Exception ex) { var response = OrganizationStructuresControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
示例#6
0
        public HttpResponseMessage Post([FromBody] CreateOrganizationStructureDto value)
        {
            try {
                if (value.Id == default(OrganizationStructureId))
                {
                    throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "OrganizationStructure");
                }
                _organizationStructureApplicationService.When(value as ICreateOrganizationStructure);
                var idObj = value.Id;

                return(Request.CreateResponse <OrganizationStructureId>(HttpStatusCode.Created, idObj));
            } catch (Exception ex) { var response = OrganizationStructuresControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
示例#7
0
 public IEnumerable <PropertyMetadata> GetMetadataFilteringFields()
 {
     try {
         var filtering = new List <PropertyMetadata>();
         foreach (var p in OrganizationStructureMetadata.Instance.Properties)
         {
             if (p.IsFilteringProperty)
             {
                 filtering.Add(p);
             }
         }
         return(filtering);
     } catch (Exception ex) { var response = OrganizationStructuresControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
 public long GetCount(string filter = null)
 {
     try {
         long count = 0;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             count = _organizationStructureApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new WebApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                                               , n => (OrganizationStructureMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? OrganizationStructureMetadata.Instance.FilteringPropertyAliasDictionary[n] : n)));
         }
         else
         {
             count = _organizationStructureApplicationService.GetCount(OrganizationStructuresControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()));
         }
         return(count);
     } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
示例#9
0
 public IEnumerable <PropertyMetadataDto> GetMetadataFilteringFields()
 {
     try {
         var filtering = new List <PropertyMetadataDto>();
         foreach (var p in OrganizationStructureMetadata.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 = OrganizationStructuresControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
示例#10
0
        public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteOrganizationStructureDto value)
        {
            try {
                // ///////////////////////////////
                if (value.Version != default(long))
                {
                    value.CommandType = CommandType.MergePatch;
                    OrganizationStructuresControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                    _organizationStructureApplicationService.When(value as IMergePatchOrganizationStructure);
                    return;
                }
                // ///////////////////////////////

                OrganizationStructuresControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                _organizationStructureApplicationService.When(value as ICreateOrganizationStructure);
            } catch (Exception ex) { var response = OrganizationStructuresControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
示例#11
0
 public IOrganizationStructureStateDto Get(string id, string fields = null)
 {
     try {
         var idObj = OrganizationStructuresControllerUtils.ParseIdString(id);
         var state = _organizationStructureApplicationService.Get(idObj);
         if (state == null)
         {
             return(null);
         }
         var stateDto = new OrganizationStructureStateDtoWrapper(state);
         if (String.IsNullOrWhiteSpace(fields))
         {
             stateDto.AllFieldsReturned = true;
         }
         else
         {
             stateDto.ReturnedFieldsString = fields;
         }
         return(stateDto);
     } catch (Exception ex) { var response = OrganizationStructuresControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
示例#12
0
 public Type ResolveTypeByPropertyName(string propertyName)
 {
     return(OrganizationStructuresControllerUtils.GetFilterPropertyType(propertyName));
 }