Web API не возвращает ответ, но данные формируются при возврате - PullRequest
0 голосов
/ 31 декабря 2018

Метод GetPlaces должен возвращать всех пользователей с их общими папками (домами), но я не получаю ответа, когда пытаюсь включить Акции.

Вызывается API и получает все данныено когда я пытаюсь вернуть данные обратно, я не получаю ответа.

Это не только вызов API, но каждый раз, когда я хочу включить другую таблицу из базы данных, я получаю один и тот же ответ.Я проверяю его с почтальоном

public class PlaceController : ControllerBase
{
    PlaceService _PlaceService;
    UserService _UserService;
    ApplicationDbContext _db;
    public PlaceController(PlaceService PlaceServicea, UserService _UserServicea, ApplicationDbContext db)
    {
        _db = db;
        _PlaceService = PlaceServicea;
        _UserService = _UserServicea;
    }
    //get all places
    [HttpGet]
    [Route("all")]
    public async Task<ActionResult> GetPlaces()
    {
        var usersWithShares = await _db.Set<User>().Include(x => x.Shares).ToListAsync();

        return Ok(usersWithShares);
        // return Ok(await _PlaceService.GetAll());
    }
}

Это моя сущность Пользователь

public class User
{
    public int Id { get; set; }
    public string Email { get; set; }
    public string Password { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public long PhoneNumber { get; set; }
    public DateTime BirthDate { get; set; }
    public string Token { get; internal set; }
    public ICollection<Place> Shares { get; set; }
}

, и это моя сущность

public class Place
{
    public int Id { get; set; }
    public int Rooms { get; set; }
    public int Garage { get; set; }
    public bool Garden { get; set; }
    public int Bathrooms { get; set; }
    public int Toilet { get; set; }
    public int Kitchen { get; set; }
    public int LivingRoom { get; set; }
    public string Description { get; set; }
    public decimal Price { get; set; }
    public User User { get; set; }
    public Adres Adres { get; set; }
    public ICollection<PlacePicture> PlacePictures { get; set; }
}

, а это моя ConfigureServices

public void ConfigureServices(IServiceCollection services)
{
    services.AddDbContext<ApplicationDbContext>(
        options => options.UseSqlServer(Configuration.GetConnectionString("Homesharing"))
        );  
    // configure DI for application services
    services.AddScoped<UserService>();
    services.AddScoped<PlaceService>();
}

См. Изображение для более

...