public void OrderFormView_InsertItem(WebshopClick.Model.BLL.Order order) { if (ModelState.IsValid) { try { Service service = new Service(); Orderrow orderrow = new Orderrow(); List<Item> cart = (List<Item>)Session["cart"]; if (cart.Count > 0) { service.UpdateOrder(order); foreach (Item item in cart) { orderrow.OrderID = order.OrderID; orderrow.ProductID = item.Product.ProductID; orderrow.TaxID = 1; orderrow.Quantity = item.Quantity; orderrow.Price = item.Product.Price; orderrow.Discount = Convert.ToDecimal(0); service.UpdateOrderrow(orderrow); orderrow.RowID = 0; } cart.Clear(); FlashPlaceHolder.Visible = true; } } catch (Exception) { ModelState.AddModelError(String.Empty, "Fel inträffade då beställning skulle genomföras."); } } }
public void UserFormView_InsertItem(WebshopClick.Model.BLL.User user) { //Checks if username already exists in the database TextBox userName = (TextBox)UserFormView.FindControl("Login"); Service service = new Service(); User checkUser = service.GetUserByLoginID(userName.Text); if (checkUser != null) { Session["Reg"] = true; PlaceHolderCheckFail.Visible = true; return; } //Salting password before hashing TextBox pswOriginal = (TextBox)UserFormView.FindControl("Password"); pswOriginal.Text = pswOriginal.Text + userName.Text; TextBox pswConfirm = (TextBox)UserFormView.FindControl("ConfirmPassword"); pswConfirm.Text = pswConfirm.Text + userName.Text; //Hashing of password string hash1 = PasswordHasher.Hash(pswOriginal.Text); string hash2 = PasswordHasher.Hash(pswConfirm.Text); if (ModelState.IsValid) { try { user.Password = hash1; service.UpdateUser(user); FlashPlaceHolder.Visible = true; isLoged(); } catch (Exception) { ModelState.AddModelError(String.Empty, "Fel inträffade då användare skulle läggas till."); } } }