public IEnumerable <IOrganizationStructureTypeStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null) { try { IEnumerable <IOrganizationStructureTypeState> states = null; if (!String.IsNullOrWhiteSpace(filter)) { states = _organizationStructureTypeApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver()) , OrganizationStructureTypesControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } else { states = _organizationStructureTypeApplicationService.Get(OrganizationStructureTypesControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()) , OrganizationStructureTypesControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } var stateDtos = new List <IOrganizationStructureTypeStateDto>(); foreach (var s in states) { var dto = s is OrganizationStructureTypeStateDtoWrapper ? (OrganizationStructureTypeStateDtoWrapper)s : new OrganizationStructureTypeStateDtoWrapper(s); if (String.IsNullOrWhiteSpace(fields)) { dto.AllFieldsReturned = true; } else { dto.ReturnedFieldsString = fields; } stateDtos.Add(dto); } return(stateDtos); } catch (Exception ex) { var response = OrganizationStructureTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Patch(string id, [FromBody] MergePatchOrganizationStructureTypeDto value) { try { OrganizationStructureTypesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _organizationStructureTypeApplicationService.When(value as IMergePatchOrganizationStructureType); } catch (Exception ex) { var response = OrganizationStructureTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IOrganizationStructureTypeStateEvent GetStateEvent(string id, long version) { try { var idObj = id; return(_organizationStructureTypeApplicationService.GetStateEvent(idObj, version)); } catch (Exception ex) { var response = OrganizationStructureTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public OrganizationStructureTypeStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version) { try { var idObj = id; var conv = new OrganizationStructureTypeStateEventDtoConverter(); var se = _organizationStructureTypeApplicationService.GetStateEvent(idObj, version); return(se == null ? null : conv.ToOrganizationStructureTypeStateEventDto(se)); } catch (Exception ex) { var response = OrganizationStructureTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Delete(string id, string commandId, string version, string requesterId = default(string)) { try { var value = new DeleteOrganizationStructureTypeDto(); value.CommandId = commandId; value.RequesterId = requesterId; value.Version = (long)Convert.ChangeType(version, typeof(long)); OrganizationStructureTypesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _organizationStructureTypeApplicationService.When(value as IDeleteOrganizationStructureType); } catch (Exception ex) { var response = OrganizationStructureTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public HttpResponseMessage Post([FromBody] CreateOrganizationStructureTypeDto value) { try { if (value.Id == default(string)) { throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "OrganizationStructureType"); } _organizationStructureTypeApplicationService.When(value as ICreateOrganizationStructureType); var idObj = value.Id; return(Request.CreateResponse <string>(HttpStatusCode.Created, idObj)); } catch (Exception ex) { var response = OrganizationStructureTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <PropertyMetadata> GetMetadataFilteringFields() { try { var filtering = new List <PropertyMetadata>(); foreach (var p in OrganizationStructureTypeMetadata.Instance.Properties) { if (p.IsFilteringProperty) { filtering.Add(p); } } return(filtering); } catch (Exception ex) { var response = OrganizationStructureTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public long GetCount(string filter = null) { try { long count = 0; if (!String.IsNullOrWhiteSpace(filter)) { count = _organizationStructureTypeApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver())); } else { count = _organizationStructureTypeApplicationService.GetCount(OrganizationStructureTypesControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs())); } return(count); } catch (Exception ex) { var response = OrganizationStructureTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <PropertyMetadataDto> GetMetadataFilteringFields() { try { var filtering = new List <PropertyMetadataDto>(); foreach (var p in OrganizationStructureTypeMetadata.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 = OrganizationStructureTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteOrganizationStructureTypeDto value) { try { // /////////////////////////////// if (value.Version != default(long)) { value.CommandType = CommandType.MergePatch; OrganizationStructureTypesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _organizationStructureTypeApplicationService.When(value as IMergePatchOrganizationStructureType); return; } // /////////////////////////////// OrganizationStructureTypesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _organizationStructureTypeApplicationService.When(value as ICreateOrganizationStructureType); } catch (Exception ex) { var response = OrganizationStructureTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IOrganizationStructureTypeStateDto Get(string id, string fields = null) { try { var idObj = id; var state = _organizationStructureTypeApplicationService.Get(idObj); if (state == null) { return(null); } var stateDto = new OrganizationStructureTypeStateDtoWrapper(state); if (String.IsNullOrWhiteSpace(fields)) { stateDto.AllFieldsReturned = true; } else { stateDto.ReturnedFieldsString = fields; } return(stateDto); } catch (Exception ex) { var response = OrganizationStructureTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public Type ResolveTypeByPropertyName(string propertyName) { return(OrganizationStructureTypesControllerUtils.GetFilterPropertyType(propertyName)); }