Example #1
0
 public BrowsePlugin(BrowseViewModel browseViewModel)
 {
     ContentView = new BrowseView
     {
         DataContext = browseViewModel
     };
 }
Example #2
0
 public QuickRecipePage()
 {
     InitializeComponent();
     Title = "Browse";
     NavigationPage.SetHasNavigationBar(this, false);
     BindingContext = vm = new BrowseViewModel();
 }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the BrowseView class.
        /// </summary>
        public BrowseView()
        {
            InitializeComponent();
            BrowseViewModel vm = (BrowseViewModel)this.DataContext;

            vm.CloseAction = new Action(() => this.Close());
        }
        public JsonResult GetJsonBestHotels(int continent, int region, string pays, int ville)
        {
            var bvm = new BrowseViewModel
            {
                Continent = continent,
                Region    = region,
                Pays      = pays,
                Ville     = ville
            };


            // TODO change to SearchResutPartialViewItem serializé ??
            return(Json(SearchController.GetSearchResult(bvm)
                        .OrderByDescending(o => o.Hotel.NbReservations)
                        .Select(o => new
            {
                hotel = new {
                    nom = o.Hotel.Nom,
                    ville = o.Hotel.Villes.name.Trim(),
                    categorie = o.Hotel.Categorie.Value,
                    photo = o.Hotel.Photo,
                    id = o.Hotel.IdHotel
                },
                produits = o.Produits
                           .Select(p => new {
                    dateDepart = p.DateDepart.ToString("dd/MM/yyyy"),
                    prix = p.Promotion == 0 ? p.Prix : p.PrixSolde,
                    duree = p.Sejours.Duree
                })
                           .OrderBy(op => op.prix)
            }
                                )
                        .Take(2).ToList(), JsonRequestBehavior.AllowGet));
        }
        public BrowseViewModel GetBrowseViewModel(int gamerId, int genreId)
        {
            var viewModel = new BrowseViewModel();

            viewModel.Games = GetGamesByGenreForGamer(gamerId, genreId);
            return(viewModel);
        }
Example #6
0
        public ActionResult GetUsers(string filter, int page = 1)
        {
            FilterViewModel obj = FilterViewModel.ToObject(filter);

            var neededSkills = obj.Skills.Where(x => x.Level > 0).Select(x => new BllUserSkill {
                Skill = x.Skill, Level = x.Level
            });
            IEnumerable <BllUser> users;

            if (neededSkills.Count() < 1)
            {
                users = userService.UsersInRole(roleService.Find(programmerRole).Id);
            }
            else
            {
                users = userService.Get(neededSkills);
            }

            var usersForPage = users.Skip((page - 1) * usersPerPage).Take(usersPerPage).Cast <BllProgrammer>();

            BrowseViewModel browseModel = new BrowseViewModel
            {
                Filter    = obj,
                Users     = usersForPage.ToList(),
                Page      = page,
                PageCount = (int)Math.Ceiling((double)users.Count() / usersPerPage)
            };

            return(PartialView("_UsersPartial", browseModel));
        }
Example #7
0
        /// <summary>
        /// Attempts to unlock the provided cheat.
        /// </summary>
        /// <param name="cheat">The cheat to unlock</param>
        private void UnlockCheat(Cheat cheat)
        {
            if (!this.LockedCheatList.Contains(cheat))
            {
                throw new Exception("Cheat must be a locked cheat");
            }

            AccessTokens accessTokens = SettingsViewModel.GetInstance().AccessTokens;

            // We need the unlocked cheat, since the locked one does not include the payload
            try
            {
                UnlockedCheat unlockedCheat = SqualrApi.UnlockCheat(accessTokens.AccessToken, cheat.CheatId);

                BrowseViewModel.GetInstance().SetCoinAmount(unlockedCheat.RemainingCoins);

                this.LockedCheatList.Remove(cheat);
                this.UnlockedCheatList.Insert(0, unlockedCheat.Cheat);
                LibraryViewModel.GetInstance().OnUnlock(unlockedCheat.Cheat);
            }
            catch (Exception ex)
            {
                OutputViewModel.GetInstance().Log(OutputViewModel.LogLevel.Error, "Error unlocking cheat", ex);
            }
        }
