public async Task <object> GetService(int id) { var service = await _servicesService.GetService(id); if (service == null) { return(JsonResults.Error(errorNum: 404, errorMessage: "Service not found")); } var model = GetServiceModel(service); return(JsonResults.Success(model)); }
public override async Task <EmbededViewResult> Execute() { Model = new ServiceMethodModel(); var serviceName = this.HttpContext.Request.Query["_s"].ToString(); var methodName = this.HttpContext.Request.Query["_m"].ToString(); Model.Service = _servicesService.GetService(serviceName); Model.Method = Model.Service.Methods.FirstOrDefault(x => x.Id == methodName); var fieldsValues = new Dictionary <string, string>(); if (IsPost()) { fieldsValues = this.HttpContext.Request.Form .Where(x => x.Key.StartsWith("_") == false && string.IsNullOrEmpty(x.Value.FirstOrDefault()) == false) .ToDictionary(x => x.Key, x => x.Value.FirstOrDefault()?.ToString()); } Model.FieldsWithValues = Model.Method.Method.GetParameters().Select(x => (x, fieldsValues.FirstOrDefault(v => v.Key == x.Name).Value)).ToList(); if (IsSubmit()) { var result = _servicesService.InvokeMethod(Model.Service, Model.Method, fieldsValues); Model.Errors = result.Errors; Model.ExecutionResult = result.Result; } return(await View()); }
public override async Task <EmbededViewResult> Execute() { Model = new ServicePropertydModel(); var serviceName = this.HttpContext.Request.Query["_s"].ToString(); var propertyName = this.HttpContext.Request.Query["_p"].ToString(); Model.Service = _servicesService.GetService(serviceName); Model.Property = Model.Service.Properties.FirstOrDefault(x => x.Id == propertyName); if (this.IsSubmit()) { var result = _servicesService.InvokeProperty(Model.Service, Model.Property); Model.Errors = result.Errors; Model.ExecutionResult = result.Result; } return(await View()); }
public override async Task <EmbededViewResult> Execute() { Model = new ServiceFielddModel(); var serviceName = this.HttpContext.Request.Query["_s"].ToString(); var fieldName = this.HttpContext.Request.Query["_f"].ToString(); Model.Service = _servicesService.GetService(serviceName); Model.Field = Model.Service.Fields.FirstOrDefault(x => x.Id == fieldName); if (IsSubmit()) { var result = _servicesService.InvokeField(Model.Service, Model.Field); Model.Errors = result.Errors; Model.ExecutionResult = result.Result; } return(await View()); }
public Service GetService(int id) { return(service.GetService(id)); }