public ActionResult GenerateCode(Models.PromotionCodes p) { if (p.Code == null || p.Code == "") { p.Code = (string)TempData["PromoCode"]; } ViewModel.PromotionCodes.PromotionCodes promotionCodes = new ViewModel.PromotionCodes.PromotionCodes(); promotionCodes.SavePromoCode(p); return(RedirectToAction("PromoCode")); }
private double?GetCustomerMargin() { try { if (Session["PromoCode"] != null && Session["PromoCode"].ToString() != "") { ViewModel.PromotionCodes.PromotionCodes promotionCodes = new ViewModel.PromotionCodes.PromotionCodes(); return(promotionCodes.GetPromoCodeByCoode(Session["PromoCode"].ToString()).Amount); } return(0); } catch { return(0); } }
public ActionResult Cart(string PromoCode, string DefaultPercentage) { if (PromoCode != null && PromoCode != "") { Session["PromoCode"] = PromoCode; ViewModel.PromotionCodes.PromotionCodes promotionCodes = new ViewModel.PromotionCodes.PromotionCodes(); var code = promotionCodes.GetPromoCodeByCoode(Session["PromoCode"].ToString()); if (code != null) { Session["Margin"] = code.Amount; TempData["Margin"] = code.Amount; } } else { Session["Margin"] = DefaultPercentage; TempData["Margin"] = DefaultPercentage; } return(RedirectToAction("cart")); }
public ActionResult GenerateCode(int?id) { Models.PromotionCodes promotionCodes = new PromotionCodes(); if (id == null) { Random generator = new Random(); string promoCode = generator.Next(0, 999999).ToString("D6"); TempData["PromoCode"] = promoCode; promotionCodes.Code = promoCode; promotionCodes.ExpiryDate = DateTime.Now; } else { ViewModel.PromotionCodes.PromotionCodes promo = new ViewModel.PromotionCodes.PromotionCodes(); promotionCodes = promo.GetPromoCodeById(id); promotionCodes.ExpiryDate = promotionCodes.ExpiryDate.Date; } return(View(promotionCodes)); }
//public ActionResult EditPromoCode(int id, string code,DateTime exp) //{ //} public ActionResult DeletePromoCode(int id) { ViewModel.PromotionCodes.PromotionCodes promotionCodes = new ViewModel.PromotionCodes.PromotionCodes(); promotionCodes.DeletePromoCode(id); return(RedirectToAction("PromoCode")); }
public ActionResult PromoCode() { ViewModel.PromotionCodes.PromotionCodes promotionCodes = new ViewModel.PromotionCodes.PromotionCodes(); return(View(promotionCodes.GetList())); }