private async void GetEntity() { if (this.FormSettings.RequestDetails.Filter == null) { throw new ArgumentException($"{nameof(this.FormSettings.RequestDetails.Filter)}: 883E834F-98A6-4DF7-9D07-F1BB0D6639E1"); } BaseResponse baseResponse = await BusyIndicatorHelpers.ExecuteRequestWithBusyIndicator ( () => this.httpService.GetEntity ( new GetEntityRequest { Filter = this.FormSettings.RequestDetails.Filter, SelectExpandDefinition = this.FormSettings.RequestDetails.SelectExpandDefinition, ModelType = this.FormSettings.RequestDetails.ModelType, DataType = this.FormSettings.RequestDetails.DataType } ) ); if (baseResponse.Success == false) { await App.Current.MainPage.DisplayAlert ( "Errors", string.Join(Environment.NewLine, baseResponse.ErrorMessages), "Ok" ); return; } GetEntityResponse getEntityResponse = (GetEntityResponse)baseResponse; this.entity = (TModel)getEntityResponse.Entity; this.originalEntityDictionary = this.entity.EntityToObjectDictionary ( mapper, this.FormSettings.FieldSettings ); this.propertiesUpdater.UpdateProperties ( FormLayout.Properties, getEntityResponse.Entity, this.FormSettings.FieldSettings ); }
public virtual async Task <ActionResult <GetEntityResponse <TSettings> > > GetSettings([FromQuery] SelectExpandArguments args, CancellationToken cancellation) { var _service = GetSettingsService(); var settings = await _service.GetSettings(args, cancellation); var singleton = new TSettings[] { settings }; var relatedEntities = ControllerUtilities.Flatten(singleton, cancellation: default); var result = new GetEntityResponse <TSettings> { Result = settings, RelatedEntities = relatedEntities }; return(Ok(result)); }
private async void GetEntity() { if (this.FormSettings.RequestDetails.Filter == null) { throw new ArgumentException($"{nameof(this.FormSettings.RequestDetails.Filter)}: 51755FE3-099A-44EB-A59B-3ED312EDD8D1"); } BaseResponse baseResponse = await BusyIndicatorHelpers.ExecuteRequestWithBusyIndicator ( () => this.httpService.GetEntity ( new GetEntityRequest { Filter = this.FormSettings.RequestDetails.Filter, SelectExpandDefinition = this.FormSettings.RequestDetails.SelectExpandDefinition, ModelType = this.FormSettings.RequestDetails.ModelType, DataType = this.FormSettings.RequestDetails.DataType } ) ); if (baseResponse.Success == false) { await App.Current.MainPage.DisplayAlert ( "Errors", string.Join(Environment.NewLine, baseResponse.ErrorMessages), "Ok" ); return; } GetEntityResponse getEntityResponse = (GetEntityResponse)baseResponse; this.entity = (TModel)getEntityResponse.Entity; (EditCommand as Command).ChangeCanExecute(); this.propertiesUpdater.UpdateProperties ( FormLayout.Properties, getEntityResponse.Entity, this.FormSettings.FieldSettings ); }
// Helper methods private async Task <GetEntityResponse <Settings> > GetImpl(GetByIdArguments args) { var settings = await _repo.Settings .Select(args.Select) .Expand(args.Expand) .OrderBy("PrimaryLanguageId") .FirstOrDefaultAsync(); if (settings == null) { // Programmer mistake throw new BadRequestException("Settings have not been initialized"); } var result = new GetEntityResponse <Settings> { Result = settings, }; return(result); }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { GetEntityResponse response = new GetEntityResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("arn", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Arn = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("components", targetDepth)) { var unmarshaller = new DictionaryUnmarshaller <string, ComponentResponse, StringUnmarshaller, ComponentResponseUnmarshaller>(StringUnmarshaller.Instance, ComponentResponseUnmarshaller.Instance); response.Components = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("creationDateTime", targetDepth)) { var unmarshaller = DateTimeUnmarshaller.Instance; response.CreationDateTime = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("description", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Description = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("entityId", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.EntityId = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("entityName", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.EntityName = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("hasChildEntities", targetDepth)) { var unmarshaller = BoolUnmarshaller.Instance; response.HasChildEntities = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("parentEntityId", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.ParentEntityId = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("status", targetDepth)) { var unmarshaller = StatusUnmarshaller.Instance; response.Status = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("updateDateTime", targetDepth)) { var unmarshaller = DateTimeUnmarshaller.Instance; response.UpdateDateTime = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("workspaceId", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.WorkspaceId = unmarshaller.Unmarshall(context); continue; } } return(response); }