Esempio n. 1
0
        //add flowers to favorite
        //by id
        public ActionResult AddToFavorite(int flowerId)
        {
            var flower = _flowerRepository.Flowers.Where(x => x.FlowerId == flowerId).FirstOrDefault();

            if (flower != null)
            {
                flower.IsFavorite = true;
                _flowerRepository.UpdateFlower(flower);
            }

            return(RedirectToAction("Favorite", "Flower"));
        }
Esempio n. 2
0
        public IActionResult EditFlower(EditFlowerViewModel editFlowerViewModel)
        {
            ViewData["categories"] = _categoryRepository.Categories.ToList();

            var flower = _flowerRepository.GetFlowerById(editFlowerViewModel.Id);

            if (flower != null)
            {
                flower.Name                 = editFlowerViewModel.Name;
                flower.ShortDescription     = editFlowerViewModel.ShortDescription;
                flower.LongDescription      = editFlowerViewModel.LongDescription;
                flower.Price                = editFlowerViewModel.Price;
                flower.ImageUrl             = editFlowerViewModel.ImageUrl;
                flower.ImageThumbnailUrl    = editFlowerViewModel.ImageThumbnailUrl;
                flower.IsFlowerPresentation = editFlowerViewModel.IsFlowerPresentation;
                flower.InStock              = editFlowerViewModel.InStock;
                flower.CategoryId           = editFlowerViewModel.CategoryId;

                _flowerRepository.UpdateFlower(flower);

                return(RedirectToAction(FManagement, _flowerRepository.FlowersAsViewModel));
            }

            return(RedirectToAction(FManagement, _flowerRepository.FlowersAsViewModel));
        }
Esempio n. 3
0
 public ActionResult Edit([Bind(Include = "Id,Name,Color")] Flower flower)
 {
     if (ModelState.IsValid)
     {
         flowerRepository.UpdateFlower(flower);
         return(RedirectToAction("Index"));
     }
     return(View(flower));
 }