public JsonResult DeleteVendorShipTo(VendorShipTo shipto) { bool result = false; using (this.UoW) { this.UoW.VendorShipTos.Delete(shipto); result = this.UoW.Commit() > 0; } return Json(new { Success = result }); }
public JsonResult SaveVendorShipTo(VendorShipTo shipto) { DateTime Now = DateTime.Now; string UserName = System.Web.HttpContext.Current.User.Identity.Name; var result = false; //if (ModelState.IsValid) //{ using (this.UoW) { if (shipto.VendorShipToID == Guid.Empty) { shipto.VendorShipToID = Guid.NewGuid(); shipto.InputDate = Now; shipto.InputBy = UserName; this.UoW.VendorShipTos.Insert(shipto); result = this.UoW.Commit() > 0; } else { shipto.LastModifiedDate = DateTime.Now; shipto.LastModifiedBy = UserName; this.UoW.VendorShipTos.Update(shipto); result = this.UoW.Commit() > 0; } } return Json(new { Success = result}); // } //else //{ // return Json(new { Success = result, Message = "Invalid Model" }); // } }
//public JsonResult GetVendorShipTos1(Guid vendorId, int pageSize, int currentPage) //{ // TGFContext db = new TGFContext(); // db.Configuration.ProxyCreationEnabled = false; // var shiptosQuery = db.VendorShipToes.Where(c => c.VendorID == vendorId); // var rowCount = shiptosQuery.Count(); // var shiptos = shiptosQuery.OrderBy(s => s.Recipient).Skip((currentPage - 1) * pageSize).Take(pageSize).ToList(); // return Json(new { Data = shiptos, VirtualRowCount = rowCount }, JsonRequestBehavior.AllowGet); //} public JsonResult SaveVendorShipTo(VendorShipTo shipto) { shipto.InputDate = DateTime.Now; shipto.LastModifiedDate = DateTime.Now; var result = false; //if (ModelState.IsValid) //{ using (this.UoW) { if (shipto.VendorShipToID == Guid.Empty) { shipto.VendorShipToID = Guid.NewGuid(); this.UoW.VendorShipTos.Insert(shipto); result = this.UoW.Commit() > 0; } else { this.UoW.VendorShipTos.Update(shipto); result = this.UoW.Commit() > 0; } } return Json(new { Success = result, VendorShipTo = shipto }); // } //else //{ // return Json(new { Success = result, Message = "Invalid Model" }); // } }