Exemplo n.º 1
0
        public void DeleteClientOrder(int Id)
        {
            Client_Order dbEntry = _context.CLIENT_ORDERS.FirstOrDefault(o => o.ID == Id);

            if (dbEntry != null)
            {
                _context.CLIENT_ORDERS.Remove(dbEntry);
                _context.SaveChanges();
            }
        }
Exemplo n.º 2
0
        // PUT: api/CustomerOrder/5
        public string Put(int id, HttpRequestMessage value)
        {
            try
            {
                Client_Order co = new Client_Order();
                co = (from p in db.Client_Order
                      where p.Client_Order_ID == id
                      select p).First();

                string  message = HttpContext.Current.Server.UrlDecode(value.Content.ReadAsStringAsync().Result).Substring(5);
                JObject json    = JObject.Parse(message);

                co.Client_Order_Status_ID = (int)json["status_ID"];
                co.Client_Order_Type_ID   = (int)json["order_type"];
                co.Delivery_Method_ID     = (int)json["delivery_method"];
                co.Reference_ID           = (string)json["reference"];
                co.VAT_Inclu  = Convert.ToBoolean((string)json["vat"]);
                co.Comment    = (string)json["comment"];
                co.Contact_ID = (int)json["Contact_ID"];

                string errorString = "false|";
                bool   error       = false;

                if ((from t in db.Client_Order
                     where t.Reference_ID == co.Reference_ID && t.Client_Order_ID != id
                     select t).Count() != 0)
                {
                    error        = true;
                    errorString += "The Customer Order Reference entered already exists on the system. ";
                }

                if (error)
                {
                    return(errorString);
                }

                db.SaveChanges();
                return("true|Customer Order successfully updated.");
            }
            catch (Exception e)
            {
                ExceptionLog.LogException(e, "CustomerOrderController PUT");
                return("false|An error has occured updating the Customer Order on the system.");
            }
        }
Exemplo n.º 3
0
 public void SaveClientOrder(Client_Order order)
 {
     if (order.ID == 0)
     {
         _context.CLIENT_ORDERS.Add(order);
     }
     else
     {
         Client_Order dbEntry = _context.CLIENT_ORDERS.FirstOrDefault(c => c.ID == order.ID);
         if (dbEntry != null)
         {
             dbEntry.ID_CLIENT         = order.ID_CLIENT;
             dbEntry.ID_PAYMENT_METHOD = order.ID_PAYMENT_METHOD;
             dbEntry.ID_PAYMENT_STATUS = order.ID_PAYMENT_STATUS;
             dbEntry.ORDER_DATE        = order.ORDER_DATE;
             dbEntry.STATUS            = order.STATUS;
             dbEntry.TOTAL             = order.TOTAL;
             dbEntry.CUR = order.CUR;
         }
     };
     _context.SaveChanges();
 }
Exemplo n.º 4
0
 void SaveClientOrder(Client_Order order) => _repo.SaveClientOrder(order);