//----------------------------
        protected void CreateDbContext()
        {
            DbContext = new TGFContext();

            // Do NOT enable proxied entities, else serialization fails
            DbContext.Configuration.ProxyCreationEnabled = false;

            // Load navigation properties explicitly (avoid serialization trouble)
            DbContext.Configuration.LazyLoadingEnabled = false;

            // Because Web API will perform validation, we don't need/want EF to do so
            DbContext.Configuration.ValidateOnSaveEnabled = false;

            //DbContext.Configuration.AutoDetectChangesEnabled = false;
        }
        public JsonResult SaveVendorTermination(VendorTermination termination)
        {
            DateTime Now = DateTime.Now;
            string UserName = System.Web.HttpContext.Current.User.Identity.Name;
            var result = false;

            if (ModelState.IsValid)
            {
                using (this.UoW)
                {
                    if (termination.VendorTerminationID == Guid.Empty)
                    {
                        termination.InputDate = Now;
                        termination.InputBy = UserName;
                        termination.LastModifiedDate = Now;
                        termination.VendorTerminationID = Guid.NewGuid();
                        this.UoW.VendorTerminations.Insert(termination);
                        result = this.UoW.Commit() > 0;
                    }
                    else
                    {
                        TGFContext db = new TGFContext();
                        termination.LastModifiedBy = UserName;
                        termination.LastModifiedDate = Now;
                        this.UoW.VendorTerminations.Update(termination);
                        result = this.UoW.Commit() > 0;
                    }
                }
                //return Json(new { Success = result, VendorShipTo = termination });
                return Json(new { Success = result});
            }
            else
            {
                return Json(new { Success = result, Message = "Invalid Model" });
            }
        }
 //public JsonResult GetVendorTerminations1(Guid vendorId, int pageSize, int currentPage)
 //{
 //    TGFContext db = new TGFContext();
 //    db.Configuration.ProxyCreationEnabled = false;
 //    var terminationsQuery = db.VendorTerminations.Include("Division1").Include("TerminationReason1").Where(c => c.VendorID == vendorId);
 //    var rowCount = terminationsQuery.Count();
 //    var terminations = terminationsQuery.OrderByDescending(s => s.TerminationDate).Skip((currentPage - 1) * pageSize).Take(pageSize).ToList();
 //    return Json(new { Data = terminations, VirtualRowCount = rowCount }, JsonRequestBehavior.AllowGet);
 //}
 public JsonResult SaveVendorTermination(VendorTermination termination)
 {
     var result = false;
     if (ModelState.IsValid)
     {
         using (this.UoW)
         {
             if (termination.VendorTerminationID == Guid.Empty)
             {
                 termination.InputDate = DateTime.Now;
                 termination.LastModifiedDate = DateTime.Now;
                 termination.VendorTerminationID = Guid.NewGuid();
                 this.UoW.VendorTerminations.Insert(termination);
                 result = this.UoW.Commit() > 0;
             }
             else
             {
                 TGFContext db = new TGFContext();
                 termination.LastModifiedDate = DateTime.Now;
                 this.UoW.VendorTerminations.Update(termination);
                 result = this.UoW.Commit() > 0;
             }
         }
         return Json(new { Success = result, VendorShipTo = termination });
     }
     else
     {
         return Json(new { Success = result, Message = "Invalid Model" });
     }
 }