public JsonResult LocationDelete(int LocationId) { Location_Table locations = db.Location_Table.Find(LocationId); // Details of patricular role to be deleted is obtained using it's id locations.LocationIsDeleted = true; //Obtained data record is made inactive by setting value of isdeleted field to one db.SaveChanges(); bool result = true; var redirectUrl = new UrlHelper(Request.RequestContext).Action("ManageLocation", "Admin"); return(Json(new { result, Url = redirectUrl }, JsonRequestBehavior.AllowGet)); }
public JsonResult LocationEdit(int LocationId, string LocationName, int LocationPIN, string LocationDescription) //updated values are passed as parameters of post function through ajax method { Location_Table locations = db.Location_Table.Find(LocationId); //Details of patricular product category to be edited is obtained using it's id locations.LocationName = LocationName; locations.LocationPIN = LocationPIN; locations.LocationDesc = LocationDescription; locations.LocationUpdatedBy = Session["user"].ToString(); locations.LocationUpdatedDate = DateTime.Now; locations.LocationIsDeleted = false; db.SaveChanges(); var redirectUrl = new UrlHelper(Request.RequestContext).Action("ManageLocation", "Admin"); //passing url to which control to be navigated is stored in a variable return(Json(new { LocationId = LocationId, LocationName = LocationName, LocationPIN = LocationPIN, LocationDesc = LocationDescription, Url = redirectUrl }, JsonRequestBehavior.AllowGet)); //Values updated and url is returned back to ajax success function }
public ActionResult ManageLocation(Location_Table locations) //new location is passed as object of Location_Table to post function ManageLocation { //if (ModelState.IsValid) //{ locations.LocationCreatedBy = Session["user"].ToString(); locations.LocationUpdatedBy = Session["user"].ToString(); locations.LocationCreatedDate = DateTime.Now; locations.LocationUpdatedDate = DateTime.Now; locations.LocationIsDeleted = false; /* Values are added */ db.Location_Table.Add(locations); //Adding values to ProductCategory_Table db.SaveChanges(); return(RedirectToAction("ManageLocation")); }
public JsonResult ServiceEdit(int ServiceId, string ServiceName, decimal DeliveryCharge, string ServiceDesc, string LocationName, string ProductName) { Product_Table product = new Product_Table(); Location_Table location = new Location_Table(); Service_Table service = db.Service_Table.Find(ServiceId); service.ServiceName = ServiceName; service.DeliveryCharge = DeliveryCharge; service.ServiceDesc = ServiceDesc; int locationId = (from l in db.Location_Table where l.LocationName == LocationName select l.LocationId).FirstOrDefault(); service.Locationid = locationId; int productId = (from p in db.Product_Table where p.ProductName == ProductName select p.ProductId).FirstOrDefault(); service.Productid = productId; service.ServiceUpdatedBy = Session["user"].ToString(); service.ServiceUpdatedDate = System.DateTime.Now; db.SaveChanges(); var redirectUrl = new UrlHelper(Request.RequestContext).Action("Manage_Service", "Service"); return(Json(new { ServiceId = ServiceId, ServiceName = ServiceName, DeliveryCharge = DeliveryCharge, ServiceDesc = ServiceDesc, LocationName = LocationName, ProductName = ProductName, Url = redirectUrl }, JsonRequestBehavior.AllowGet)); }