Esempio n. 1
0
 public void Patch(string id, [FromBody] MergePatchOrganizationDto value)
 {
     try {
         OrganizationsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _organizationApplicationService.When(value as IMergePatchOrganization);
     } catch (Exception ex) { var response = OrganizationsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Esempio n. 2
0
 public IOrganizationStateEvent GetStateEvent(string id, long version)
 {
     try {
         var idObj = id;
         return(_organizationApplicationService.GetStateEvent(idObj, version));
     } catch (Exception ex) { var response = OrganizationsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Esempio n. 3
0
 public IEnumerable <IPartyStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null)
 {
     try {
         IEnumerable <IPartyState> states = null;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             states = _partyApplicationService.Get <OrganizationState>(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                                               , n => (PartyMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? PartyMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))
                                                                       , OrganizationsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         else
         {
             states = _partyApplicationService.Get <OrganizationState>(OrganizationsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                                       , OrganizationsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         var stateDtos = new List <IPartyStateDto>();
         foreach (var s in states)
         {
             var dto = s is PartyStateDtoWrapper ? (PartyStateDtoWrapper)s : new PartyStateDtoWrapper(s);
             if (String.IsNullOrWhiteSpace(fields))
             {
                 dto.AllFieldsReturned = true;
             }
             else
             {
                 dto.ReturnedFieldsString = fields;
             }
             stateDtos.Add(dto);
         }
         return(stateDtos);
     } catch (Exception ex) { var response = OrganizationsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Esempio n. 4
0
 public IPartyStateDto Get(string id, string fields = null)
 {
     try {
         var idObj = id;
         var state = _partyApplicationService.Get(idObj);
         if (state == null)
         {
             return(null);
         }
         if (state != null && !typeof(IOrganizationState).IsAssignableFrom(state.GetType()))
         {
             return(null);
         }
         var stateDto = new PartyStateDtoWrapper(state);
         if (String.IsNullOrWhiteSpace(fields))
         {
             stateDto.AllFieldsReturned = true;
         }
         else
         {
             stateDto.ReturnedFieldsString = fields;
         }
         return(stateDto);
     } catch (Exception ex) { var response = OrganizationsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Esempio n. 5
0
 public void Patch(string id, [FromBody] MergePatchPartyDto value)
 {
     try {
         value.PartyTypeId = PartyTypeIds.Organization;
         OrganizationsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _partyApplicationService.When(value as IMergePatchParty);
     } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Esempio n. 6
0
 public PartyStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version)
 {
     try {
         var idObj = id;
         var conv  = new PartyStateEventDtoConverter();
         var se    = _partyApplicationService.GetEvent(idObj, version);
         return(se == null ? null : conv.ToPartyStateEventDto(se));
     } catch (Exception ex) { var response = OrganizationsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Esempio n. 7
0
 public void Delete(string id, string commandId, string version, string requesterId = default(string))
 {
     try {
         var value = new DeleteOrganizationDto();
         value.CommandId   = commandId;
         value.RequesterId = requesterId;
         value.Version     = (long)Convert.ChangeType(version, typeof(long));
         OrganizationsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _organizationApplicationService.When(value as IDeleteOrganization);
     } catch (Exception ex) { var response = OrganizationsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Esempio n. 8
0
        public HttpResponseMessage Post([FromBody] CreatePartyDto value)
        {
            try {
                value.PartyTypeId = PartyTypeIds.Organization;
                if (value.PartyId == default(string))
                {
                    throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "Party");
                }
                _partyApplicationService.When(value as ICreateParty);
                var idObj = value.PartyId;

                return(Request.CreateResponse <string>(HttpStatusCode.Created, idObj));
            } catch (Exception ex) { var response = OrganizationsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
Esempio n. 9
0
 public IEnumerable <PropertyMetadata> GetMetadataFilteringFields()
 {
     try {
         var filtering = new List <PropertyMetadata>();
         foreach (var p in OrganizationMetadata.Instance.Properties)
         {
             if (p.IsFilteringProperty)
             {
                 filtering.Add(p);
             }
         }
         return(filtering);
     } catch (Exception ex) { var response = OrganizationsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Esempio n. 10
0
 public long GetCount(string filter = null)
 {
     try
     {
         long count = 0;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             count = _organizationApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver()));
         }
         else
         {
             count = _organizationApplicationService.GetCount(OrganizationsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()));
         }
         return(count);
     } catch (Exception ex) { var response = OrganizationsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Esempio n. 11
0
 public long GetCount(string filter = null)
 {
     try {
         long count = 0;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             count = _partyApplicationService.GetCount <OrganizationState>(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new WebApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                                                   , n => (PartyMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? PartyMetadata.Instance.FilteringPropertyAliasDictionary[n] : n)));
         }
         else
         {
             count = _partyApplicationService.GetCount <OrganizationState>(OrganizationsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()));
         }
         return(count);
     } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Esempio n. 12
0
 public IEnumerable <PropertyMetadataDto> GetMetadataFilteringFields()
 {
     try {
         var filtering = new List <PropertyMetadataDto>();
         foreach (var p in PartyMetadata.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 = OrganizationsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Esempio n. 13
0
        public void Put(string id, [FromBody] CreateOrMergePatchOrDeletePartyDto value)
        {
            try {
                value.PartyTypeId = PartyTypeIds.Organization;
                // ///////////////////////////////
                if (value.Version != default(long))
                {
                    value.CommandType = CommandType.MergePatch;
                    OrganizationsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                    _partyApplicationService.When(value as IMergePatchParty);
                    return;
                }
                // ///////////////////////////////

                OrganizationsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                _partyApplicationService.When(value as ICreateParty);
            } catch (Exception ex) { var response = OrganizationsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
Esempio n. 14
0
 public IPartyStateDto GetHistoryState(string id, long version, string fields = null)
 {
     try {
         var idObj = id;
         var state = _partyApplicationService.GetHistoryState(idObj, version);
         if (state == null)
         {
             return(null);
         }
         var stateDto = new PartyStateDtoWrapper(state);
         if (String.IsNullOrWhiteSpace(fields))
         {
             stateDto.AllFieldsReturned = true;
         }
         else
         {
             stateDto.ReturnedFieldsString = fields;
         }
         return(stateDto);
     } catch (Exception ex) { var response = OrganizationsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Esempio n. 15
0
 public OrganizationStateDto Get(string id, string fields = null)
 {
     try {
         var idObj = id;
         var state = (OrganizationState)_organizationApplicationService.Get(idObj);
         if (state == null)
         {
             return(null);
         }
         var stateDto = new OrganizationStateDto(state);
         if (String.IsNullOrWhiteSpace(fields))
         {
             stateDto.AllFieldsReturned = true;
         }
         else
         {
             stateDto.ReturnedFieldsString = fields;
         }
         return(stateDto);
     } catch (Exception ex) { var response = OrganizationsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
 public IEnumerable <OrganizationStateDto> Get(string parentId = null, string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null)
 {
     try {
         var parentIdObj = parentId == null ? null : parentId;
         IEnumerable <IOrganizationState> states = null;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             if (parentIdObj == null)
             {
                 if (IsOnlyIdReturned(fields))
                 {
                     var ids = _organizationTreeApplicationService.GetRootIds(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver())
                                                                              , OrganizationsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
                     states = OrganizationsControllerUtils.ToOrganizationStateDtoCollection(ids);
                 }
                 else
                 {
                     states = _organizationTreeApplicationService.GetRoots(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver())
                                                                           , OrganizationsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
                 }
             }
             else
             {
                 if (IsOnlyIdReturned(fields))
                 {
                     var ids = _organizationTreeApplicationService.GetChildIds(parentIdObj, CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver())
                                                                               , OrganizationsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
                     states = OrganizationsControllerUtils.ToOrganizationStateDtoCollection(ids);
                 }
                 else
                 {
                     states = _organizationTreeApplicationService.GetChildren(parentIdObj, CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver())
                                                                              , OrganizationsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
                 }
             }
         }
         else
         {
             if (parentIdObj == null)
             {
                 if (IsOnlyIdReturned(fields))
                 {
                     var ids = _organizationTreeApplicationService.GetRootIds(OrganizationsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                                              , OrganizationsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
                     states = OrganizationsControllerUtils.ToOrganizationStateDtoCollection(ids);
                 }
                 else
                 {
                     states = _organizationTreeApplicationService.GetRoots(OrganizationsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                                           , OrganizationsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
                 }
             }
             else
             {
                 if (IsOnlyIdReturned(fields))
                 {
                     var ids = _organizationTreeApplicationService.GetChildIds(parentIdObj, OrganizationsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                                               , OrganizationsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
                     states = OrganizationsControllerUtils.ToOrganizationStateDtoCollection(ids);
                 }
                 else
                 {
                     states = _organizationTreeApplicationService.GetChildren(parentIdObj, OrganizationsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                                              , OrganizationsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
                 }
             }
         }
         var stateDtos = new List <OrganizationStateDto>();
         foreach (var s in states)
         {
             var dto = s is OrganizationStateDto ? (OrganizationStateDto)s : new OrganizationStateDto((OrganizationState)s);
             if (String.IsNullOrWhiteSpace(fields))
             {
                 dto.AllFieldsReturned = true;
             }
             else
             {
                 dto.ReturnedFieldsString = fields;
             }
             stateDtos.Add(dto);
         }
         return(stateDtos);
     } catch (Exception ex) { var response = OrganizationsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Esempio n. 17
0
 public Type ResolveTypeByPropertyName(string propertyName)
 {
     return(OrganizationsControllerUtils.GetFilterPropertyType(propertyName));
 }