public HttpResponseMessage GetLastVideos(int skip, int take) { var videos = service.GetLastAds(skip, take); var reviews = service.GetModeratorViews("admin@admin"); List <SimpleAdModelDTO> ads = new List <SimpleAdModelDTO>(); List <ModeratorViewDTO> views = new List <ModeratorViewDTO>(); foreach (var ad in videos) { var adDto = AdMapUtils.GetAdDTO(ad); ModeratorViewDTO viewDto = new ModeratorViewDTO { ad = adDto, review = new ModeratorView { AdId = ad.Id } }; var review = reviews.FirstOrDefault(a => a.AdId == ad.Id); if (review != null) { viewDto.review = review; } views.Add(viewDto); } return(Request.CreateResponse(HttpStatusCode.OK, views)); }
public HttpResponseMessage GetUserAds() { var userAds = service.GetUserAds(User.Identity.GetUserId()); List <SimpleAdModelDTO> ads = new List <SimpleAdModelDTO>(); foreach (var ad in userAds) { ads.Add(AdMapUtils.GetAdDTO(ad)); } return(Request.CreateResponse(HttpStatusCode.OK, ads)); }