Ejemplo n.º 1
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id != null)
            {
                Match = await GetMatch(id);

                ResultsVM = new ResultsVM()
                {
                    MatchId = Match.MatchId
                };

                this.Games = new List <Game>();

                //Create 5 new games for result entry
                for (int i = 0; i < 5; i++)
                {
                    var game = new Game();
                    game.GameNo = i + 1;
                    Games.Add(game);
                }


                if (Match.Played == true)
                {
                    return(RedirectToPage("./Index"));
                }
            }
            else
            {
                return(RedirectToPage("./Index"));
            }

            return(Page());
        }
Ejemplo n.º 2
0
        public ActionResult Result()
        {
            string subName = Session["subName"] as string;
            int    id      = -1;

            if (subName == null)
            {
                string sub = Session["sub"] as string;
                id = int.Parse(sub);
            }
            else
            {
                id = filterService.getSubCatgoryIDFromName(subName);
            }

            string category    = filterService.GetCategoryNameFromSub(id);
            string subcategory = filterService.GetSubCateogryName(id);

            ViewBag.Categories = filterService.GetCategoryNames();
            ViewBag.SpecList   = resultsService.getSpecListForSubCategory(id);

            var model = new ResultsVM();

            model.SubCategoryID   = id;
            model.SpecList        = resultsService.getSpecListForSubCategory(id);
            model.SpecFilterList  = resultsService.getSpecFilters(id);
            model.Category        = category;
            model.SubCategory     = subcategory;
            model.Products        = resultsService.getAllProductsBySubCategory(id);
            model.IndividualSpecs = resultsService.getIndividualProperties(id);
            model.isFiltered      = false;

            return(View("Results", model));
        }
Ejemplo n.º 3
0
        public ActionResult SearchResults(string category, string subcategory, string subcategoryid)
        {
            Session["sub"] = subcategoryid;

            var model = new ResultsVM();

            model.SpecList = resultsService.getSpecListForSubCategory(int.Parse(subcategoryid));

            return(Json(new { url = Url.Action("Result", "Results") }));
        }
Ejemplo n.º 4
0
        public ActionResult FilterResults()
        {
            string sub = Session["sub"] as string;
            int    id  = int.Parse(sub);

            string y1    = Session["year1"] as string;
            int    year1 = int.Parse(y1);

            string y2    = Session["year2"] as string;
            int    year2 = int.Parse(y2);

            string category    = filterService.GetCategoryNameFromSub(id);
            string subcategory = filterService.GetSubCateogryName(id);

            ViewBag.Categories = filterService.GetCategoryNames();
            ViewBag.SpecList   = resultsService.getSpecListForSubCategory(id);

            var model = new ResultsVM();

            model.SubCategoryID   = id;
            model.SpecList        = resultsService.getSpecListForSubCategory(id);
            model.SpecFilterList  = resultsService.getSpecFilters(id);
            model.Year1           = year1;
            model.Year2           = year2;
            model.Category        = category;
            model.SubCategory     = subcategory;
            model.Products        = resultsService.getAllProductsBySubCategory(id);
            model.IndividualSpecs = resultsService.getIndividualProperties(id);

            List <int> specValues = Session["filterSpecs"] as List <int>;

            ViewBag.filterSpecs = Session["filterSpecs"] as List <int>;

            int i = 0;
            int j = 0;

            while (i < model.SpecList.Count)
            {
                string str1 = model.SpecList[i] + "Min";
                string str2 = model.SpecList[i] + "Max";
                ViewData[str1] = specValues[j].ToString();
                j++;
                ViewData[str2] = specValues[j].ToString();
                j++;

                i++;
            }

            model.isFiltered = true;

            return(View("Results", model));
        }
