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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
public Type ResolveTypeByPropertyName(string propertyName) { return(OrganizationStructuresControllerUtils.GetFilterPropertyType(propertyName)); }