public JsonResult Add(Order order)
        {
            if (ModelState.IsValid)
            {
                var cartList = (List<Cart>)Session["CartList"];
                _repository.AddOrder(order, cartList);
                Session["CartList"] = null;
                return Json(new { item = "Added" }, JsonRequestBehavior.AllowGet);
            }
            var allErrors = ModelState.Values.SelectMany(v => v.Errors);

            return Json(allErrors);
        }
        public void AddOrder(Order order, List<Cart> listGoods)
        {
            using (var db = new ShopContext())
            {
                db.Orders.Add(order);
                db.SaveChanges();

                var email = order.Email;
                const string subject = "Your Order Id";

                var text = "Your Order Id:" + Environment.NewLine + order.Id;
                MailSender.sendMail(subject, email, text);

                foreach (var item in listGoods)
                {
                    item.OrderId = order.Id;
                    db.Carts.Add(item);
                }
                db.SaveChanges();

            }
        }