public void Create(Product product)
 {
     if (product.PieDetailId.HasValue && product.PieDetailId != -1)
     {
         var pieDetail = _pieDetailRepository.GetPieDetailById(product.PieDetailId.Value);
         product.PieDetail = pieDetail;
     }
     product.IsActive = true;
     _appDbContext.Products.Add(product);
     _appDbContext.SaveChanges();
 }
Beispiel #2
0
 public IActionResult AddPieOfTheWeek(int pieDetailId)
 {
     try
     {
         var pieDetail = _pieDetailRepository.GetPieDetailById(pieDetailId);
         pieDetail.IsPieOfTheWeek = true;
         _pieDetailRepository.Update(pieDetail);
         return(Ok());
     }
     catch
     {
         return(BadRequest());
     }
 }
        public IActionResult AddPieToPieDetail(Pie pie)
        {
            if (ModelState.IsValid)
            {
                var pieId = _pieRepository.Add(pie);

                return(RedirectToAction("EditPieDetail/" + pieId.PieDetailId));
            }

            pie.PieDetail = _pieDetailRepository.GetPieDetailById(pie.PieDetailId);
            return(View(pie));
        }
        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));
        }
Beispiel #5
0
        public IActionResult AddPieDetailChild(int pieDetailId)
        {
            var pieDetail       = _pieDetailRepo.GetPieDetailById(pieDetailId);
            ProductViewModel vm = new ProductViewModel();
            var baseProduct     = _pieDetailRepo.GetChildren(pieDetailId).FirstOrDefault();

            if (baseProduct != null)
            {
                vm.Category        = baseProduct.Category;
                vm.IsActive        = baseProduct.IsActive;
                vm.IsOnSale        = baseProduct.IsOnSale;
                vm.MinOrderAmount  = baseProduct.MinOrderAmount;
                vm.MultipleAmount  = baseProduct.MultipleAmount;
                vm.PreparationTime = baseProduct.PreparationTime;
                vm.Price           = baseProduct.Price;
                vm.PriceInStore    = baseProduct.PriceInStore;
                vm.Temperature     = baseProduct.Temperature;
            }
            vm.PieDetails  = _pieDetailRepo.PieDetails;
            vm.PieDetail   = pieDetail;
            vm.PieDetailId = pieDetail.PieDetailId;
            vm.Ingredients = pieDetail.Ingredients;
            return(View("Product", vm));
        }