public JsonResult Edit(DonHangCRUD model)
        {
            rs r;

            using (var trans = new TransactionScope())
            {
                try
                {
                    var entity = _DonHangServ.SingleOrDefault(s => s.Id == model.Id);
                    entity.TrangThaiGiaoHangId  = model.TrangThaiGiaoHangId;
                    entity.TrangThaiThanhToanId = model.TrangThaiThanhToanId;
                    entity.ModifiedDate         = DateTime.Now;
                    entity.GhiChuDonHang        = model.GhiChuDonHang;
                    _DonHangServ.Save();

                    int diemtichluy = __db.DonHangs.Where(w => w.UserId == entity.UserId && w.TrangThaiThanhToanId == 2).Sum(s => (int?)s.TongTienHang) ?? 0;
                    var user        = __db.Users.Find(entity.UserId);
                    __db.SaveChanges();

                    trans.Complete();
                    r = rs.T("Okay");
                }
                catch (Exception ex)
                {
                    r = rs.F("Lỗi: " + ex.Message);
                }
            }
            return(Json(r, JsonRequestBehavior.DenyGet));
        }
        public JsonResult Edit(DonHangCRUD model)
        {
            rs r;

            using (var trans = new TransactionScope())
            {
                try
                {
                    var entity = _DonHangServ.SingleOrDefault(s => s.Id == model.Id);
                    entity.TrangThaiGiaoHangId  = model.TrangThaiGiaoHangId;
                    entity.TrangThaiThanhToanId = model.TrangThaiThanhToanId;
                    entity.HTTTID        = model.HTTTID;
                    entity.ModifiedDate  = DateTime.Now;
                    entity.GhiChuDonHang = model.GhiChuDonHang;
                    _DonHangServ.Save();
                    trans.Complete();
                    r = rs.T("Okay");
                }
                catch (Exception ex)
                {
                    r = rs.F("Lỗi: " + ex.Message);
                }
            }
            return(Json(r, JsonRequestBehavior.DenyGet));
        }