public IHttpActionResult GetPersonList(int id, int page = 1, int pagesize = 10) { //Get PersonList personList = db.PersonLists.Find(id); if (personList == null) { return(NotFound()); } //Page var listRestaurants = db.ListRestaurants .Include(x => x.PersonRestaurant.Restaurant.Address) .Where(x => x.PersonList.ID == id) .OrderBy(x => x.Sequence).ThenBy(x => x.ID) .Skip(pagesize * (page - 1)) .Take(pagesize) .ToList(); //Copy personList.ListRestaurants.Clear(); foreach (var item in listRestaurants) { personList.ListRestaurants.Add(item); } //Convert PersonListDTO returnThis = _dtoFactory.Create(personList); return(Ok(returnThis)); }
public IHttpActionResult GetVisited(int personid) { List <PersonRestaurant> visited = db.PersonRestaurants .Include(x => x.Restaurant.Address) .Where(x => x.Person.ID == personid && x.HasVisited) .ToList(); PersonListDTO visitedList = new PersonListDTO() { ID = 0, Title = "Visited", ListRestaurants = visited.Select(x => _dtoFactory.Create(x)), }; return(Ok(visitedList)); }
public IHttpActionResult GetGoals(int personid) { List <PersonRestaurant> goals = db.PersonRestaurants .Include(x => x.Restaurant.Address) .Where(x => x.Person.ID == personid && !x.HasVisited) .ToList(); PersonListDTO goalList = new PersonListDTO() { ID = 0, Title = "Goals", ListRestaurants = goals.Select(x => _dtoFactory.Create(x)), }; return(Ok(goalList)); }
public async Task <ActionResult <ReplyData> > GetPeople() { try { var response = new ReplyData(); var data = await _context.People .Include(e => e.Book) .Include(e => e.Movie) .ToListAsync(); response.data = _mapper.Map <List <Person>, List <PersonListDTO> >(data); PersonListDTO p = new PersonListDTO(); response.schema = new Schema(p, _context); return(response); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError, "Failed to load data")); } }