Example #8
0
        /// <summary>
        /// Selects a specific game for which to view the store.
        /// </summary>
        /// <param name="game">The selected game.</param>
        public void SelectGame(Game game)
        {
            // Deselect current game
            this.IsCheatListLoading = true;
            this.LockedCheatList    = null;
            this.UnlockedCheatList  = null;

            Task.Run(() =>
            {
                try
                {
                    // Select new game
                    AccessTokens accessTokens = SettingsViewModel.GetInstance().AccessTokens;
                    StoreCheats storeCheats   = SqualrApi.GetStoreCheats(accessTokens.AccessToken, game.GameId);
                    this.LockedCheatList      = new FullyObservableCollection <Cheat>(storeCheats.LockedCheats);
                    this.UnlockedCheatList    = new FullyObservableCollection <Cheat>(storeCheats.UnlockedCheats);
                }
                catch (Exception ex)
                {
                    OutputViewModel.GetInstance().Log(OutputViewModel.LogLevel.Error, "Error loading cheats", ex);
                    BrowseViewModel.GetInstance().NavigateBack();
                }
                finally
                {
                    this.IsCheatListLoading = false;
                }
            });
        }
Example #9
0
        // [Route("Browse/ByEmployer/")]
        // [Route("Browse/ByEmployer/{name}")]
        public IActionResult ByEmployer([FromQuery] string name, int?page)
        {
            if (name == null || name == string.Empty)
            {
                return(this.Redirect("/Browse/Jobs/"));
            }

            if (!page.HasValue)
            {
                page = 1;
            }

            BrowseViewModel viewModel = new BrowseViewModel()
            {
                Name        = name,
                PagesCount  = (int)Math.Ceiling(this.jobPostsService.GetJobCountByEmployer(name) / GlobalConstants.ItemsPerPage),
                CurrentPage = (int)page,
            };

            viewModel.JobsDisplayViewModel = new JobsDisplayViewModel
            {
                JobPosts = this.jobPostsService.GetAllByEmployer <JobPostViewModel>(name, (int)page),
            };

            return(this.View(viewModel));
        }
Example #10
0
        public BrowsePage()
        {
            InitializeComponent();

            viewModel        = ViewModelLocator.Instance.BrowseViewModel;
            this.DataContext = viewModel;
        }
Example #11
0
        public ActionResult GetMorePosts(string category, int lastId)
        {
            BrowseViewModel model = new BrowseViewModel();

            model.Category = category;

            if (category == "none")
            {
                model.Posts = _browseServcie.getAdditionalPostsFromAllLatest(lastId).ToList();
            }
            else
            {
                model.Posts = _browseServcie.getAdditionalPostsFromCategory(category, lastId).ToList();
            }


            if (model.Posts.Count > 0)
            {
                return(PartialView("_AdditionalPosts", model));
            }
            else
            {
                return(null);
            }
        }
Example #12
0
        public IActionResult Search(int pageNumber, string searchText)
        {
            if (searchText != null && searchText.Length > 0)
            {
                pageNumber = pageNumber < 1 ? 1 : pageNumber;

                var searchTokens = searchText.ToLower().Split(" ", StringSplitOptions.RemoveEmptyEntries);

                var viewModel = new BrowseViewModel();

                if (this.User.Identity.IsAuthenticated)
                {
                    var userId    = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
                    var profileId = this.profilesService.GetId(userId);

                    viewModel.Posts = this.browseService.SearchPosts <PostViewModel>(searchTokens, pageNumber);
                    viewModel.Items = this.browseService.GetSearchCount(searchTokens);

                    foreach (var post in viewModel.Posts)
                    {
                        post.IsOwner = this.postsService.IsOwner(post.Id, profileId);
                        post.IsLiked = this.postsService.IsLiked(post.Id, profileId);

                        foreach (var comment in post.Comments)
                        {
                            comment.IsLiked = this.commentsService.IsLiked(comment.Id, profileId);
                        }

                        post.Comments.OrderByDescending(x => x.CreatedOn);
                    }
                }
                else
                {
                    viewModel.Posts = this.browseService.SearchPublicPosts <PostViewModel>(searchTokens, pageNumber);
                    viewModel.Items = this.browseService.GetSearchPublicCount(searchTokens);

                    foreach (var post in viewModel.Posts)
                    {
                        post.IsOwner = false;
                        post.IsLiked = false;

                        foreach (var comment in post.Comments)
                        {
                            comment.IsLiked = false;
                        }

                        post.Comments.OrderByDescending(x => x.CreatedOn);
                    }
                }

                viewModel.Profiles     = this.browseService.SearchProfiles <ProfileSearchViewModel>(searchTokens, pageNumber);
                viewModel.PageNumber   = pageNumber;
                viewModel.ItemsPerPage = 20;

                return(new JsonResult(viewModel));
            }

            return(this.BadRequest());
        }
