public C_Visa Convert(Visa visa) { C_Visa cVisa = new C_Visa(); cVisa.ValidDate = visa.ValidDate; cVisa.ExpiryDate = visa.ExpiryDate; cVisa.CardNumber = visa.CardNumber; cVisa.CardSecurityCode = visa.CardSecurityCode; return cVisa; }
public Visa Convert(C_Visa cVisa) { Visa visa = new Visa(); visa.ValidDate = cVisa.ValidDate; visa.ExpiryDate = cVisa.ExpiryDate; visa.CardNumber = cVisa.CardNumber; visa.CardSecurityCode = cVisa.CardSecurityCode; return visa; }
public bool InsertOrderFromUser(int userId, Address address, Visa visa) { bool completed = false; using (var context = Config.context) { try { C_Order order = new C_Order(); // Get products in baskets and add them to order var data = context.C_Basket.Where(c => c.userId == userId).Select(c => new { c.C_Product }); foreach (var item in data) { C_OrderItem orderItem = new C_OrderItem(); orderItem.C_Product = item.C_Product; order.C_OrderItem.Add(new C_OrderItem()); } // Remove products in basket var baskets = context.C_Basket.Where(i => i.userId == userId); foreach (var item in baskets) context.C_Basket.Remove(item); // Setup order before adding it to database order.userId = userId; order.timestamp = DateTime.Now; // Setup address // Setup payment context.C_Order.Add(order); context.SaveChanges(); completed = true; } catch (Exception ex) { // log here } } return completed; }