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); }
public ViewResult HotDeal(HotDeal hot) { if (hot != null) { productRepository.UpdateHotDeal(hot); } return(View(hot)); }
public ViewResult HotDeal() { HotDeal hotDeal = productRepository.HotDeal; if (hotDeal == null) { hotDeal = new HotDeal(); } return(View(hotDeal)); }
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")); }
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(); }
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()); }
public void ClickHotDealLink() { HotDeal.Click(); }