protected void OnSafeClick(object sender, EventArgs e) { //todo: errorhandling var db = new M133_GoInternationalEntities1(); var currentUser = db.User.First(usr => usr.SessionId == Data.SessionId); var username = TextBoxUsername.Text; var password = TextBoxPassword.Text; var walletaddress = TextBoxWalletAddress.Text; if (username != currentUser.Username) { db.User.First(usr => usr.Id == currentUser.Id).Username = username; } if (password != currentUser.Password) { db.User.First(usr => usr.Id == currentUser.Id).Password = password; } if (walletaddress != currentUser.WalletAddress) { db.User.First(usr => usr.Id == currentUser.Id).WalletAddress = walletaddress; } db.SaveChanges(); }
protected void OnClick(object sender, EventArgs e) { var db = new M133_GoInternationalEntities1(); //todo: errorhandling if (TextBoxProductName.Text == String.Empty || TextBoxPrice.Text == String.Empty || TextBoxQuantity.Text == String.Empty || TextBoxDescription.Text == String.Empty) { return; } //todo: errorhandling var productName = TextBoxProductName.Text; var price = float.Parse(TextBoxPrice.Text); var quantity = float.Parse(TextBoxQuantity.Text); var description = TextBoxDescription.Text; //todo: errorhandling var currentUser = db.User.First(usr => usr.SessionId == Data.SessionId); var newProduct = new Product { Name = productName, Price = price, Quantity = quantity, Description = description, Seller = currentUser.Id }; AddProductToUser(newProduct, currentUser, db); db.Product.Add(newProduct); db.SaveChanges(); }
protected void Page_Load(object sender, EventArgs e) { var db = new M133_GoInternationalEntities1(); var products = db.Product.ToList().OrderByDescending(prd => prd.Id).ToList(); Products = products; }
protected void Submit_OnClick(object sender, EventArgs e) { var db = new M133_GoInternationalEntities1(); string output = null; var username = TextBoxUsername.Text; var password = TextBoxPassword.Text; try { var user = db.User.First(use => use.Username == username); if (user.Password != password) { LabelError.Visible = true; TextBoxPassword.Text = String.Empty; return; } Session.Timeout = 20; Data.SessionId = Session.SessionID; db.User.First(usr => usr.Username == username && usr.Password == password).SessionId = Data.SessionId; db.SaveChanges(); SiteMaster.Username = username; Response.Redirect(RedirectUrl ?? "/Default.aspx"); } catch (Exception) { LabelError.Visible = true; } TextBoxPassword.Text = String.Empty; }
protected void Page_Load(object sender, EventArgs e) { var db = new M133_GoInternationalEntities1(); //todo: errorhandling var currentUser = db.User.First(usr => usr.SessionId == Data.SessionId); this.CurrentUser = currentUser; }
private void Initialize(int id) { //todo: errorhandling var db = new M133_GoInternationalEntities1(); var user = db.User.First(use => use.Id == id); ProductsFromUser = user.Product.ToList(); CurrentUser = user; }
private void Initialize(int id) { var db = new M133_GoInternationalEntities1(); var product = db.Product.First(prd => prd.Id == id); this.Product = product; var seller = db.User.First(user => product.Seller == user.Id); this.Seller = seller; }
protected void Page_Load(object sender, EventArgs e) { var db = new M133_GoInternationalEntities1(); db.User.First(usr => usr.SessionId == Data.SessionId).SessionId = String.Empty; db.SaveChanges(); Session.Clear(); Session.Abandon(); Response.Redirect("/Default.aspx"); }
protected void Page_Load(object sender, EventArgs e) { var db = new M133_GoInternationalEntities1(); var user = new User(); user.Username = "******"; user.Password = "******"; if (Request.QueryString["redirectUrl"] != null) { RedirectUrl = Server.UrlDecode(Request.QueryString["redirectUrl"]); } }
protected void OnClick(object sender, EventArgs e) { var db = new M133_GoInternationalEntities1(); var username = TextBoxUsername.Text; var password = TextBoxPassword.Text; var wallettAddress = TextBoxWalletAddress.Text; if (db.User.Any(existinguser => existinguser.Username == username)) { LabelErrorUserExists.Visible = true; TextBoxPassword.Text = String.Empty; return; } if (username != String.Empty && password != String.Empty) { var user = new User(); user.Username = username; user.Password = password; if (wallettAddress != String.Empty) { user.WalletAddress = wallettAddress; } db.User.Add(user); db.SaveChanges(); Response.Redirect(RedirectUrl ?? "/Default.aspx"); } else { LabeErrorEmptyFields.Visible = true; TextBoxPassword.Text = String.Empty; return; } }
private void AddProductToUser(Product product, User user, M133_GoInternationalEntities1 db) { db.User.Find(user).Product.Add(product); }