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()); }
public ActionResult Design([Bind(Include = "form,IngredientSelect")] DesignClass design) { if (ModelState.IsValid) { string pizza = "1"; foreach (var item in design.form) { pizza = item.ToString(); } var list = context.Ingredients.ToList(); string pizzaSize = SelectedPizzaSize(pizza); Session["Pizza"] = pizzaSize; foreach (var item in design.IngredientSelect) { Session["Ingredients"] += SelectedIngredientsName(item) + " "; } decimal Total = SelectedPizzaPrice(pizzaSize); decimal TotalIngredient = 0; foreach (var item in design.IngredientSelect) { TotalIngredient += SelectedIngredientsPrice(item); } //Session["TotalIngredient"] = TotalIngredient; if (TotalIngredient == 0) { Session["Error"] = "Error"; return(RedirectToAction("Design", "Order")); } else { Total += TotalIngredient; Session["Total"] = Total; return(RedirectToAction("Final")); } } ViewBag.PizzaSizes = PizzaSizes(null); List <SelectListItem> ingredientShows = new List <SelectListItem>(); foreach (var item in context.Ingredients) { ingredientShows.Add(new SelectListItem() { Text = item.dIngredient, Value = item.IngredientId.ToString() }); } ViewBag.TotalDrop = ingredientShows.Count(); ViewBag.IngredientSelect = ingredientShows; return(View()); }
// public ClassViewModel() { RelationPropertyAStructChangedCommand = new Microsoft.Practices.Prism.Commands.DelegateCommand(RelationPropertyAStructChanged); RelationPropertyBStructChangedCommand = new Microsoft.Practices.Prism.Commands.DelegateCommand(RelationPropertyBStructChanged); DesignClass = new DesignClass(); DesignClass.ClassID = -1; DesignClass.State = "added"; ListCollectionView listCollectionView = (ListCollectionView)CollectionViewSource.GetDefaultView(ApplicationDesignCache.NamespaceSource); listCollectionView.SortDescriptions.Add(new SortDescription("NamespaceName", ListSortDirection.Ascending)); NamespaceSource = ApplicationDesignCache.NamespaceSource; SelectedNameSpace = ApplicationDesignCache.NamespaceSource.Where(item => item.NamespaceID == 55).FirstOrDefault(); listCollectionView = (ListCollectionView)CollectionViewSource.GetDefaultView(ApplicationDesignCache.StructSource); listCollectionView.SortDescriptions.Add(new SortDescription()); StructSource = ApplicationDesignCache.StructSource; RelationPropertyAStructSource = ApplicationDesignCache.StructSource; RelationPropertyBStructSource = ApplicationDesignCache.StructSource; IsEnableBaseClass = false; }