public async Task <HealthRequest> AddOrUpdateRequest(HealthRequest healthRequest) { try { //If there is no id assigned to the blog if (healthRequest.Id == Guid.Empty) { //Then we need to add a new record DbContext.HealthRequests.Add(healthRequest); } else { //Get the blokg from the db var healthrequestDb = await DbContext.HealthRequests.SingleOrDefaultAsync(item => item.Id == healthRequest.Id); //Update the wanted values healthrequestDb.Subject = healthRequest.Subject; healthrequestDb.Content = healthRequest.Content; healthrequestDb.Note = healthRequest.Note; healthRequest = healthrequestDb; //Mark it as modified DbContext.Entry(healthrequestDb).State = EntityState.Modified; } await DbContext.SaveChangesAsync(); return(healthRequest); } catch (System.Exception ex) { LogginService.LogException(ex); } return(null); }
public override Task <HealthResult> Check(HealthRequest request, ServerCallContext context) { _logger.LogTrace("do check."); return(Task.FromResult(new HealthResult { Result = $"GrpcApi is healthful! -{DateTime.Now}-{request.Id}" })); }
public static HealthResponse GetHealth(this Channel chan, uint ttl, ECDsa key, bool debug = false) { var req = new HealthRequest(); req.SetTTL(ttl); req.SignHeader(key, debug); var cli = new Status.StatusClient(chan); return(cli.HealthCheck(req)); }
public virtual IActionResult Health(HealthRequest request) { HealthResponse response = new HealthResponse() { Data = new Dictionary <string, string>() }; response.Data["healthy"] = "TRUE"; IActionResult result = Ok(response); return(result); }
public override async Task <HealthResponse> AddPersonHealthData(HealthRequest request, ServerCallContext context) { var healthData = new HealthData { Name = request.Name, HealthParameter1 = request.HealthParameter1, HealthParameter2 = request.HealthParameter2 }; _personDbContext.Health.Add(healthData); await _personDbContext.SaveChangesAsync(); var results = new HealthResponse { Message = "Health Data Save Successfully." }; return(results); }
static async Task Main(string[] args) { using var channel = GrpcChannel.ForAddress("https://localhost:5001"); var client = new AddressBookService.AddressBookServiceClient(channel); var userAddress = new AddressAdditionRequest { Name = "22 Feb 2020", Address = "Webinar" }; var reply = await client.AddUserAddressAsync(userAddress); Console.WriteLine("Greeting: " + reply.Message); // Health Data var healthData = new HealthRequest { Name = "Test Name", HealthParameter1 = 100, HealthParameter2 = 120 }; var results = await client.AddPersonHealthDataAsync(healthData); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }