public async Task <IActionResult> Add(CitizensAppeal citizensAppeal, ScheduleForWeek scheduleForWeek) { citizensAppeal.ScheduleForWeekID = db.SchedulesForWeek.Where(o => o.StartTime == scheduleForWeek.StartTime).FirstOrDefault().ScheduleForWeekID; if (citizensAppeal == null) { return(View()); } try { db.CitizensAppeals.Add(citizensAppeal); await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CitizensAppealExists(citizensAppeal.CitizensAppealID)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); }
public IActionResult Index(ScheduleForWeek scheduleForWeek) { var sessionSortState = HttpContext.Session.GetString("SortStateScheduleForWeek"); SortState sortOrder = new SortState(); if (sessionSortState != null) { sortOrder = (SortState)Enum.Parse(typeof(SortState), sessionSortState); } int?page = HttpContext.Session.GetInt32("ScheduleForWeekPage"); if (page == null) { page = 0; HttpContext.Session.SetInt32("ScheduleForWeekPage", 0); } IQueryable <ScheduleForWeek> schedulesForWeek = Sort(_context.SchedulesForWeek, sortOrder, scheduleForWeek.StartTime, (int)page); HttpContext.Session.SetObject("Patient", scheduleForWeek); ScheduleForWeeksViewModel schedulesForWeekView = new ScheduleForWeeksViewModel { ScheduleForWeekViewModel = scheduleForWeek, PageViewModel = schedulesForWeek, PageNumber = (int)page }; return(View(schedulesForWeekView)); }
public async Task <IActionResult> Add(ScheduleForWeek scheduleForWeek, TVShow tvShow) { scheduleForWeek.TVShowID = _context.TVShows.Where(o => o.NameShow == tvShow.NameShow).FirstOrDefault().TVShowID; if (scheduleForWeek == null) { return(View()); } try { _context.SchedulesForWeek.Add(scheduleForWeek); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ScheduleForWeekExists(scheduleForWeek.ScheduleForWeekID)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); }
public static void AddScheduleForWeek(ScheduleForWeek scheduleForWeekToAdd) { using (Context db = new Context()) { db.SchedulesForWeek.Add(scheduleForWeekToAdd); db.SaveChanges(); } }
public static ScheduleForWeek FindScheduleForWeekById(int id) { ScheduleForWeek scheduleForWeek = null; using (Context db = new Context()) { scheduleForWeek = db.SchedulesForWeek.Where(k => k.ScheduleForWeekID == id).ToList().FirstOrDefault(); } return(scheduleForWeek); }
public static void DeleteScheduleForWeek(ScheduleForWeek scheduleForWeekToDelete) { using (Context db = new Context()) { if (scheduleForWeekToDelete != null) { db.SchedulesForWeek.Remove(scheduleForWeekToDelete); db.SaveChanges(); } } }
public static void UpdataScheduleForWeek(ScheduleForWeek scheduleForWeek) { using (Context db = new Context()) { if (scheduleForWeek != null) { db.SchedulesForWeek.Update(scheduleForWeek); db.SaveChanges(); } } }
public IActionResult Index(SortState sortOrder = SortState.No, int index = 0) { ScheduleForWeek sessionScheduleForWeek = HttpContext.Session.GetObject <ScheduleForWeek>("Patient"); string sessionSortState = HttpContext.Session.GetString("SortStatePatient"); int? page = HttpContext.Session.GetInt32("Page"); if (page == null) { page = 0; HttpContext.Session.SetInt32("Page", 0); } else { if (!(page < 1 && index < 0)) { page += index; } HttpContext.Session.SetInt32("Page", (int)page); } if (sessionScheduleForWeek != null) { _scheduleForWeek = sessionScheduleForWeek; } if (sessionSortState != null) { if (sortOrder == SortState.No) { sortOrder = (SortState)Enum.Parse(typeof(SortState), sessionSortState); } } ViewData["NameSort"] = sortOrder == SortState.NameDesc ? SortState.NameAsc : SortState.NameDesc; HttpContext.Session.SetString("SortState", sortOrder.ToString()); IQueryable <ScheduleForWeek> ScheduleForWeeks = Sort(db.SchedulesForWeek, sortOrder, _scheduleForWeek.StartTime, (int)page); ScheduleForWeeksViewModel scheduleForWeeksView = new ScheduleForWeeksViewModel { ScheduleForWeekViewModel = _scheduleForWeek, PageViewModel = ScheduleForWeeks, PageNumber = (int)page }; return(View(scheduleForWeeksView)); }
public IActionResult Index(SortState sortOrder) { ScheduleForWeek sessionScheduleForWeek = HttpContext.Session.GetObject <ScheduleForWeek>("ScheduleForWeek"); string sessionSortState = HttpContext.Session.GetString("SortStateScheduleForWeek"); int? page = HttpContext.Session.GetInt32("ScheduleForWeekPage"); if (page == null) { page = 0; HttpContext.Session.SetInt32("ScheduleForWeekPage", 0); } if (sessionScheduleForWeek != null) { _scheduleForWeek = sessionScheduleForWeek; } if (sessionSortState != null) { if (sortOrder == SortState.No) { sortOrder = (SortState)Enum.Parse(typeof(SortState), sessionSortState); } } ViewData["NameSort"] = sortOrder == SortState.NameDesc ? SortState.NameAsc : SortState.NameDesc; HttpContext.Session.SetString("SortState", sortOrder.ToString()); IQueryable <ScheduleForWeek> SchedulesForWeek = Sort(_context.SchedulesForWeek, sortOrder, _scheduleForWeek.StartTime, (int)page); foreach (var item in SchedulesForWeek) { item.TVShow = _context.TVShows.Where(o => o.TVShowID == item.TVShowID).FirstOrDefault(); } ScheduleForWeeksViewModel SchedulesForWeekView = new ScheduleForWeeksViewModel { ScheduleForWeekViewModel = _scheduleForWeek, PageViewModel = SchedulesForWeek, PageNumber = (int)page }; return(View(SchedulesForWeekView)); }
public IActionResult Edit(ScheduleForWeek scheduleForWeek) { if (ModelState.IsValid) { try { _context.Update(scheduleForWeek); _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ScheduleForWeekExists(scheduleForWeek.ScheduleForWeekID)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(scheduleForWeek)); }