public bool Edit(Order order) { bool completed = false; using (var context = Config.context) { try { var item = context.C_Order.Single(i => i.id == order.Id); // As not everything cannot be implemented in the second layer // Not everything can be changed, and thus cannot use Convert // as it will break data in the database. item.id = order.Id; //item.money = order.Money; //item.C_OrderItem //item.C_User item.timestamp = order.Timestamp; context.SaveChanges(); completed = true; } catch (Exception ex) { // log here } } return completed; }
public Order Convert(C_Order cOrder) { Order order = new Order(); order.Id = cOrder.id; //order.User = //order.Items = cOrder.C_OrderItems.ToList(); order.Money = (decimal)cOrder.money; order.Timestamp = cOrder.timestamp; return order; }
public C_Order Convert(Order order) { C_Order cOrder = new C_Order(); cOrder.id = order.Id; //cOrder.userId = order.User.Id; //cOrder.C_OrderItems cOrder.money = order.Money; cOrder.timestamp = order.Timestamp; return cOrder; }
public Order FindOrderById(int id) { using (var context = Config.context) { try { var data = context.C_Product.Single(i => i.id == id); Order order = new Order(); return order; } catch (Exception ex) { // log here } } return null; }
public bool Remove(Order order) { bool completed = false; using (var context = Config.context) { try { var item = context.C_Order.Single(i => i.id == order.Id); var data = context.C_Order.Remove(item); completed = true; } catch (Exception ex) { // log here } } return completed; }
public bool Insert(Order order) { bool completed = false; return completed; }
public bool Edit(Order order) { bool completed = false; return completed; }
public bool Insert(Order order) { bool completed = false; using (var context = Config.context) { try { var data = context.C_Order.Add(Convert(order)); context.SaveChanges(); completed = true; } catch (Exception ex) { // log here } } return completed; }