public async Task <IActionResult> UserBookmarksChangePage(UserBookmarksModel model) { var pager = new Pager(_user.CountUserBookmarks(model.IdentUserId), model.CurrPage); if (model.CurrPage == 0) { pager.CurrentPage = 1; } model.Pager = pager; model.Bookmarks = _user.GetUserBookmarks(model.IdentUserId, pager.CurrentPage, pager.PageSize).Select(ob => new ObjectItemModel() { Id = ob.Id, Name = ob.Name, Location = ob.City != null ? ob.Address + ", " + ob.City.Name : ob.Address, ImgSrc = ob.ObjectImages.Count > 0 ? ob.ObjectImages.ElementAt(0).Path : "/pink.png", Lat = ob.Lat, Lng = ob.Lng, Description = ob.Description, WebContact = ob.WebContact, EmailContact = ob.EmailContact, PhoneNumberContact = ob.PhoneNumberContact, Type = ob.ObjectType == null ? "" : ob.ObjectType.Name, NumberOfRatings = _touristObject.GetNumberOfRatings(ob.Id), Rating = Math.Round(_touristObject.GetAvarageRating(ob.Id), 2), }).ToList(); return(PartialView("_UserBookmarks", model)); }
public async Task <IActionResult> _UserBookmarks() { var user = await _userManager.GetUserAsync(User); if (user == null) { return(NotFound($"Nemoguće je pronaći korisnika koji ima ID '{_userManager.GetUserId(User)}'.")); } var model = new UserBookmarksModel() { IdentUserId = user.Id, }; var pager = new Pager(_user.CountUserBookmarks(user.Id), 1); model.Pager = pager; model.Bookmarks = _user.GetUserBookmarks(user.Id, pager.CurrentPage, pager.PageSize).Select(ob => new ObjectItemModel() { Id = ob.Id, Name = ob.Name, Location = ob.City != null ? ob.Address + ", " + ob.City.Name : ob.Address, ImgSrc = ob.ObjectImages.Count > 0 ? ob.ObjectImages.ElementAt(0).Path : "/pink.png", Lat = ob.Lat, Lng = ob.Lng, Description = ob.Description, WebContact = ob.WebContact, EmailContact = ob.EmailContact, PhoneNumberContact = ob.PhoneNumberContact, Type = ob.ObjectType == null ? "" : ob.ObjectType.Name, NumberOfRatings = _touristObject.GetNumberOfRatings(ob.Id), Rating = Math.Round(_touristObject.GetAvarageRating(ob.Id), 2), }).ToList(); //napravi view return(PartialView("_UserBookmarks", model)); }