Exemple #1
0
        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;
        }
Exemple #2
0
 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;
 }
Exemple #3
0
 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;
 }
Exemple #4
0
        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;
        }
Exemple #5
0
 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;
 }
Exemple #6
0
        public bool Insert(Order order)
        {
            bool completed = false;

            return completed;
        }
Exemple #7
0
        public bool Edit(Order order)
        {
            bool completed = false;

            return completed;
        }
Exemple #8
0
 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;
 }