// ACTION: ADD TO CART // Adds item to cart, if more than one of the same product is added the CartItem 'Quantity' parameter is increased public ActionResult AddToCart(int id) { Session["CartCount"] = (int)Session["CartCount"] + 1; foreach (Models.Instrument product in productListAll) { if (product.ID == id) { userdata = Models.UserData.GetUserData((int)Session["UserID"]); if (userdata.ShoppingCartList == null) { userdata.ShoppingCartList = new List <UserData.CartItem>(); } // Increase "Quantity" if product already exists in cart var exists = false; foreach (var cartitem in userdata.ShoppingCartList) { if (cartitem.ProductID == id) { exists = true; cartitem.Quantity++; } } // Add item to cart if (exists == false) { userdata.ShoppingCartList.Add(new UserData.CartItem { ProductID = product.ID, ProductName = product.ProductName, Price = product.Price, Quantity = 1 }); } UserData.SaveUserData(userdata); } } string category = (string)TempData["Category"]; // Stay in category, used by HOME/INDEX ViewModel VM = ViewModel.View(productListAll, userdata, category); // Redirect to product info page if AddtoCart button was pressed there.. if (TempData["ProductInfo"] is int) { Instrument productdata = productListAll.Where(x => x.ID == id).FirstOrDefault(); return(RedirectToAction("Product", "Home", productdata)); } return(RedirectToAction("Index", "Home", VM)); }
public GUIUserData(Models.UserData userData) { InitializeComponent(); Username.Text = userData.Username; Nickname.Text = userData.NickName; Email.Text = userData.Email; GamesWonValue.Text = userData.GamesWon.ToString(); GamesLostValue.Text = userData.GamesLost.ToString(); }
public LobbyRoomController(GUIPages.GUILobbyRoom _parent, Communication _com) { parent = _parent; com = _com; GameRooms = new List <Models.GameRoom>(); userData = new Models.UserData(); loadedDataChecklist = new List <bool>() { false, false, false, parent.CardCollectionLoaded }; }
// ACTION: BUY // Reset cart counter and send bought products to Reciept page public ActionResult Buy() { userdata = Models.UserData.GetUserData((int)Session["UserID"]); Session["CartCount"] = 0; // Reset CartItem-counter on Shopping Cart-icon TempData["UserData"] = userdata; // Copy Shopping List for Reciept ViewModel VM = ViewModel.View(productListAll, userdata); return(RedirectToAction("Reciept", VM)); }
public ActionResult Index(Models.UserData User) { if (User.Name == "root" && SHA256Hash(User.Password) == "") { Session["isAuthed"] = true; ViewBag.WelcomeMessage = "환영합니다, root"; ViewBag.OtherMessage = "무엇을 도와드릴까요?"; } return(View(new Models.UserData())); }
private void setGetUDataParams(string code, string state) { if (GetUData == null) { GetUData = new Models.UserData(); } Dictionary <string, string> result = OauthLogin.getUserInfo(code); GetUData.OpenId = result[OauthLogin.OPEN_ID]; GetUData.Nick_Name = result[OauthLogin.NICK_NAME]; GetUData.Head_Img_Url = result[OauthLogin.HEAD_IMG_URL]; GetUData.Controller = state; }
//[Dependency] //public RMS_MenusBiz uBiz { get; set; } //[Dependency] //public RMS_UserBiz userBiz { get; set; } public ActionResult Index() { string code = Request["code"]; if (GetUData == null) { GetUData = new Models.UserData(); } GetUData.OpenId = "ov0HljubVsu4mOIfZsTMry_s3CNM"; if (code != null && code != "") { GetUData.OpenId = OauthLogin.getOpenId(code); } return(View()); }
//推荐链接解码 public ActionResult decoderRecommendUrl() { string recommendId = FilterTools.FilterSpecial(DESProvider.Decrypt(Request["param"], ConstantList.ENCRYPT_KEY)); string type = FilterTools.FilterSpecial(Request["type"]); if (type.Equals("recommend")) { if (GetUData == null) { GetUData = new Models.UserData(); } GetUData.User_Id = getUserIdByRecommendId(recommendId); return(Redirect(redirctUrl("home"))); } return(View()); }
public IActionResult HomeUser() { StreamReader reader = new StreamReader(new FileStream("data.txt", FileMode.Open)); string str = reader.ReadToEnd(); reader.Close(); string _Login = null, _password = null; foreach (var a in str.Split("|")) { _Login = a.Split(",").First(); _password = a.Split(",").Take(2).Last(); if (_Login == _login && _password == _Password) { var model = new Models.UserData(a.Split(",").Take(1).Last(), a.Split(",").Take(2).Last(), a.Split(",").Take(3).Last(), a.Split(",").Take(4).Last(), a.Split(",").Take(5).Last(), a.Split(",").Take(6).Last(), DateTime.Parse(a.Split(",").Take(7).Last())); return(View()); } } return(View()); }
public ActionResult CekUser(Models.UserData UserData) { var userDetail = new Models.UserData { }; using (con = new MySqlConnection(ConfigurationManager.ConnectionStrings["database"].ConnectionString)) { con.Open(); MySqlCommand cmd = new MySqlCommand(string.Format("SELECT * FROM user_data WHERE username = '******' AND password = '******'", UserData.Username, UserData.Password), con); using (MySqlDataReader read = cmd.ExecuteReader()) if (read.HasRows) { read.Read(); userDetail = new Models.UserData { UserID = Convert.ToInt32(read["id"]), Username = read["username"].ToString(), Password = read["password"].ToString(), Role = read["role"].ToString() }; } if (userDetail != null) { Session["userID"] = userDetail.UserID; Session["user"] = userDetail.Username; Session["role"] = userDetail.Role; switch (userDetail.Role) { case "admin": return(RedirectToAction("Index", "Admin")); case "user": return(RedirectToAction("Index", "Home")); } } UserData.ErrorMessage = "Username Atau Password Salah!"; return(View("Index", UserData)); } }
public IActionResult Login(string Login, string password) { if (Login == null && password == null) { ViewData["error"] = @"Введите логин и пароль"; return(View()); } else { StreamReader reader = new StreamReader(new FileStream("data.txt", FileMode.Open)); string str = reader.ReadToEnd(); reader.Close(); string _Login = null, _password = null; foreach (var a in str.Split("|")) { _Login = a.Split(",").First(); _password = a.Split(",").Take(2).Last(); if (_Login == Login && _password == password) { _login = Login; _Password = password; var model = new Models.UserData(a.Split(",").Take(1).Last(), a.Split(",").Take(2).Last(), a.Split(",").Take(3).Last(), a.Split(",").Take(4).Last(), a.Split(",").Take(5).Last(), a.Split(",").Take(6).Last(), DateTime.Parse(a.Split(",").Take(7).Last())); return(View("Views/Home/HomeUser.cshtml", model)); } else if (_Login == Login) { ViewData["error"] = @"Неверный пароль"; return(View()); } else { ViewData["error"] = @"Неверный логин или пароль"; } } return(View()); } }
public IActionResult Registration(string Login, string password, string password1, string Name, string Email, string pol, string Age ) { ViewData["er"] = "Заполните форму"; ViewData["color"] = "black"; ViewData["color2"] = "black"; ViewData["pass"] = "******"; if (password == password1 && password != null) { try { Startup.UserDate.Add(new Models.UserData(Login, password, Name, Email, Age, pol, DateTime.Now)); if (Models.UserData.GetUsers(new StreamReader(new FileStream("data.txt", FileMode.Open)), Login) == true) { System.IO.File.AppendAllText("Data.txt", new Models.UserData(Login, password, Name, Email, Age, pol, DateTime.Now).ToString()); } else { throw new Exception(); } } catch (ArgumentNullException e) { return(View()); } catch (ArgumentOutOfRangeException e) { ViewData["color2"] = "red"; ViewData["er"] = e.ParamName; return(View()); } catch (FormatException e) { ViewData["color2"] = "red"; ViewData["er"] = "Некорректный возрост достуны только символы 0-120"; return(View()); } catch (Exception e) { ViewData["color2"] = "red"; ViewData["er"] = "Данный логин уже существует"; return(View()); } } else if (password != null) { ViewData["pass"] = "******"; ViewData["color"] = "red"; return(View()); } else { ViewData["pass"] = "******"; return(View()); } var model = new Models.UserData(Login, password, Name, Email, Age, pol, DateTime.Now); return(View("Views/Home/HomeUser.cshtml", model)); }