public async Task <ActionResult> Login(string username, string password) { try { ReturnData <Users> response = await UserAction.ValidateUser(username, password); if (response.code == 200) { Users user = response.data; int CookiesExpire = int.Parse(ConfigurationManager.AppSettings["cookiesExpire"].ToString()); FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(user.uid, user.username, DateTime.Now, DateTime.Now.AddMinutes(CookiesExpire), true, user.roles); string cookieContents = FormsAuthentication.Encrypt(ticket); var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, cookieContents) { Expires = ticket.Expiration, Path = FormsAuthentication.FormsCookiePath }; Response.Cookies.Add(cookie); return(RedirectToAction("Dashboard", "Home")); } else { ViewBag.ClassStatus = DesignClass.AlertDesign(response.code); ViewBag.Message = response.message; return(View()); } } catch (Exception ex) { ViewBag.ClassStatus = DesignClass.AlertDesign(500); ViewBag.Message = ex.Message; return(View()); } }
public async Task <ActionResult> Category(string category) { ReturnData <int> response = await products.AddCategory(category, User.Identity.Name); TempData["Alert"] = DesignClass.AlertDesign(response.code); TempData["Message"] = DesignClass.StandardMessage(response.code); return(Redirect("Category")); }
public async Task <ActionResult> Brands(string brand) { ReturnData <int> response = await products.AddBrands(brand, User.Identity.Name); TempData["Alert"] = DesignClass.AlertDesign(response.code); TempData["Message"] = DesignClass.StandardMessage(response.code); return(Redirect("Brands")); }
public async Task <ActionResult> Category() { ResponseAPI <categories> response = await products.GetCategory(); ViewBag.Code = response.code; ViewBag.GetBrandAlert = DesignClass.AlertDesign(response.code); ViewBag.GetBrandMessage = DesignClass.StandardMessage(response.code); ViewData["categories"] = response.data; return(View()); }