public ActionResult Delete(int id) { //find the card with that particular id GetWellSoonCard Card = db.GetWellSoonCards.Find(id); /*GetWellSoonCard Card = db.GetWellSoonCards.SqlQuery("Select * from GetWellSoonCards where CardId = @id", new SqlParameter("@id", id)).FirstOrDefault();*/ //To do: Look into inner join Linq CardDesign Design = db.CardDesigns.SqlQuery("Select * from CardDesigns inner join GetWellSoonCards on GetWellSoonCards.CardDesignId = CardDesigns.CardDesignId where CardId = @id", new SqlParameter("@id", id)).FirstOrDefault(); Debug.WriteLine("I am trying to show card id" + id); ShowGetWell ShowGetWellViewModel = new ShowGetWell(); ShowGetWellViewModel.GetWellSoonCard = Card; ShowGetWellViewModel.CardDesign = Design; return(View(ShowGetWellViewModel)); }
public ActionResult Show(int id) { //grab the id of current logged in user to display their names, phone etc... string userId = User.Identity.GetUserId(); ApplicationUser currentUser = db.Users.FirstOrDefault(x => x.Id == userId); //display the cards and the design of cards GetWellSoonCard Card = db.GetWellSoonCards.Find(id); //GetWellSoonCard Card = db.GetWellSoonCards.SqlQuery("Select * from GetWellSoonCards where CardId = @id", new SqlParameter("@id", id)).FirstOrDefault(); //Look into Inner join CardDesign Design = db.CardDesigns.SqlQuery("Select * from CardDesigns inner join GetWellSoonCards on GetWellSoonCards.CardDesignId = CardDesigns.CardDesignId where CardId = @id", new SqlParameter("@id", id)).FirstOrDefault(); Debug.WriteLine("I am trying to show card id" + id); //instanciate the class ShowGetWell ShowGetWellViewModel = new ShowGetWell(); ShowGetWellViewModel.GetWellSoonCard = Card; ShowGetWellViewModel.CardDesign = Design; ShowGetWellViewModel.User = currentUser; return(View(ShowGetWellViewModel)); }