コード例 #1
0
 public BrowsePlugin(BrowseViewModel browseViewModel)
 {
     ContentView = new BrowseView
     {
         DataContext = browseViewModel
     };
 }
コード例 #2
0
 public QuickRecipePage()
 {
     InitializeComponent();
     Title = "Browse";
     NavigationPage.SetHasNavigationBar(this, false);
     BindingContext = vm = new BrowseViewModel();
 }
コード例 #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());
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        public BrowseViewModel GetBrowseViewModel(int gamerId, int genreId)
        {
            var viewModel = new BrowseViewModel();

            viewModel.Games = GetGamesByGenreForGamer(gamerId, genreId);
            return(viewModel);
        }
コード例 #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));
        }
コード例 #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);
            }
        }
コード例 #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;
                }
            });
        }
コード例 #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));
        }
コード例 #10
0
        public BrowsePage()
        {
            InitializeComponent();

            viewModel        = ViewModelLocator.Instance.BrowseViewModel;
            this.DataContext = viewModel;
        }
コード例 #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);
            }
        }
コード例 #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());
        }
コード例 #13
0
        public ViewResult Latest()
        {
            BrowseViewModel model = new BrowseViewModel();

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

            return(View(model));
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #16
0
 public BrowseController(SpotifyBrowse browseRepo, IMapper mapper,
                         ICookieManager cookiesManager, BrowseViewModel model)
 {
     _mapper         = mapper;
     _browseRepo     = browseRepo;
     _model          = model;
     _cookiesManager = cookiesManager;
 }
コード例 #17
0
        public ViewResult Index()
        {
            BrowseViewModel model = new BrowseViewModel();

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

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

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

            return(View(model));
        }
コード例 #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;
 }
コード例 #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));
        }
コード例 #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));
        }
コード例 #22
0
        public ActionResult Browse()
        {
            var model = new BrowseViewModel();

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

            return(View(model));
        }
コード例 #23
0
ファイル: MainController.cs プロジェクト: ridgew/FileUpload
        public IActionResult Browse(bool noLayout)
        {
            BrowseViewModel model = factory.CreateBrowser();
            if (model == null)
                return NotFound();

            if (noLayout)
                return PartialView("_Browser", model);
            else
                return View(model);
        }
コード例 #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));
        }
コード例 #25
0
ファイル: HomeController.cs プロジェクト: sumo300/trunc
        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));
        }
コード例 #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
     });
 }
コード例 #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);
 }
コード例 #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());
        }
コード例 #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));
            }
        }
コード例 #30
0
 /// <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)
     });
 }
コード例 #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);
        }