public async Task <ActionResult <BotSchedule> > PostBotSchedule(BotSchedule botSchedule) { _context.BotSchedule.Add(botSchedule); await _context.SaveChangesAsync(); return(CreatedAtAction("GetBotSchedule", new { id = botSchedule.Id }, botSchedule)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,StartDay,TimeOccur,DayOccur,FrequencyOccur")] BotSchedule botSchedule) { if (id != botSchedule.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(botSchedule); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BotScheduleExists(botSchedule.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(botSchedule)); }
public async Task <IActionResult> PutBotSchedule(int id, BotSchedule botSchedule) { if (id != botSchedule.Id) { return(BadRequest()); } _context.Entry(botSchedule).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BotScheduleExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Scheduling(BotSchedule botSchedule) { if (ModelState.IsValid) { _context.Add(botSchedule); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(botSchedule)); }
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)); }