Example #13
0
        public ViewResult Latest()
        {
            BrowseViewModel model = new BrowseViewModel();

            model.Posts = _browseServcie.getAllLatestItems().ToList();

            return(View(model));
        }
Example #14
0
        public static List <SearchResutPartialViewItem> GetSearchResult(BrowseViewModel bvm)
        {
            SearchBase s = new Search();

            s = new SearchOptionDestination(s, bvm.Continent, bvm.Region, bvm.Pays, bvm.Ville);
            s = new SearchOptionAPartirDAujourdHui(s);
            return(OrderingGroupResult(s));
        }
Example #15
0
        // GET: Browse
        public ActionResult Index()
        {
            var bvm = new BrowseViewModel();

            ViewBag.BestHotels = SearchController.GetSearchResult(bvm).OrderByDescending(o => o.Hotel.NbReservations).Take(2).ToList();

            return(View(bvm));
        }
Example #16
0
 public BrowseController(SpotifyBrowse browseRepo, IMapper mapper,
                         ICookieManager cookiesManager, BrowseViewModel model)
 {
     _mapper         = mapper;
     _browseRepo     = browseRepo;
     _model          = model;
     _cookiesManager = cookiesManager;
 }
Example #17
0
        public ViewResult Index()
        {
            BrowseViewModel model = new BrowseViewModel();

            //model.Posts = _browseServcie.getLatestItemsFromAllCategories().ToList();
            model.Posts = _browseServcie.getAllLatestItems().ToList();

            return(View("Latest", model));
        }
Example #18
0
        public ViewResult Category(string category)
        {
            BrowseViewModel model = new BrowseViewModel();

            model.Category = category;
            model.Posts    = _browseServcie.getLatestItemsByCategory(category).ToList();

            return(View(model));
        }
Example #19
0
 /// <summary>
 /// Create from service model
 /// </summary>
 /// <param name="model"></param>
 public BrowseViewApiModel(BrowseViewModel model)
 {
     if (model == null)
     {
         throw new ArgumentNullException(nameof(model));
     }
     ViewId    = model.ViewId;
     Version   = model.Version;
     Timestamp = model.Timestamp;
 }
Example #20
0
        public ViewResult CategoryAndTag(string category, string tag)
        {
            BrowseViewModel model = new BrowseViewModel();

            model.Category = category;
            model.Tag      = tag;
            model.Posts    = _browseServcie.getLatestItemsByCategoryAndTag(category, tag).ToList();

            return(View("Category", model));
        }
Example #21
0
        public async Task <IActionResult> Browse()
        {
            BrowseViewModel browseViewModel = new BrowseViewModel();

            browseViewModel.Meals = await _context.Meals
                                    .Include(m => m.MealCategories)
                                    .Include(m => m.MealIngredients)
                                    .ToListAsync();

            return(View(browseViewModel));
        }
Example #22
0
        public ActionResult Browse()
        {
            var model = new BrowseViewModel();

            foreach (var productGroup in _cardService.ProductGroups())
            {
                model.ProductGroups.Add(new ProductGroupViewModel(productGroup));
            }

            return(View(model));
        }
Example #23
0
        public IActionResult Browse(bool noLayout)
        {
            BrowseViewModel model = factory.CreateBrowser();
            if (model == null)
                return NotFound();

            if (noLayout)
                return PartialView("_Browser", model);
            else
                return View(model);
        }
