public ActionResult Update(int id) { var db = new MyDbDataContext(); //string cookieClient = Request.Cookies["name_client"].Value; //string deCodecookieClient = CryptorEngine.Decrypt(cookieClient, true); //string userName = deCodecookieClient.Substring(0, deCodecookieClient.IndexOf("||")); //var user = db.Users.FirstOrDefault(a => a.UserName == userName); //if (user.UserContent == true) //{ // int cout = 0; // HttpCookie langCookie = Request.Cookies["lang_client"]; // while (langCookie != null) // { // langCookie.Expires = DateTime.Now.AddDays(-30); // HttpContext.Response.Cookies.Add(langCookie); // cout++; // if (cout == 10) // break; // } // cout = 0; // HttpCookie nameCookie = Request.Cookies["name_client"]; // while (nameCookie != null) // { // nameCookie.Expires = DateTime.Now.AddDays(-30); // HttpContext.Response.Cookies.Add(nameCookie); // cout++; // if (cout == 10) // break; // } // CurrentSession.ClearAll(); // return View(); //} ViewBag.Title = "Udpate Promotion"; PromotionCode detailPro = db.PromotionCodes.FirstOrDefault(a => a.ID == id); if (detailPro == null) { TempData["Messages"] = "Does not exist"; return(RedirectToAction("Index")); } LoadData(); var pro = new EPromotionCode { Code = detailPro.Code, Rate = detailPro.Rate, StartDay = detailPro.StartDay, EndDay = detailPro.EndDay, Status = detailPro.Status, Total = detailPro.Total, Description = detailPro.Description, Used = detailPro.Used, }; return(View(pro)); }
public ActionResult Create() { var db = new MyDbDataContext(); string cookieClient = Request.Cookies["name_client"].Value; string deCodecookieClient = CryptorEngine.Decrypt(cookieClient, true); string userName = deCodecookieClient.Substring(0, deCodecookieClient.IndexOf("||")); var user = db.Users.FirstOrDefault(a => a.UserName == userName); if (user.UserContent == true) { int cout = 0; HttpCookie langCookie = Request.Cookies["lang_client"]; while (langCookie != null) { langCookie.Expires = DateTime.Now.AddDays(-30); HttpContext.Response.Cookies.Add(langCookie); cout++; if (cout == 10) { break; } } cout = 0; HttpCookie nameCookie = Request.Cookies["name_client"]; while (nameCookie != null) { nameCookie.Expires = DateTime.Now.AddDays(-30); HttpContext.Response.Cookies.Add(nameCookie); cout++; if (cout == 10) { break; } } CurrentSession.ClearAll(); return(Redirect("http://swallowtravel.com/admin")); } ViewBag.Title = "Add Promotion"; LoadData(); var Pro = new EPromotionCode(); return(View(Pro)); }
public ActionResult Create(EPromotionCode model) { using (var db = new MyDbDataContext()) { if (ModelState.IsValid) { try { if (db.PromotionCodes.ToList().Find(x => x.Code == model.Code) != null) { TempData["Messages"] = "is exist code"; return(View(model)); } var pro = new PromotionCode { Code = model.Code, Rate = model.Rate, StartDay = model.StartDay, EndDay = model.EndDay, Total = model.Total, Used = model.Used, Description = model.Description, Status = model.Status, }; db.PromotionCodes.InsertOnSubmit(pro); db.SubmitChanges(); TempData["Messages"] = "Successful"; return(RedirectToAction("Index")); } catch (Exception exception) { LoadData(); ViewBag.Messages = "Error: " + exception.Message; return(View(model)); } } LoadData(); return(View(model)); } }
public ActionResult Create() { var db = new MyDbDataContext(); //string cookieClient = Request.Cookies["name_client"].Value; //string deCodecookieClient = CryptorEngine.Decrypt(cookieClient, true); //string userName = deCodecookieClient.Substring(0, deCodecookieClient.IndexOf("||")); //var user = db.Users.FirstOrDefault(a => a.UserName == userName); //if (user.UserContent == true) //{ // int cout = 0; // HttpCookie langCookie = Request.Cookies["lang_client"]; // while (langCookie != null) // { // langCookie.Expires = DateTime.Now.AddDays(-30); // HttpContext.Response.Cookies.Add(langCookie); // cout++; // if (cout == 10) // break; // } // cout = 0; // HttpCookie nameCookie = Request.Cookies["name_client"]; // while (nameCookie != null) // { // nameCookie.Expires = DateTime.Now.AddDays(-30); // HttpContext.Response.Cookies.Add(nameCookie); // cout++; // if (cout == 10) // break; // } // CurrentSession.ClearAll(); // return View(); //} ViewBag.Title = "Add Promotion"; LoadData(); var Pro = new EPromotionCode(); return(View(Pro)); }
public ActionResult Update(EPromotionCode model) { //Kiểm tra xem alias thuộc tour này đã tồn tại chưa var db = new MyDbDataContext(); if (ModelState.IsValid) { try { PromotionCode Pro = db.PromotionCodes.FirstOrDefault(b => b.ID == model.ID); if (Pro != null) { Pro.Code = model.Code; Pro.StartDay = model.StartDay; Pro.EndDay = model.EndDay; Pro.Rate = model.Rate; Pro.Status = model.Status; Pro.Used = model.Used; Pro.Total = model.Total; Pro.Description = model.Description; db.SubmitChanges(); TempData["Messages"] = "Successful"; return(RedirectToAction("Index")); } } catch (Exception exception) { LoadData(); ViewBag.Messages = "Error: " + exception.Message; return(View()); } } LoadData(); return(View(model)); }