コード例 #1
0
        public ActionResult HotDeal()
        {
            HotDeal hotDeal = productRepository.HotDeal;

            if (hotDeal != null)
            {
                if (hotDeal.IsHotDeal == true)
                {
                    DateTime now = DateTime.Now;
                    if (DateTime.Compare(hotDeal.HotDealActionStartTime, now) <= 0 && DateTime.Compare(hotDeal.HotDealActionEndTime, now) >= 0)
                    {
                        //  if (Request.Cookies["HotDealActionEndTime"] == null)
                        {
                            HttpCookie cookie = new HttpCookie("HotDealActionEndTime");
                            cookie.Value   = hotDeal.HotDealActionEndTime.ToString();
                            cookie.Expires = hotDeal.HotDealActionEndTime;
                            Response.Cookies.Add(cookie);
                        }
                        return(PartialView("~/Views/Product/Sections/_HotDeal.cshtml", hotDeal));
                    }
                }
                else
                {
                    Response.Cookies["HotDealActionEndTime"].Value = null;
                }
            }
            return(null);
        }
コード例 #2
0
 public ViewResult HotDeal(HotDeal hot)
 {
     if (hot != null)
     {
         productRepository.UpdateHotDeal(hot);
     }
     return(View(hot));
 }
コード例 #3
0
        public ViewResult HotDeal()
        {
            HotDeal hotDeal = productRepository.HotDeal;

            if (hotDeal == null)
            {
                hotDeal = new HotDeal();
            }
            return(View(hotDeal));
        }
コード例 #4
0
ファイル: HomeController.cs プロジェクト: mehi441/final
        public ActionResult DeleteHot(int?id)
        {
            HotDeal hotDeal = db.HotDeals.Find(id);

            if (hotDeal == null)
            {
                return(HttpNotFound());
            }
            db.HotDeals.Remove(hotDeal);
            db.SaveChanges();

            return(RedirectToAction("HotDeal"));
        }
コード例 #5
0
        public async Task UpdateHotDeal(HotDeal hotDeal)
        {
            HotDeal hot = context.HotDeal.FirstOrDefault();

            if (hot != null)
            {
                hot.HotDealActionStartTime = hotDeal.HotDealActionStartTime;
                hot.HotDealActionEndTime   = hotDeal.HotDealActionEndTime;
                hot.HotDealTime            = hotDeal.HotDealTime;
                hot.HotDealToProducts      = hotDeal.HotDealToProducts;
                hot.IsHotDeal = hotDeal.IsHotDeal;
            }
            else
            {
                context.HotDeal.Add(hotDeal);
            }
            await context.SaveChangesAsync();
        }
コード例 #6
0
ファイル: HomeController.cs プロジェクト: mehi441/final
        public ActionResult CreateHot(HotDeal hotDeal)
        {
            if (ModelState.IsValid)
            {
                if (hotDeal.ProductOptionId == 0)
                {
                    ViewBag.ProductOptions = db.ProductOptions.Include("Product")
                                             .Include("Color")
                                             .Include("Product.Model")
                                             .Include("Product.Model.Brand")
                                             .ToList();
                    ModelState.AddModelError("", "please select product");
                    return(View());
                }
                else
                {
                    hotDeal.AddedDate = DateTime.Now;

                    hotDeal.EndDate = hotDeal.EndDateForm;

                    int hours = hotDeal.EndTime.Hour;
                    hotDeal.EndDate = hotDeal.EndDate.AddHours(hours);
                    int minutes = hotDeal.EndTime.Minute;
                    hotDeal.EndDate = hotDeal.EndDate.AddMinutes(minutes);


                    db.HotDeals.Add(hotDeal);
                    db.SaveChanges();

                    return(RedirectToAction("HotDeal"));
                }
            }

            ViewBag.ProductOptions = db.ProductOptions.Include("Product")
                                     .Include("Product.Model")
                                     .Include("Product.Model.Brand")
                                     .Include("Color")
                                     .ToList();
            return(View());
        }
コード例 #7
0
 public void ClickHotDealLink()
 {
     HotDeal.Click();
 }