public async Task <IActionResult> CreateFormQuestion() { //return View(); var model = new FormCategoryViewModel(); var catGroups = await _formRepo.GetFormCategoriesAsync(); model.FormCategoryViewModelList = catGroups.ToList(); return(View(model)); }
//[Authorize(Policy = "CREATE_STUDENT")] public async Task <IActionResult> CreateFormCategory(FormCategoryViewModel model) { if (ModelState.IsValid) { var result = await _formRepo.CreateFormCategoryAsync(model); if (result > 0) { return(RedirectToAction(nameof(ViewStudents))); } } // Need to repopulate the Roles dropdown. //var roles = await _roleRepo.GetIdentityRolesAsync(); //model.Roles = roles.ToList(); return(View(model)); }
//create qcasync public async Task <int> CreateFormQuestionAsync(FormCategoryViewModel model) { try { using (var connection = _connectionProvider.Create()) { return(await connection.ExecuteScalarAsync <int>("dbig5_admin.ADD_QC_VIASQLDEV", new { pQuestion_Text = model.Question_Text, pCATEGORY_ID = model.Category_ID }, commandType : CommandType.StoredProcedure)); } } catch (Exception ex) { Console.WriteLine(ex); } // Return failed to insert return(0); }
//[Authorize(Policy = "CREATE_PROJECT")] public async Task <IActionResult> CreateFormQuestion(FormCategoryViewModel model) { try { if (ModelState.IsValid) { await _formRepo.CreateFormQuestionAsync(model); return(View(model)); //return RedirectToAction(nameof(ViewFormCategories)); } } catch (Exception ex) { Console.WriteLine(ex); } return(View(model)); }
/* * * * public async Task<IEnumerable<int>> GetRolesForUserAsync(int userID) * { * try * { * using (var connection = _connectionProvider.Create()) * { * return await connection.QueryAsync<int>("dbig5_admin.READ_ROLES_FOR_USER_VIASQLDEV", new { pUserID = userID }, commandType: CommandType.StoredProcedure); * } * } * catch (Exception ex) * { * Console.WriteLine(ex); * } * return null; * } */ public async Task <int> CreateFormCategoryAsync(FormCategoryViewModel model) { try { using (var connection = _connectionProvider.Create()) { return(await connection.QuerySingleAsync <int>("dbig5_admin.ADD_CATEGORY_VIASQLDEV", new { pCATEGORY_TYPE = model.Category_Type }, commandType : CommandType.StoredProcedure)); } } catch (Exception ex) { Console.WriteLine(ex); } // Return "Fail to Insert" return(0); }