Esempio n. 1
0
        public ViewResult Index()
        {
            var result = new List <PieDetailViewModel>();

            foreach (var pieOfTheWeek in _pieRepository.PiesOfTheWeek.Take(3))
            {
                var p = new PieDetailViewModel()
                {
                    IsMobile       = this.Request.IsMobile(),
                    PrimaryPicture = _flickrRepository.GetAlbumPictures(pieOfTheWeek.FlickrAlbumId).PrimaryPicture,
                    PieDetail      = pieOfTheWeek,
                    Pies           = _pieRepository.ActivePies.Where(x => x.PieDetail.PieDetailId == pieOfTheWeek.PieDetailId)
                };
                result.Add(p);
            }
            ;
            var homeViewModel = new HomeViewModel
            {
                PiesOfTheWeek = result,
                HostUrl       = this.Request.HostUrl(),
                IsMobile      = this.Request.IsMobile()
            };

            return(View(homeViewModel));
        }
Esempio n. 2
0
        public void Return_Not_Null_ReadDescriptionCommand()
        {
            var connectivityMock = new Mock <IConnectionService>();
            var dialogogMock     = new Mock <IDialogService>();
            var navigationMock   = new Mock <INavigationService>();

            var pieDetailsViewModel = new PieDetailViewModel(
                connectivityMock.Object,
                navigationMock.Object,
                dialogogMock.Object
                );

            var readDescriptionCommand = pieDetailsViewModel.ReadDescriptionCommand;

            Assert.NotNull(readDescriptionCommand);
        }
        public IActionResult Details(int id)
        {
            var pieDetail = _pieDetailRepository.GetPieDetailById(id);

            if (pieDetail == null || pieDetail.FlickrAlbumId == 0)
            {
                return(NotFound());
            }

            var result = new PieDetailViewModel()
            {
                PieDetail = pieDetail, Pies = _pieRepository.ActivePies.Where(x => x.PieDetail.PieDetailId == pieDetail.PieDetailId)
            };

            result.PrimaryPicture     = _flickrRepository.GetAlbumPictures(pieDetail.FlickrAlbumId).PrimaryPicture;
            result.AlbumPitures       = _flickrRepository.GetAlbumPictures(pieDetail.FlickrAlbumId);
            result.RequestAbsoluteUrl = Request.AbsoluteUrl();

            return(View(result));
        }
        //public Dictionary<int, string> TimeEstimations(IEnumerable<Product> products)
        //{
        //    var timeEstimations = new Dictionary<int, string>();
        //    foreach (var time in products.Select(x => x.PreparationTime).Distinct())
        //        timeEstimations.Add(time, _calendar.GetSoonestPickupEstimateForUsers(time));
        //    return timeEstimations;
        //}

        public PieDetailViewModel MapDbPieDetailToPieDetailViewModel(PieDetail dbPieDetail)
        {
            var products = GetChildren(dbPieDetail.PieDetailId);
            // var times = TimeEstimations(products);

            var result = new PieDetailViewModel()
            {
                IsMobile       = _ctx.HttpContext.Request.IsMobile(),
                PrimaryPicture = _flickrRepository.GetAlbumPictures(dbPieDetail.FlickrAlbumId).PrimaryPicture,
                PieDetail      = dbPieDetail,
                Pies           = _pieRepository.ActivePies.Where(x => x.PieDetail.PieDetailId == dbPieDetail.PieDetailId)
            };

            result.Products = products
                              .Select(x => _mapper.Map <Product, ProductEstimationViewModel>(x));
            //.Select(x =>
            //{
            //    x.Estimation = times[x.PreparationTime];
            //    return x;
            //});

            return(result);
        }