public async Task <IActionResult> Create([Bind("ID,Question,QuestionID,Authors,QuestionDate,Answer")] QOTDAnswerCreateEditViewModel QOTDAnswerVM, IFormCollection form) { Debug.Print(QOTDAnswerVM.QuestionID.ToString()); //not sure I want to allow multiple authors // need to swich to creating a different row for each author instead of saving multiple author ids string AuthorIds = ""; foreach (string item in form["Authors"]) { string ite = item; AuthorIds += ite + ",,"; } QOTDAnswer qOTDAnswer = new QOTDAnswer(); qOTDAnswer.Question = QOTDAnswerVM.Question; qOTDAnswer.QuestionID = QOTDAnswerVM.QuestionID; qOTDAnswer.Answer = QOTDAnswerVM.Answer; qOTDAnswer.QuestionDate = QOTDAnswerVM.QuestionDate; qOTDAnswer.Author = AuthorIds; Debug.Print(qOTDAnswer.Author); if (ModelState.IsValid) { _context.Add(qOTDAnswer); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(qOTDAnswer)); }
public async Task <IActionResult> Create([Bind("ID,address,cost,bathrooms,squarefootage,bedrooms,emailID,zipcode,insertionDate,type,state,city")] USAHouses uSAHouses) { if (ModelState.IsValid) { _context.Add(uSAHouses); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(uSAHouses)); }
public async Task <IActionResult> Create([Bind("ID,GivenName,FamilyName,DateCreated,Creator")] ParticipantQOTD participantQOTD) { if (ModelState.IsValid) { _context.Add(participantQOTD); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(participantQOTD)); }
public async Task <IActionResult> Create([Bind("ID,Question,QuestionAuthor,QuestionDate,Theme")] QOTD qOTD) { if (ModelState.IsValid) { _context.Add(qOTD); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(qOTD)); }