Ejemplo n.º 5
0
        private async Task ExecuteTranslate()
        {
            var translationResult = await ViewModel.Translate.Execute();

            if (translationResult.language != null && translationResult.result != null)
            {
                var resultList = Locator.Current.GetService <IExplorerLocator>().Open <ResultListVM>(openExisting: true);
                if (resultList != null)
                {
                    await resultList.AddResultVM.Execute(new ResultItemVM()
                    {
                        Name   = translationResult.result.Name,
                        Origin = translationResult.language.LanguageType,
                        Result = translationResult.result,
                    });
                }
                string id          = ResultsVM.GenerateID(translationResult.result);
                var    resultPanel = Locator.Current.GetService <IExplorerLocator>().Open <ResultsVM>(id: id, openExisting: true);
                if (resultPanel != null)
                {
                    resultPanel.Result = translationResult.result;
                }
            }
        }
        public ActionResult _SearchResults(SearchVM searchData)
        {
            List <ResultsVM> results = new List <ResultsVM>();

            ViewBag.NbrNight   = (searchData.LastNight - searchData.FirstNight).TotalDays + 1;
            ViewBag.FirstNight = searchData.FirstNight;
            ViewBag.LastNight  = searchData.LastNight;

            //on génère une première liste filtrée uniquement sur les dates
            List <Room> freeRooms = RoomManager.GetAllEmptyRoomsAtDateRange(searchData.FirstNight, searchData.LastNight);

            foreach (Room r in freeRooms)
            {
                //calcul du prix de la chambre pour la durée avec majoration de 20% si occupation > 70%
                int  priceForDates = 0;
                bool priceIncrease = false;

                for (DateTime day = searchData.FirstNight; day <= searchData.LastNight; day = day.AddDays(1.0))
                {
                    double hotelOccupationAtDate = HotelManager.GetHotelOccupationAtDateFromId(r.IdHotel, day);
                    if (hotelOccupationAtDate < 0.7)
                    {
                        priceForDates += (int)r.Price;
                    }
                    else
                    {
                        priceForDates += (int)((double)r.Price * 1.2);
                        priceIncrease  = true;
                    }
                }

                //calcul du nombre de place libre par hotel
                int hotelFreePlaces = freeRooms
                                      .Where(h => h.IdHotel == r.IdHotel)
                                      .Select(p => p.Type)
                                      .Sum();


                ResultsVM result = new ResultsVM
                {
                    Room            = r,
                    Hotel           = HotelManager.GetHotelFromId(r.IdHotel),
                    Pictures        = PictureManager.GetPictureFromRoomId(r.IdRoom),
                    PriceForDates   = priceForDates,
                    PriceIncreased  = priceIncrease,
                    HotelFreePlaces = hotelFreePlaces
                };

                results.Add(result);
            }

            ViewBag.freeRoomsAtDate = results.Count();

            //filtrage des options choisies
            List <ResultsVM> toRemove = new List <ResultsVM>();

            foreach (ResultsVM r in results)
            {
                bool filtered = false;
                //filtrage de la localisation
                if (searchData.Location != "Valais")
                {
                    if (searchData.Location != r.Hotel.Location)
                    {
                        filtered = true;
                    }
                }

                //filtrage par le nombre de places dans l'hotel
                if (searchData.Adultes > r.HotelFreePlaces)
                {
                    filtered = true;
                }

                //prix
                if (r.PriceForDates > searchData.MaxNightPrice)
                {
                    filtered = true;
                }

                //étoiles
                if (!searchData.Star1 && r.Hotel.Category == 1)
                {
                    filtered = true;
                }
                if (!searchData.Star2 && r.Hotel.Category == 2)
                {
                    filtered = true;
                }
                if (!searchData.Star3 && r.Hotel.Category == 3)
                {
                    filtered = true;
                }
                if (!searchData.Star4 && r.Hotel.Category == 4)
                {
                    filtered = true;
                }
                if (!searchData.Star5 && r.Hotel.Category == 5)
                {
                    filtered = true;
                }
                //sèche-cheveu
                if (searchData.HasHairDryer && !r.Room.HasHairDryer)
                {
                    filtered = true;
                }
                //parking
                if (searchData.HasParking && !r.Hotel.HasParking)
                {
                    filtered = true;
                }
                //tv
                if (searchData.HasTV && !r.Room.HasTV)
                {
                    filtered = true;
                }


                if (filtered)
                {
                    toRemove.Add(r);
                }
            }

            foreach (ResultsVM r in toRemove)
            {
                results.Remove(r);
            }

            List <ResultsVM> orderedList = results
                                           .OrderBy(p => p.PriceForDates)
                                           .ToList();

            return(PartialView(orderedList));
        }