コード例 #1
0
        //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" }));
            }
        }
コード例 #2
0
        public JsonResult DeleteVendorTermination(VendorTermination termination)
        {
            bool result = false;

            using (this.UoW)
            {
                this.UoW.VendorTerminations.Delete(termination);
                result = this.UoW.Commit() > 0;
            }
            return(Json(new { Success = result }));
        }