public void AddOrder() { UserMapper userMapper = new UserMapper(); User loggedUser = userMapper.LoggedUser; var productMapper = new ProductMapper(); var order = new Samsung_Order(); order.userId = loggedUser.Id; order.totalPrice = Convert.ToInt32(shoppingCart.TotalPrice); using (var db = new EntitySamsung()) { db.Samsung_Order.Add(order); db.SaveChanges(); foreach (var item in shoppingCart.ShoppingCartItemsList) { var orderItem = new Samsung_OrderItem(); orderItem.orderId = order.id; orderItem.productId = item.IdProduct; orderItem.quantity = item.Quantity; db.Samsung_OrderItem.Add(orderItem); productMapper.EditStockProduct(item.IdProduct, item.Quantity); db.SaveChanges(); } } }
public static Boolean CheckCredentials(LoginVM userVm) { UserMapper userMapper = new UserMapper(); List<Samsung_User> recivedList = userMapper.GetAllSamsungUsers(); foreach (var item in recivedList) { if ((item.emailAddress.Equals(userVm.EmailAddress)) && (item.password.Equals(userVm.Password))) { return true; } } return false; }
public static Boolean RegisterUser(RegisterVM registerVm) { UserMapper userMapper = new UserMapper(); Samsung_User newUser = new Samsung_User(registerVm.FirstName, registerVm.LastName, registerVm.Zipcode, registerVm.DateOfBirth, registerVm.EmailAddress, registerVm.Password); Boolean succes = userMapper.CheckUserExistence(newUser); if (!succes) { userMapper.AddUser(newUser); return true; } return false; }
public static void GetAllSamsungUsers() { UserMapper userMapper = new UserMapper(); Samsung_User userSamsung = new Samsung_User(); userMapper.GetAllSamsungUsers(); }