public JsonResult DeleteVendorContact(VendorContact contact)
 {
     bool result = false;
     using (this.UoW)
     {
         this.UoW.VendorContacts.Delete(contact);
         result = this.UoW.Commit() > 0;
     }
     return Json(new { Success = result });
 }
        public JsonResult SaveVendorContact(VendorContact contact)
        {
            DateTime Now = DateTime.Now;
            string UserName = System.Web.HttpContext.Current.User.Identity.Name;
            var result = false;

            if (ModelState.IsValid)
            {
                using (this.UoW)
                {
                    if (contact.VendorContactID == Guid.Empty)
                    {
                        contact.VendorContactID = Guid.NewGuid();
                        contact.InputDate = Now;
                        contact.InputBy = UserName;
                        this.UoW.VendorContacts.Insert(contact);
                        result = this.UoW.Commit() > 0;
                    }
                    else
                    {
                        contact.LastModifiedBy = UserName;
                        contact.LastModifiedDate = Now;
                        this.UoW.VendorContacts.Update(contact);
                        result = this.UoW.Commit() > 0;
                    }
                }
                return Json(new { Success = result});
            }
            else
            {
                return Json(new { Success = result, Message = "Invalid Model" });
            }
        }
 //public JsonResult GetVendorContacts1(Guid vendorId, int pageSize, int currentPage)
 //{
 //    TGFContext db = new TGFContext();
 //    db.Configuration.ProxyCreationEnabled = false;
 //    var contactsQuery = db.VendorContacts.Include("Vendor").Where(c => c.VendorID == vendorId);
 //    var rowCount = contactsQuery.Count();
 //    var contacts = contactsQuery.OrderBy(c => c.Firstname).Skip((currentPage - 1) * pageSize).Take(pageSize).ToList();
 //    contacts.ForEach(c =>
 //    {
 //        c.Vendnum = c.Vendor.Vendnum;
 //    });
 //    return Json(new { Data = contacts, VirtualRowCount = rowCount }, JsonRequestBehavior.AllowGet);
 //}
 public JsonResult SaveVendorContact(VendorContact contact)
 {
     contact.InputDate = DateTime.Now;
     contact.LastModifiedDate = DateTime.Now;
     var result = false;
     if (ModelState.IsValid)
     {
         using (this.UoW)
         {
             if (contact.VendorContactID == Guid.Empty)
             {
                 contact.VendorContactID = Guid.NewGuid();
                 this.UoW.VendorContacts.Insert(contact);
                 result = this.UoW.Commit() > 0;
             }
             else
             {
                 this.UoW.VendorContacts.Update(contact);
                 result = this.UoW.Commit() > 0;
             }
         }
         return Json(new { Success = result, VendorContact = contact });
     }
     else
     {
         return Json(new { Success = result, Message = "Invalid Model" });
     }
 }