public async Task <ActionResult <BotQuestions> > PostBotQuestions(BotQuestions botQuestions) { _context.BotQuestions.Add(botQuestions); await _context.SaveChangesAsync(); return(CreatedAtAction("GetBotQuestions", new { id = botQuestions.Id }, botQuestions)); }
public async Task <IActionResult> PutBotQuestions(int id, BotQuestions botQuestions) { if (id != botQuestions.Id) { return(BadRequest()); } _context.Entry(botQuestions).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BotQuestionsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Question,BotScheduleId")] BotQuestions botQuestions) { if (id != botQuestions.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(botQuestions); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BotQuestionsExists(botQuestions.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(botQuestions)); }
public async Task <IActionResult> Create(BotQuestions botQuestions) { if (ModelState.IsValid) { _context.Add(botQuestions); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(botQuestions)); }
public async Task <IActionResult> Create(ScheduleViewModel ScheduleViewModel) { if (ModelState.IsValid) { var schedID = _context.BotSchedule.ToList().Count(); for (int j = 0; j < ScheduleViewModel.Respondents.Length; j++) { BotSchedule sched = new BotSchedule(); sched.Id = ScheduleViewModel.ID; sched.Date = ScheduleViewModel.StartDay; sched.Time = ScheduleViewModel.TimeOccur; sched.Monday = ScheduleViewModel.Monday.ToString().Substring(0, 1); sched.Tuesday = ScheduleViewModel.Tuesday.ToString().Substring(0, 1); sched.Wednesday = ScheduleViewModel.Monday.ToString().Substring(0, 1); sched.Thursday = ScheduleViewModel.Thursday.ToString().Substring(0, 1); sched.Friday = ScheduleViewModel.Friday.ToString().Substring(0, 1); sched.Saturday = ScheduleViewModel.Saturday.ToString().Substring(0, 1); sched.Sunday = ScheduleViewModel.Sunday.ToString().Substring(0, 1); sched.Creator = "Chris"; sched.ScheduleId = schedID; sched.Frequency = ScheduleViewModel.FrequencyOccur; sched.WelcomeMsg = ScheduleViewModel.WelcomeMsg; sched.Respondents = ScheduleViewModel.Respondents[j]; _context.Add(sched); await _context.SaveChangesAsync(); } for (int i = 0; i < ScheduleViewModel.Question.Length; i++) { BotQuestions quest = new BotQuestions(); quest.ScheduleId = schedID; quest.Questions = ScheduleViewModel.Question[i]; _context.Add(quest); await _context.SaveChangesAsync(); } //var SurveyId = _context.BotSchedule.ToList().LastOrDefault(); return(RedirectToAction(nameof(Scheduling))); } return(View(ScheduleViewModel)); }