コード例 #1
0
      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));
      }
コード例 #2
0
ファイル: USAHomesController.cs プロジェクト: crnr63/HomeBase
        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));
        }
コード例 #3
0
      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));
      }
コード例 #4
0
      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));
      }