public async Task OnGetAsync(string action, int?id, int alerttype = 0) { VIQInfoModel = await _context.VIQInfo.ToListAsync(); if ("transfer" == action) { //add questionnaire VIQInfoModel viqinfo = VIQInfoModel.FirstOrDefault(item => item.QId == id); bool result = _briefcaseRepository.AddQuestionnaire(viqinfo); if (result == false) { TempData["message"] = "The questionnaire was transferred already."; TempData["result"] = "Info!"; } else { TempData["message"] = "The questionnaire was transferred successfully."; TempData["result"] = "Success!"; } } else if (action == "remove") { _briefcaseRepository.RemoveQuestionnaire(id ?? -1); TempData["message"] = "The questionnaire was removed."; TempData["result"] = "Success!"; } RegisteredQuestionnaires = _briefcaseRepository.GetRegisteredQuestionnaires(); AlertType = (alerttype + 1) % 5; }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } VIQInfoModel = await _context.VIQInfo.FirstOrDefaultAsync(m => m.QId == id); if (VIQInfoModel == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } VIQInfoModel = await _context.VIQInfo.FindAsync(id); if (VIQInfoModel != null) { _context.VIQInfo.Remove(VIQInfoModel); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }