Пример #1
0
        public bool AddOrder(tblOrder order, List<tblOrderDetail> orderDetail, tblOrder_Shipping orderShipping)
        {
            try
            {
                web365db.tblOrder.Add(order);

                orderShipping.OrderID = order.ID;

                web365db.tblOrder_Shipping.Add(orderShipping);

                foreach (var item in orderDetail)
                {
                    item.OrderID = order.ID;

                    web365db.tblOrderDetail.Add(item);
                }

                var result = web365db.SaveChanges();

                return result > 0;
            }
            catch (Exception)
            {
                return false;
            }
        }
Пример #2
0
        public ActionResult Action(tblOrder objSubmit)
        {
            if (objSubmit.ID == 0)
            {
                objSubmit.DateCreated = DateTime.Now;
                objSubmit.DateUpdated = DateTime.Now;
                objSubmit.IsDeleted = false;
                objSubmit.IsViewed = true;
                orderRepository.Add(objSubmit);
            }
            else
            {
                var obj = orderRepository.GetById<tblOrder>(objSubmit.ID);

                UpdateModel(obj);

                objSubmit.DateUpdated = DateTime.Now;

                orderRepository.Update(obj);
            }

            return Json(new
            {
                Error = false
            }, JsonRequestBehavior.AllowGet);
        }