public void Patch(string id, [FromBody] MergePatchPicklistDto value) { try { PicklistsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _picklistApplicationService.When(value as IMergePatchPicklist); } catch (Exception ex) { var response = PicklistsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <IPicklistStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null) { try { IEnumerable <IPicklistState> states = null; if (!String.IsNullOrWhiteSpace(filter)) { states = _picklistApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver() , n => (PicklistMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? PicklistMetadata.Instance.FilteringPropertyAliasDictionary[n] : n)) , PicklistsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } else { states = _picklistApplicationService.Get(PicklistsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()) , PicklistsControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } var stateDtos = new List <IPicklistStateDto>(); foreach (var s in states) { var dto = s is PicklistStateDtoWrapper ? (PicklistStateDtoWrapper)s : new PicklistStateDtoWrapper(s); if (String.IsNullOrWhiteSpace(fields)) { dto.AllFieldsReturned = true; } else { dto.ReturnedFieldsString = fields; } stateDtos.Add(dto); } return(stateDtos); } catch (Exception ex) { var response = PicklistsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public PicklistStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version) { try { var idObj = id; var conv = new PicklistStateEventDtoConverter(); var se = _picklistApplicationService.GetEvent(idObj, version); return(se == null ? null : conv.ToPicklistStateEventDto(se)); } catch (Exception ex) { var response = PicklistsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Delete(string id, string commandId, string version, string requesterId = default(string)) { try { var value = new DeletePicklistDto(); value.CommandId = commandId; value.RequesterId = requesterId; value.Version = (long)Convert.ChangeType(version, typeof(long)); PicklistsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _picklistApplicationService.When(value as IDeletePicklist); } catch (Exception ex) { var response = PicklistsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IPicklistRoleStateDto GetPicklistRole(string picklistId, string partyRoleId) { try { var state = (PicklistRoleState)_picklistApplicationService.GetPicklistRole(picklistId, ((new ValueObjectTextFormatter <PartyRoleId>()).Parse(partyRoleId))); if (state == null) { return(null); } var stateDto = new PicklistRoleStateDtoWrapper(state); stateDto.AllFieldsReturned = true; return(stateDto); } catch (Exception ex) { var response = PicklistsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public HttpResponseMessage Post([FromBody] CreatePicklistDto value) { try { if (value.PicklistId == default(string)) { throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "Picklist"); } _picklistApplicationService.When(value as ICreatePicklist); var idObj = value.PicklistId; return(Request.CreateResponse <string>(HttpStatusCode.Created, idObj)); } catch (Exception ex) { var response = PicklistsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public long GetCount(string filter = null) { try { long count = 0; if (!String.IsNullOrWhiteSpace(filter)) { count = _picklistApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new WebApiControllerTypeConverter(), new PropertyTypeResolver() , n => (PicklistMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? PicklistMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))); } else { count = _picklistApplicationService.GetCount(PicklistsControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())); } return(count); } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <PropertyMetadataDto> GetMetadataFilteringFields() { try { var filtering = new List <PropertyMetadataDto>(); foreach (var p in PicklistMetadata.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 = PicklistsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Put(string id, [FromBody] CreateOrMergePatchOrDeletePicklistDto value) { try { // /////////////////////////////// if (value.Version != default(long)) { value.CommandType = CommandType.MergePatch; PicklistsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _picklistApplicationService.When(value as IMergePatchPicklist); return; } // /////////////////////////////// PicklistsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _picklistApplicationService.When(value as ICreatePicklist); } catch (Exception ex) { var response = PicklistsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <IPicklistRoleStateDto> GetPicklistRoles(string picklistId) { try { var states = _picklistApplicationService.GetPicklistRoles(picklistId); if (states == null) { return(null); } var stateDtos = new List <IPicklistRoleStateDto>(); foreach (var s in states) { var dto = s is PicklistRoleStateDtoWrapper ? (PicklistRoleStateDtoWrapper)s : new PicklistRoleStateDtoWrapper((PicklistRoleState)s); dto.AllFieldsReturned = true; stateDtos.Add(dto); } return(stateDtos); } catch (Exception ex) { var response = PicklistsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IPicklistStateDto Get(string id, string fields = null) { try { var idObj = id; var state = _picklistApplicationService.Get(idObj); if (state == null) { return(null); } var stateDto = new PicklistStateDtoWrapper(state); if (String.IsNullOrWhiteSpace(fields)) { stateDto.AllFieldsReturned = true; } else { stateDto.ReturnedFieldsString = fields; } return(stateDto); } catch (Exception ex) { var response = PicklistsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public Type ResolveTypeByPropertyName(string propertyName) { return(PicklistsControllerUtils.GetFilterPropertyType(propertyName)); }