public async Task <HealthDto> AddHealthAsync(string userId, HealthDto healthDto) { var user = await _context.Users.Where(u => u.Id == userId) .Include(u => u.Health) .FirstOrDefaultAsync(); if (user == null) { return(new HealthDto()); } if (user.Health == null) { var newHealth = _mapper.Map <Health>(healthDto); await _context.Health.AddAsync(newHealth); _context.SaveChanges(); user.Health = newHealth; } else { user.Health.Allergies = healthDto.Allergies; user.Health.ContactLastName = healthDto.ContactLastName; user.Health.ContactFirstName = healthDto.ContactFirstName; user.Health.ContactLastName = healthDto.ContactLastName; user.Health.PhoneNumber = healthDto.PhoneNumber; } await _context.SaveChangesAsync(); return(await GetHealthForUserAsync(userId)); }
public HealthDto CheckServiceHealth() { var healthResult = new HealthDto { ServiceHealthy = true }; return(healthResult); }