Beispiel #1
0
 public void Patch(string id, [FromBody] MergePatchPartyRoleDto value)
 {
     try {
         PartyRolesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _partyRoleApplicationService.When(value as IMergePatchPartyRole);
     } catch (Exception ex) { var response = PartyRolesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Beispiel #2
0
 public IEnumerable <IPartyRoleStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null)
 {
     try {
         IEnumerable <IPartyRoleState> states = null;
         if (!String.IsNullOrWhiteSpace(filter))
         {
             states = _partyRoleApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver()
                                                                               , n => (PartyRoleMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? PartyRoleMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))
                                                       , PartyRolesControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         else
         {
             states = _partyRoleApplicationService.Get(PartyRolesControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())
                                                       , PartyRolesControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults);
         }
         var stateDtos = new List <IPartyRoleStateDto>();
         foreach (var s in states)
         {
             var dto = s is PartyRoleStateDtoWrapper ? (PartyRoleStateDtoWrapper)s : new PartyRoleStateDtoWrapper(s);
             if (String.IsNullOrWhiteSpace(fields))
             {
                 dto.AllFieldsReturned = true;
             }
             else
             {
                 dto.ReturnedFieldsString = fields;
             }
             stateDtos.Add(dto);
         }
         return(stateDtos);
     } catch (Exception ex) { var response = PartyRolesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Beispiel #3
0
 public PartyRoleStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version)
 {
     try {
         var idObj = PartyRolesControllerUtils.ParseIdString(id);
         var conv  = new PartyRoleStateEventDtoConverter();
         var se    = _partyRoleApplicationService.GetEvent(idObj, version);
         return(se == null ? null : conv.ToPartyRoleStateEventDto(se));
     } catch (Exception ex) { var response = PartyRolesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Beispiel #4
0
 public void Delete(string id, string commandId, string version, string requesterId = default(string))
 {
     try {
         var value = new DeletePartyRoleDto();
         value.CommandId   = commandId;
         value.RequesterId = requesterId;
         value.Version     = (long)Convert.ChangeType(version, typeof(long));
         PartyRolesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _partyRoleApplicationService.When(value as IDeletePartyRole);
     } catch (Exception ex) { var response = PartyRolesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Beispiel #5
0
        public HttpResponseMessage Post([FromBody] CreatePartyRoleDto value)
        {
            try {
                if (value.PartyRoleId == default(PartyRoleId))
                {
                    throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "PartyRole");
                }
                _partyRoleApplicationService.When(value as ICreatePartyRole);
                var idObj = value.PartyRoleId;

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

                PartyRolesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                _partyRoleApplicationService.When(value as ICreatePartyRole);
            } catch (Exception ex) { var response = PartyRolesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
Beispiel #9
0
 public IPartyRoleStateDto Get(string id, string fields = null)
 {
     try {
         var idObj = PartyRolesControllerUtils.ParseIdString(id);
         var state = _partyRoleApplicationService.Get(idObj);
         if (state == null)
         {
             return(null);
         }
         var stateDto = new PartyRoleStateDtoWrapper(state);
         if (String.IsNullOrWhiteSpace(fields))
         {
             stateDto.AllFieldsReturned = true;
         }
         else
         {
             stateDto.ReturnedFieldsString = fields;
         }
         return(stateDto);
     } catch (Exception ex) { var response = PartyRolesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }