public void Patch(string id, [FromBody] MergePatchLocatorTypeDto value) { try { LocatorTypesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _locatorTypeApplicationService.When(value as IMergePatchLocatorType); } catch (Exception ex) { var response = LocatorTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public IEnumerable <ILocatorTypeStateDto> GetAll(string sort = null, string fields = null, int firstResult = 0, int maxResults = int.MaxValue, string filter = null) { try { IEnumerable <ILocatorTypeState> states = null; if (!String.IsNullOrWhiteSpace(filter)) { states = _locatorTypeApplicationService.Get(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new ApiControllerTypeConverter(), new PropertyTypeResolver() , n => (LocatorTypeMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? LocatorTypeMetadata.Instance.FilteringPropertyAliasDictionary[n] : n)) , LocatorTypesControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } else { states = _locatorTypeApplicationService.Get(LocatorTypesControllerUtils.GetQueryFilterDictionary(this.Request.GetQueryNameValuePairs()) , LocatorTypesControllerUtils.GetQueryOrders(sort, QueryOrderSeparator), firstResult, maxResults); } var stateDtos = new List <ILocatorTypeStateDto>(); foreach (var s in states) { var dto = s is LocatorTypeStateDtoWrapper ? (LocatorTypeStateDtoWrapper)s : new LocatorTypeStateDtoWrapper(s); if (String.IsNullOrWhiteSpace(fields)) { dto.AllFieldsReturned = true; } else { dto.ReturnedFieldsString = fields; } stateDtos.Add(dto); } return(stateDtos); } catch (Exception ex) { var response = LocatorTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public LocatorTypeStateCreatedOrMergePatchedOrDeletedDto GetStateEvent(string id, long version) { try { var idObj = id; var conv = new LocatorTypeStateEventDtoConverter(); var se = _locatorTypeApplicationService.GetEvent(idObj, version); return(se == null ? null : conv.ToLocatorTypeStateEventDto(se)); } catch (Exception ex) { var response = LocatorTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Delete(string id, string commandId, string version, string requesterId = default(string)) { try { var value = new DeleteLocatorTypeDto(); value.CommandId = commandId; value.RequesterId = requesterId; value.Version = (long)Convert.ChangeType(version, typeof(long)); LocatorTypesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _locatorTypeApplicationService.When(value as IDeleteLocatorType); } catch (Exception ex) { var response = LocatorTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public HttpResponseMessage Post([FromBody] CreateLocatorTypeDto value) { try { if (value.LocatorTypeId == default(string)) { throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "LocatorType"); } _locatorTypeApplicationService.When(value as ICreateLocatorType); var idObj = value.LocatorTypeId; return(Request.CreateResponse <string>(HttpStatusCode.Created, idObj)); } catch (Exception ex) { var response = LocatorTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public long GetCount(string filter = null) { try { long count = 0; if (!String.IsNullOrWhiteSpace(filter)) { count = _locatorTypeApplicationService.GetCount(CriterionDto.ToSubclass(JObject.Parse(filter).ToObject <CriterionDto>(), new WebApiControllerTypeConverter(), new PropertyTypeResolver() , n => (LocatorTypeMetadata.Instance.FilteringPropertyAliasDictionary.ContainsKey(n) ? LocatorTypeMetadata.Instance.FilteringPropertyAliasDictionary[n] : n))); } else { count = _locatorTypeApplicationService.GetCount(LocatorTypesControllerUtils.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 LocatorTypeMetadata.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 = LocatorTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteLocatorTypeDto value) { try { // /////////////////////////////// if (value.Version != default(long)) { value.CommandType = CommandType.MergePatch; LocatorTypesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _locatorTypeApplicationService.When(value as IMergePatchLocatorType); return; } // /////////////////////////////// LocatorTypesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _locatorTypeApplicationService.When(value as ICreateLocatorType); } catch (Exception ex) { var response = LocatorTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public ILocatorTypeStateDto Get(string id, string fields = null) { try { var idObj = id; var state = _locatorTypeApplicationService.Get(idObj); if (state == null) { return(null); } var stateDto = new LocatorTypeStateDtoWrapper(state); if (String.IsNullOrWhiteSpace(fields)) { stateDto.AllFieldsReturned = true; } else { stateDto.ReturnedFieldsString = fields; } return(stateDto); } catch (Exception ex) { var response = LocatorTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public Type ResolveTypeByPropertyName(string propertyName) { return(LocatorTypesControllerUtils.GetFilterPropertyType(propertyName)); }