public void SaveOrder(Order order) { using (var context = new EFDbContext()) { var _order = new Order { AddressId = order.AddressId, UserId = order.UserId, OrderDate = DateTime.Now, OrderTotal = order.OrderTotal }; context.Orders.Add(_order); foreach (var detail in order.OrderDetails) { var _orderDetail = new OrderDetail { ProductId = detail.ProductId, Quantity = detail.Quantity, SizeId = detail.SizeId, ColorId = detail.ColorId, ManufacturerId = detail.ManufacturerId, SubTotal = detail.SubTotal, Order = _order }; context.OrderDetails.Add(_orderDetail); } context.SaveChanges(); } }
/// <summary> /// Verifies that the specified user name and password exist in the data source. /// </summary> /// <returns> /// true if the specified username and password are valid; otherwise, false. /// </returns> /// <param name="username">The name of the user to validate. </param><param name="password">The password for the specified user. </param> public override bool ValidateUser(string username, string password) { if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)) return false; using (var context = new EFDbContext()) { var user = (from u in context.Users where String.Compare(u.Username, username, StringComparison.OrdinalIgnoreCase) == 0 && String.Compare(u.Password, password, StringComparison.OrdinalIgnoreCase) == 0 // && !u.Deleted select u).FirstOrDefault(); return user != null; } }