public ActionResult Update(int HealthLibraryID) { //get health library info based on the passed in id and return it HealthLibrary HealthLibrary = db.HealthLibraries.FirstOrDefault(f => f.HealthLibraryID == HealthLibraryID); return(View(HealthLibrary)); }
//method for public show view public ActionResult PublicShow(int HealthLibraryID) { Debug.WriteLine("Showing details for post: " + HealthLibraryID); //get health library post based on id and return it HealthLibrary HealthLibrary = db.HealthLibraries.FirstOrDefault(f => f.HealthLibraryID == HealthLibraryID); return(View(HealthLibrary)); }
public ActionResult Show(int HealthLibraryID) { //check if the user is logged in and is an admin and direct to login if they are not an admin or logged in //put the rest of the code in an else statement Debug.WriteLine("Showing details for post: " + HealthLibraryID); //get health library post based on id and return it HealthLibrary HealthLibrary = db.HealthLibraries.FirstOrDefault(f => f.HealthLibraryID == HealthLibraryID); return(View(HealthLibrary)); }
public ActionResult Delete(int HealthLibraryID) { //check if the user is logged in and is an admin and direct to login if they are not an admin or logged in //put the rest of the code in an else statement Debug.WriteLine("Attemping to delete post: " + HealthLibraryID); //search for specific health library post based on passed in id HealthLibrary HealthLibrary = db.HealthLibraries.Find(HealthLibraryID); //delete the post and save changes db.HealthLibraries.Remove(HealthLibrary); db.SaveChanges(); //redirect to list view return(RedirectToAction("List")); }
public ActionResult Update(int HealthLibraryID, string Title, DateTime Date, string Body, bool Published) { //check if the user is logged in and is an admin and direct to login if they are not an admin or logged in //put the rest of the code in an else statement Debug.WriteLine("Attemping to update post: " + HealthLibraryID); //search for the specific health library post info HealthLibrary HealthLibrary = db.HealthLibraries.Find(HealthLibraryID); //bind new params HealthLibrary.Title = Title; HealthLibrary.Date = Date; HealthLibrary.Body = Body; HealthLibrary.Published = Published; //save changes db.SaveChanges(); //redirect to list view return(RedirectToAction("List")); }
public ActionResult Add(string Title, DateTime Date, string Body, bool Published) { //check if the user is logged in and is an admin and direct to login if they are not an admin or logged in //put the rest of the code in an else statement Debug.WriteLine("Attemping to add a new post: " + Title); //create a new health library post HealthLibrary HealthLibrary = new HealthLibrary(); //bind passed in params HealthLibrary.Title = Title; HealthLibrary.Date = Date; HealthLibrary.Body = Body; HealthLibrary.Published = Published; //add to the db and save db.HealthLibraries.Add(HealthLibrary); db.SaveChanges(); //redirect to list view return(RedirectToAction("List")); }