Example #24
0
        public async Task <IActionResult> Browse()
        {
            var events = await _eventsService.ListAllEventsAsync();

            var model = new BrowseViewModel
            {
                Events = _mapper.Map <IEnumerable <Event>, IEnumerable <BrowseEventViewModel> >(events),
                Filter = new FilterEventsViewModel()
            };

            return(View(model));
        }
Example #25
0
        public ActionResult Browse()
        {
            IEnumerable <UrlItem> items = _urlRepo.All().OrderByDescending(i => i.CreatedOn);
            var itemsWithLastHit        = GetUrlItemsForViewModel(items);

            var model = new BrowseViewModel {
                Items        = itemsWithLastHit.Take(100),
                TableCaption = ViewRes.Browse.TableCaptionNewest100
            };

            return(View(model));
        }
Example #26
0
 /// <summary>
 /// Create from service model
 /// </summary>
 /// <param name="model"></param>
 public static BrowseViewApiModel ToApiModel(
     this BrowseViewModel model)
 {
     if (model == null)
     {
         return(null);
     }
     return(new BrowseViewApiModel {
         ViewId = model.ViewId,
         Version = model.Version,
         Timestamp = model.Timestamp
     });
 }
Example #27
0
 public void BackendErrorWhenRequestingPopularMoviesTest()
 {
     try
     {
         faultyMockClient.Setup(x => x.GetPopularMovies(It.IsAny <List <Genre> >())).Throws(new BadBackendRequestException());
         faultyViewModel = new BrowseViewModel(ex => { e = ex; exceptionHandled = true; }, preferences, faultyMockClient.Object);
     }
     catch
     {
         Assert.Fail();
     }
     Assert.IsTrue(exceptionHandled);
 }
Example #28
0
        public List <Hotels> GetHotelsList(int continent, int region, string pays, int ville)
        {
            var bvm = new BrowseViewModel
            {
                Continent = continent,
                Region    = region,
                Pays      = pays,
                Ville     = ville
            };


            // TODO change to SearchResutPartialViewItem serializé ??
            return(SearchController.GetSearchResult(bvm).Select(p => p.Hotel).ToList());
        }
Example #29
0
        public ActionResult Index()
        {
            if (User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Index", "Browse"));
            }
            else
            {
                BrowseViewModel model = new BrowseViewModel();
                model.Posts = _browseServcie.getLatestItemsByDate().ToList();

                return(View(model));
            }
        }
 /// <summary>
 /// Convert diagnostics to request header
 /// </summary>
 /// <param name="viewModel"></param>
 /// <param name="context"></param>
 /// <returns></returns>
 public static ViewDescription ToStackModel(this BrowseViewModel viewModel,
                                            ServiceMessageContext context)
 {
     if (viewModel == null)
     {
         return(null);
     }
     return(new ViewDescription {
         Timestamp = viewModel.Timestamp ??
                     DateTime.MinValue,
         ViewVersion = viewModel.Version ??
                       0,
         ViewId = viewModel.ViewId.ToNodeId(context)
     });
 }
Example #31
0
        public ActionResult GetUsers(string filter, int page = 1)
        {
            FilterViewModel obj = FilterViewModel.ToObject(filter);

            var neededSkills = obj.Skills.Where(x => x.Level > 0).Select(x => new BllUserSkill { Skill = x.Skill, Level = x.Level });
            IEnumerable<BllUser> users;

            if (neededSkills.Count() < 1)
                users = userService.UsersInRole(roleService.Find(programmerRole).Id);
            else
                users = userService.Get(neededSkills);

            var usersForPage = users.Skip((page - 1) * usersPerPage).Take(usersPerPage).Cast<BllProgrammer>();

            BrowseViewModel browseModel = new BrowseViewModel
            {
                Filter = obj,
                Users = usersForPage.ToList(),
                Page = page,
                PageCount = (int)Math.Ceiling((double)users.Count() / usersPerPage)
            };

            return PartialView("_UsersPartial", browseModel);
        }