Exemplo n.º 1
0
 public IActionResult Create(Puzzle puzzle)
 {
     if (ModelState.IsValid)
     {
         _context.Puzzle.Add(puzzle);
         _context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewData["ShopId"] = new SelectList(_context.Shop, "ID", "Shop", puzzle.ShopId);
     return(View(puzzle));
 }
Exemplo n.º 2
0
        public IActionResult Create(IFormFile croppedImage1, string shortDesc, string longDesc, decimal originalPrice, decimal discountPrice)
        {
            //Save image
            var uploads = Path.Combine(_environment.WebRootPath, "Uploads");

            if (croppedImage1.Length > 0)
            {
                var prizeImageId = Guid.NewGuid().ToString();
                var fileName     = string.Format("{0}.jpg", prizeImageId);

                croppedImage1.SaveAs(Path.Combine(uploads, fileName));

                ImageResizer.ImageJob img1 = new ImageResizer.ImageJob(Path.Combine(uploads, fileName), Path.Combine(uploads, "Prizes", "400", fileName),
                                                                       new ImageResizer.Instructions("maxheight=400;&scale=both;format=jpg;mode=max"));

                img1.Build();

                ImageResizer.ImageJob img2 = new ImageResizer.ImageJob(Path.Combine(uploads, fileName), Path.Combine(uploads, "Prizes", "600", fileName),
                                                                       new ImageResizer.Instructions("maxheight=600;&scale=both;format=jpg;mode=max"));

                img2.Build();

                Prize newPrize = new Prize();
                newPrize.PrizeImage    = prizeImageId;
                newPrize.ShortDesc     = shortDesc;
                newPrize.LongDesc      = longDesc;
                newPrize.OriginalPrice = originalPrice;
                newPrize.DiscountPrice = discountPrice;

                newPrize.ShopId = 2;
                newPrize.Status = (int)EnumHelper.PrizeStatus.InProduction;

                if (ModelState.IsValid)
                {
                    _context.Prize.Add(newPrize);
                    _context.SaveChanges();
                }
            }

            return(View());
        }
Exemplo n.º 3
0
        public IActionResult ApprovePuzzle(int id, string approve)
        {
            Puzzle puzzle = _context.Puzzle.Single(m => m.ID == id);

            int status;

            if (approve != null)
            {
                puzzle.StartDate = DateTime.Now;
                status           = (int)EnumHelper.PuzzleStatus.InProduction;
            }
            else
            {
                status = (int)EnumHelper.PuzzleStatus.ToReview;
            }

            puzzle.Status = status;
            _context.Update(puzzle);
            _context.SaveChanges();
            return(RedirectToAction("ToApproveList"));
        }