public void OnPost() { var author = new ClubMember { MemberID = 1, FName = "Walker", LName = "Chesley", }; //do something to save user created content here. var newContent = new Content { ContentTitle = contentTitle, ContentBody = contentBody, //add whoever is logged in as the author Author = author, }; try { _context.Content.Add(newContent); _context.SaveChanges(); } catch (Exception e) { _logger.LogWarning(e, "Error saving to database"); } }
public async Task <IActionResult> OnPost(int MemberId) { SingleMember = await _context.ClubMember.FindAsync(MemberId); SingleMember.FName = fName; SingleMember.LName = lName; SingleMember.ClubTitle = clubTitle; SingleMember.DuesPaid = duesPaid; try { _context.Update(SingleMember); _context.SaveChanges(); } catch (Exception e) { _logger.LogWarning(e, "Error updating member"); } return(RedirectToPage("Members")); }