public async Task <IActionResult> ShoesDetail(string id) { ViewBag.Account = HttpContext.Session.GetString("UserName"); if (id == null) { return(NotFound()); } return(RedirectToAction("Index", "ShoesManage", await shoesDao.GetObject(int.Parse(id)))); }
public async Task <IActionResult> Index() { ViewBag.Account = HttpContext.Session.GetString("UserName"); List <ExportBill> cart = new List <ExportBill>(); if (SessionHelper.GetObjectFromJson <List <ExportBill> >(HttpContext.Session, "Cart") != null) { cart = SessionHelper.GetObjectFromJson <List <ExportBill> >(HttpContext.Session, "Cart"); foreach (var item in cart) { item.Shoes = await shoesDao.GetObject(item.ShoesId); } ViewBag.Total = cart.Sum(item => item.Price * item.Quantity); ViewBag.Cart = cart; } else { List <Sell> list = await exportBillDao.GetList(); ViewBag.Cart = cart; ViewBag.Total = 0; } return(View()); }
// GET: /<controller>/ public async Task <IActionResult> Index(Shoes shoes) { ViewBag.Account = HttpContext.Session.GetString("UserName"); return(View(await shoesDao.GetObject(shoes.Id))); }
public async Task <IActionResult> Index(String username, String password) { if (HttpContext.Session.GetString("UserName") == null) { Account account = await context.Account.SingleOrDefaultAsync(x => x.UserName.Equals(username) && x.Password.Equals(password)); if (account == null) { TempData["Message"] = "Username or Password is not correct!"; return(View("Index")); } else { //var claims = new List<Claim> //{ // new Claim(ClaimTypes.Name, username) //}; //var userIdentity = new ClaimsIdentity(claims, "login"); //ClaimsPrincipal principal = new ClaimsPrincipal(userIdentity); CookieOptions cookie = new CookieOptions(); cookie.Expires = DateTime.Now.AddHours(1); if (account.Type.Equals(1)) { //await HttpContext.SignInAsync(principal); Response.Cookies.Append(account.UserName + account.Password, account.UserName, cookie); return(RedirectToAction("Index", "Dashboard", account)); } else { if (ShoesID == "") { Response.Cookies.Append(account.UserName + account.Password, account.UserName, cookie); return(RedirectToAction("Index", "Main", account)); } else { Response.Cookies.Append(account.UserName + account.Password, account.UserName, cookie); HttpContext.Session.SetString("Account", account.UserName + account.Password); HttpContext.Session.SetString("UserName", account.UserName); return(RedirectToAction("Index", "Shoes", await shoesDao.GetObject(int.Parse(ShoesID)))); } } } } else { string user = HttpContext.Session.GetString("UserName"); Account account = await accountDao.GetObject(user); if (account.Type.Equals(1)) { return(RedirectToAction("Index", "Dashboard", account)); } else { if (ShoesID == "") { return(RedirectToAction("Index", "Main", account)); } else { return(RedirectToAction("Index", "Shoes", await shoesDao.GetObject(int.Parse(ShoesID)))); } } } }
public async Task <IActionResult> ShoesInfo(string id) { return(RedirectToAction("Index", "Shoes", await shoesDao.GetObject(int.Parse(id)))); }