public async Task <IViewComponentResult> InvokeAsync() { string fullLink = $"{baseUri}/SchoolUser"; var userIdentity = User as ClaimsPrincipal; string loggedUserId = _user.GetUserId(userIdentity); if (loggedUserId == null) { var viewModel = new NavbarVm() { Action = "Index", Controller = "Home" }; return(await Task.FromResult <IViewComponentResult>(View(viewModel))); } string userByIdentityReference = $"{fullLink}/IdRef/{loggedUserId}"; var user = WebApiService.GetApiResult <SchoolUser>(userByIdentityReference); ViewBag.Mode = user.SchoolUserCategory.Category; if (user.SchoolUserCategory.Category == "Teacher") { var viewModel = new NavbarVm() { Action = "Index", Controller = "Home", Area = "Teacher" }; return(await Task.FromResult <IViewComponentResult>(View(viewModel))); } if (user.SchoolUserCategory.Category == "Admin") { var viewModel = new NavbarVm() { Action = "Index", Controller = "Home", Area = "Admin" }; return(await Task.FromResult <IViewComponentResult>(View(viewModel))); } if (user.SchoolUserCategory.Category == "Student") { var viewModel = new NavbarVm() { Action = "IndexWithoutRedirect", Controller = "Home" }; return(await Task.FromResult <IViewComponentResult>(View(viewModel))); } else { var viewModel = new NavbarVm() { Action = "Index", Controller = "Home" }; return(await Task.FromResult <IViewComponentResult>(View(viewModel))); } }
public IActionResult Edit(Guid id) { string fullLink = $"{baseUri}/SchoolUser"; string categoryLink = $"{baseUri}/SchoolUserCategory"; string classgroupLink = $"{baseUri}/ClassGroup"; string userById = fullLink + "/" + id; var schoolUser = WebApiService.GetApiResult <SchoolUser>(userById); var classGroups = new SelectList(WebApiService.GetApiResult <ICollection <ClassGroup> >(classgroupLink), nameof(ClassGroup.Id), nameof(ClassGroup.ClassGroupName), schoolUser.ClassGroup.Id.ToString()); var schoolUserCategories = new SelectList(WebApiService.GetApiResult <ICollection <SchoolUserCategory> >(categoryLink), nameof(SchoolUserCategory.Id), nameof(SchoolUserCategory.Category), schoolUser.SchoolUserCategory.Id.ToString()); EditUserViewModel editUserViewModel = new EditUserViewModel { Id = schoolUser.Id, FirstName = schoolUser.FirstName, LastName = schoolUser.LastName, ClassGroup = schoolUser.ClassGroup, AvatarURL = schoolUser.AvatarURL, IdentityReference = schoolUser.IdentityReference, SchoolUserCategory = schoolUser.SchoolUserCategory, ClassGroupOptions = classGroups, SchoolUserCategoryOptions = schoolUserCategories }; return(View(editUserViewModel)); }
public async Task <IActionResult> Save(List <AssessmentFirstLangCreateTestDetailVm> vm) { var questionsToAdd = new List <Question>(); string fullLink = $"{baseUri}/Assessment/{2}"; var langAssessment = WebApiService.GetApiResult <Assessment>(fullLink); try { foreach (var question in vm) { if (question.IsToBeAdded) { var questionToAdd = WebApiService.GetApiResult <Question>($"{baseUri}/Question/{question.QuestionId}"); questionsToAdd.Add(questionToAdd); } } var assessment = new AssessmentDetail() { AssessmentTitle = $"{langAssessment.AssessmentTitle}, {DateTime.Now.Date}", Questions = questionsToAdd, AssessmentId = 2, Assessment = langAssessment }; await WebApiService.PostCallApi <AssessmentDetail, AssessmentDetail>($"{baseUri}/assessmentdetail", assessment); return(RedirectToAction(nameof(Index))); } catch (Exception ex) { Debug.WriteLine(ex.Message); } return(RedirectToAction(nameof(Index))); }
public IActionResult Index() { string fullLink = $"{baseUri}/SchoolUser"; string loggedUserid = _user.GetUserId(User); string userByIdentityReference = $"{fullLink}/IdRef/{loggedUserid}"; var user = WebApiService.GetApiResult <SchoolUser>(userByIdentityReference); string categoryLink = $"{baseUri}/SchoolUserCategory"; string getCategoryByIdLink = categoryLink + "/" + 1; var userCategory = WebApiService.GetApiResult <SchoolUserCategory>(getCategoryByIdLink); if (user.SchoolUserCategory.Category != userCategory.Category) { return(RedirectToAction("Index", "Home", new { Area = "" })); } string classgroupLink = $"{baseUri}/ClassGroup"; ICollection <ClassGroup> classGroup = WebApiService.GetApiResult <ICollection <ClassGroup> >(classgroupLink); ICollection <SchoolUser> schoolUsers = WebApiService.GetApiResult <ICollection <SchoolUser> >(fullLink); UserViewModel userViewModel = new UserViewModel { ClassGroups = classGroup, Users = schoolUsers }; return(View(userViewModel)); }
public async Task <IActionResult> Edit(EditUserViewModel editUserViewModel) { string fullLink = $"{baseUri}/SchoolUser"; string categoryLink = $"{baseUri}/SchoolUserCategory"; string classgroupLink = $"{baseUri}/ClassGroup"; string userById = fullLink + "/" + editUserViewModel.Id; var schoolUser = WebApiService.GetApiResult <SchoolUser>(userById); schoolUser.FirstName = editUserViewModel.FirstName; schoolUser.LastName = editUserViewModel.LastName; string categoryById = categoryLink + "/" + editUserViewModel.SelectedSchoolUserCategoryId; string classgroupById = classgroupLink + "/" + editUserViewModel.SelectedClassGroupId; var schoolUserCategory = WebApiService.GetApiResult <SchoolUserCategory>(categoryById); var classGroup = WebApiService.GetApiResult <ClassGroup>(classgroupById); schoolUser.ClassGroup = classGroup; schoolUser.ClassGroupId = classGroup.Id; schoolUser.SchoolUserCategory = schoolUserCategory; schoolUser.SchoolUserCategoryId = schoolUserCategory.Id; await WebApiService.PutCallApi <SchoolUser, SchoolUser>(userById, schoolUser); return(new RedirectToActionResult("Index", "User", new { id = editUserViewModel.Id })); }
public IActionResult Index(Guid id) { string fullLink = $"{baseUri}/SchoolUser"; string loggedUserid = _user.GetUserId(User); string categoryLink = $"{baseUri}/SchoolUserCategory"; string getCategoryByIdLink = categoryLink + "/" + 1; var userCategory = WebApiService.GetApiResult <SchoolUserCategory>(getCategoryByIdLink); string userByIdentityReference = $"{fullLink}/IdRef/{loggedUserid}"; var user = WebApiService.GetApiResult <SchoolUser>(userByIdentityReference); if (user.SchoolUserCategory.Category != userCategory.Category) { return(RedirectToAction("Index", "Home", new { Area = "" })); } string userById = fullLink + "/" + id; var schoolUser = WebApiService.GetApiResult <SchoolUser>(userById); UserDetailViewModel userDetailViewModel = new UserDetailViewModel { Id = schoolUser.Id, FirstName = schoolUser.FirstName, LastName = schoolUser.LastName, ClassGroup = schoolUser.ClassGroup, AvatarURL = schoolUser.AvatarURL, IdentityReference = schoolUser.IdentityReference, SchoolUserCategory = schoolUser.SchoolUserCategory }; return(View(userDetailViewModel)); }
public IActionResult Index() { string fullLink = $"{baseUri}/SchoolUserCategory"; var schoolUserCategories = WebApiService.GetApiResult <ICollection <SchoolUserCategory> >(fullLink); SchoolUserCategoryViewModel schoolUserCategoryViewModel = new SchoolUserCategoryViewModel { schoolUserCategories = schoolUserCategories }; return(View(schoolUserCategoryViewModel)); }
public IActionResult Index() { string fullLink = $"{baseUri}/Assessment/"; var allLangAssessments = WebApiService.GetApiResult <List <Assessment> >(fullLink); var viewModel = new AssessmentFirstLangIndexVm() { SelectedAssessments = allLangAssessments }; return(View(viewModel)); }
public IActionResult Index() { string fullLink = $"{baseUri}/ClassGroup"; var classGroups = WebApiService.GetApiResult <ICollection <ClassGroup> >(fullLink); ClassGroupViewModel classGroupViewModel = new ClassGroupViewModel { classGroups = classGroups }; return(View(classGroupViewModel)); }
public IActionResult Index() { string fullLink = $"{baseUri}/Question/LangFirstGradeQuestions"; var allFirstLangQuestions = WebApiService.GetApiResult <List <LangFirstGradeQuestionDto> >(fullLink); var viewModel = new LangFirstQuestionsIndexVm() { Questions = allFirstLangQuestions }; return(View(viewModel)); }
public IActionResult Add() { string fullLink = $"{baseUri}/YearGrade"; var yearGrades = new SelectList(WebApiService.GetApiResult <ICollection <YearGrade> >(fullLink), nameof(YearGrade.Id), nameof(YearGrade.Grade)); ClassGroupDetailViewModel classGroupDetailViewModel = new ClassGroupDetailViewModel { YearGradeOptions = yearGrades }; return(View(classGroupDetailViewModel)); }
public IActionResult Create() { ViewBag.Mode = "Create"; var categoryLink = $"{baseUri}/QuestionCategory"; var categories = WebApiService.GetApiResult <List <QuestionCategory> >(categoryLink); var availableCategories = categories.Where(c => c.CategoryQuestion == QuestionCategories.LangQuestionSecondGrade || c.CategoryQuestion == QuestionCategories.LangQuestionThirdGrade); var viewModel = new LangQuestionsDetailVm() { AvailableCategories = availableCategories }; return(View("Detail", viewModel)); }
public async Task <IActionResult> Edit(SchoolUserCategoryDetailViewModel schoolUserCategoryDetailViewModel) { string fullLink = $"{baseUri}/SchoolUserCategory"; string schoolUserCategoryById = fullLink + "/" + schoolUserCategoryDetailViewModel.Id; SchoolUserCategory schoolUserCategory = WebApiService.GetApiResult <SchoolUserCategory>(schoolUserCategoryById); schoolUserCategory.Category = schoolUserCategoryDetailViewModel.Category; string updateLink = $"{baseUri}/SchoolUserCategory/{schoolUserCategory.Id}"; await WebApiService.PutCallApi <SchoolUserCategory, SchoolUserCategory>(updateLink, schoolUserCategory); return(RedirectToAction("Index", "UserCategory")); }
public IActionResult Detail(int id) { string fullLink = $"{baseUri}/Assessment/{id}"; var langAssessment = WebApiService.GetApiResult <Assessment>(fullLink); var viewModel = new AssessmentFirstLangDetailVm() { Id = langAssessment.Id, AssessmentTitle = langAssessment.AssessmentTitle, RelatedAssessments = langAssessment.AssessmentDetails }; return(View(viewModel)); }
public IActionResult Edit(int id) { string fullLink = $"{baseUri}/SchoolUserCategory"; string schoolUserCategoryById = fullLink + "/" + id; SchoolUserCategory schoolUserCategory = WebApiService.GetApiResult <SchoolUserCategory>(schoolUserCategoryById); SchoolUserCategoryDetailViewModel schoolUserCategoryDetailViewModel = new SchoolUserCategoryDetailViewModel { Category = schoolUserCategory.Category }; return(View(schoolUserCategoryDetailViewModel)); }
public IActionResult Index() { string fullLink = $"{baseUri}/Question/"; var allLangQuestions = WebApiService.GetApiResult <List <Question> >(fullLink); var specificList = allLangQuestions.Where(c => c.QuestionCategory.CategoryQuestion == QuestionCategories.LangQuestionSecondGrade || c.QuestionCategory.CategoryQuestion == QuestionCategories.LangQuestionThirdGrade); var viewModel = new LangQuestionsIndexVm() { Questions = specificList }; return(View(viewModel)); }
public IActionResult Details(int id) { string fullLink = $"{baseUri}/SchoolUserCategory/{id}"; string userLink = $"{baseUri}/SchoolUser"; var userCategory = WebApiService.GetApiResult <SchoolUserCategory>(fullLink); var users = WebApiService.GetApiResult <List <SchoolUser> >(userLink); SchoolUserCategoryDetailViewModel detailVm = new SchoolUserCategoryDetailViewModel { Id = userCategory.Id, Category = userCategory.Category, SchoolUsers = users }; return(View(detailVm)); }
public IActionResult Index() { string fullLink = $"{baseUri}/SchoolUser"; string loggedUserid = _user.GetUserId(User); string userByIdentityReference = $"{fullLink}/IdRef/{loggedUserid}"; var user = WebApiService.GetApiResult <SchoolUser>(userByIdentityReference); if (user.SchoolUserCategory.Category == "Teacher" || user.SchoolUserCategory.Category == "Admin") { return(View()); } return(RedirectToAction("Index", "Home", new { Area = "" })); }
public async Task <IActionResult> Delete(Guid id) { string fullLink = $"{baseUri}/SchoolUser"; string userById = fullLink + "/" + id; var schoolUser = WebApiService.GetApiResult <SchoolUser>(userById); string identityId = schoolUser.IdentityReference; var identityUser = await _user.FindByIdAsync(identityId); await _user.DeleteAsync(identityUser); await WebApiService.DeleteCallApi <SchoolUser>(userById); return(RedirectToAction("Overview", "User")); }
public IActionResult OverView() { string classgroupLink = $"{baseUri}/ClassGroup"; string categoryLink = $"{baseUri}/SchoolUserCategory"; string userLink = $"{baseUri}/SchoolUser"; var users = WebApiService.GetApiResult <List <SchoolUser> >(userLink); var classes = WebApiService.GetApiResult <List <ClassGroup> >(classgroupLink); var categories = WebApiService.GetApiResult <List <SchoolUserCategory> >(categoryLink); UserViewModel viewmodel = new UserViewModel() { Users = users, ClassGroups = classes, Categories = categories }; return(View(viewmodel)); }
public async Task <IActionResult> Add(ClassGroupDetailViewModel classGroupDetailViewModel) { string fullLink = $"{baseUri}/ClassGroup"; string yeargradeLink = $"{baseUri}/YearGrade/{classGroupDetailViewModel.SelectedYearGradeId}"; YearGrade yearGrade = WebApiService.GetApiResult <YearGrade>(yeargradeLink); ClassGroup classGroup = new ClassGroup { ClassGroupName = classGroupDetailViewModel.ClassGroupName, YearGrade = null, YearGradeId = yearGrade.Id }; await WebApiService.PostCallApi <ClassGroup, ClassGroup>(fullLink, classGroup); return(RedirectToAction("Index", "Classgroup")); }
public IActionResult Details(int id) { string classgroupLink = $"{baseUri}/ClassGroup"; string fullLink = $"{baseUri}/ClassGroup/{id}"; string userLink = $"{baseUri}/SchoolUser"; var classGroup = WebApiService.GetApiResult <ClassGroup>(fullLink); var users = WebApiService.GetApiResult <List <SchoolUser> >(userLink); ClassGroupDetailViewModel detailVm = new ClassGroupDetailViewModel { Id = classGroup.Id, ClassGroupName = classGroup.ClassGroupName, YearGrade = classGroup.YearGrade, SelectedYearGradeId = classGroup.YearGradeId, SchoolUsers = users }; return(View(detailVm)); }
public IActionResult Edit(int id) { string fullLink = $"{baseUri}/ClassGroup"; string classgroupById = fullLink + "/" + id; ClassGroup classGroup = WebApiService.GetApiResult <ClassGroup>(classgroupById); string yeargradeLink = $"{baseUri}/YearGrade"; var yearGrades = new SelectList(WebApiService.GetApiResult <ICollection <YearGrade> >(yeargradeLink), nameof(YearGrade.Id), nameof(YearGrade.Grade), classGroup.YearGrade.Id.ToString()); ClassGroupDetailViewModel editClassGroupViewModel = new ClassGroupDetailViewModel { ClassGroupName = classGroup.ClassGroupName, SchoolUsers = classGroup.SchoolUsers, YearGrade = classGroup.YearGrade, YearGradeOptions = yearGrades }; return(View(editClassGroupViewModel)); }
public async Task <IActionResult> Delete(int id) { var questionToDeleteLink = $"{baseUri}/Question/{id}"; var questionToDelete = WebApiService.GetApiResult <Question>(questionToDeleteLink); var feedBackOne = questionToDelete.Feedback.ElementAt(0); var feedBackOneLink = $"{baseUri}/Feedback/{feedBackOne.Id}"; var deletedFeedBackOne = await WebApiService.DeleteCallApi <Feedback>(feedBackOneLink); var feedBackTwo = questionToDelete.Feedback.ElementAt(1); var feedBackTwoLink = $"{baseUri}/Feedback/{feedBackTwo.Id}"; var deletedFeedBackTwo = await WebApiService.DeleteCallApi <Feedback>(feedBackTwoLink); var questionLink = $"{baseUri}/Question/{id}"; var deletedQuestion = await WebApiService.DeleteCallApi <Question>(questionLink); var answerLink = $"{baseUri}/Answer/{deletedQuestion.AnswerId}"; var deletedAnswer = await WebApiService.DeleteCallApi <Answer>(answerLink); return(RedirectToAction(nameof(Index))); }
public IActionResult Update(int id) { ViewBag.Mode = "Edit"; var questionLink = $"{baseUri}/Question/{id}"; var question = WebApiService.GetApiResult <Question>(questionLink); var viewModel = new LangFirstQuestionDetailVm() { Id = question.Id, QuestionTitle = question.QuestionTitle, FileName = question.FileName, AnswerId = question.Answer.Id, Answer = question.Answer.LangAnswer, FirstFeedbackId = question.Feedback.OfType <Feedback>().ElementAt(0).Id, FirstFeedback = question.Feedback.OfType <Feedback>().ElementAt(0).Description, SecondFeedbackId = question.Feedback.OfType <Feedback>().ElementAt(1).Id, SecondFeedback = question.Feedback.OfType <Feedback>().ElementAt(1).Description }; return(View("Detail", viewModel)); }
public async Task <IActionResult> Edit(ClassGroupDetailViewModel editClassGroupViewModel) { string fullLink = $"{baseUri}/ClassGroup"; string classgroupById = fullLink + "/" + editClassGroupViewModel.Id; ClassGroup classGroup = WebApiService.GetApiResult <ClassGroup>(classgroupById); classGroup.ClassGroupName = editClassGroupViewModel.ClassGroupName; classGroup.SchoolUsers = editClassGroupViewModel.SchoolUsers; string yeargradeLink = $"{baseUri}/YearGrade/{editClassGroupViewModel.SelectedYearGradeId}"; YearGrade yearGrade = WebApiService.GetApiResult <YearGrade>(yeargradeLink); classGroup.YearGrade = yearGrade; classGroup.YearGradeId = yearGrade.Id; string updateLink = $"{baseUri}/ClassGroup/{classGroup.Id}"; await WebApiService.PutCallApi <ClassGroup, ClassGroup>(updateLink, classGroup); return(RedirectToAction("Index", "Classgroup")); }
public IActionResult Detail(int id) { //POSSIBLE ADJUST FOR QUESTIONCATEGORY ViewBag.Mode = "Detail"; var questionLink = $"{baseUri}/Question/{id}"; var question = WebApiService.GetApiResult <Question>(questionLink); var viewModel = new LangQuestionsDetailVm() { QuestionCategory = question.QuestionCategory.CategoryQuestion, Id = question.Id, QuestionTitle = question.QuestionTitle, Description = question.Description, AnswerId = question.Answer.Id, Answer = question.Answer.LangAnswer, FirstFeedbackId = question.Feedback.OfType <Feedback>().ElementAt(0).Id, FirstFeedback = question.Feedback.OfType <Feedback>().ElementAt(0).Description, SecondFeedbackId = question.Feedback.OfType <Feedback>().ElementAt(1).Id, SecondFeedback = question.Feedback.OfType <Feedback>().ElementAt(1).Description }; return(View("Detail", viewModel)); }
public IActionResult CreateTest() { string fullLink = $"{baseUri}/Question/"; var allLangQuestions = WebApiService.GetApiResult <List <Question> >(fullLink); var specificList = allLangQuestions .Where(c => c.QuestionCategory.CategoryQuestion == QuestionCategories.LangQuestionFirstGrade) .ToList(); var detailList = new List <AssessmentFirstLangCreateTestDetailVm>(); foreach (var item in specificList) { var detailModel = new AssessmentFirstLangCreateTestDetailVm() { QuestionToAdd = item, QuestionId = item.Id }; detailList.Add(detailModel); } return(View(detailList)); }
public async Task <IActionResult> Save(LangFirstQuestionDetailVm viewModel, IFormFile picture) { if (viewModel.Id != 0) { var categoryLink = $"{baseUri}/QuestionCategory/{2}"; var category = WebApiService.GetApiResult <QuestionCategory>(categoryLink); var answerLink = $"{baseUri}/Answer/{viewModel.AnswerId}"; var answer = new Answer() { Id = viewModel.AnswerId, LangAnswer = viewModel.Answer }; answer = await WebApiService.PutCallApi <Answer, Answer>(answerLink, answer); List <Feedback> feedbackList = new List <Feedback>(); feedbackList.Add(new Feedback() { Id = viewModel.FirstFeedbackId, Description = viewModel.FirstFeedback, QuestionId = viewModel.Id }); feedbackList.Add(new Feedback() { Id = viewModel.SecondFeedbackId, Description = viewModel.SecondFeedback, QuestionId = viewModel.Id }); var questionLink = $"{baseUri}/Question/{viewModel.Id}"; var question = new Question() { Id = viewModel.Id, QuestionTitle = viewModel.QuestionTitle, FileName = _imageServices.UploadImage(picture, "images/LangFirstQuestions"), AnswerId = answer.Id, Answer = answer, QuestionCategory = category, QuestionCategoryId = category.Id, Feedback = feedbackList }; question = await WebApiService.PutCallApi <Question, Question>(questionLink, question); var feedbackLink = $"{baseUri}/Feedback"; await WebApiService.PutCallApi <Feedback, Feedback>($"{feedbackLink}/{viewModel.FirstFeedbackId}", feedbackList.ElementAt(0)); await WebApiService.PutCallApi <Feedback, Feedback>($"{feedbackLink}/{viewModel.SecondFeedbackId}", feedbackList.ElementAt(1)); return(RedirectToAction(nameof(Index))); } else { var categoryLink = $"{baseUri}/QuestionCategory/{2}"; var category = WebApiService.GetApiResult <QuestionCategory>(categoryLink); var answerLink = $"{baseUri}/Answer"; var answer = new Answer() { LangAnswer = viewModel.Answer }; //var seededAnswer = await WebApiService.PostCallApi<Answer, Answer>(answerLink, answer); answer.Id = 0; List <Feedback> feedbackList = new List <Feedback>(); feedbackList.Add(new Feedback() { Description = viewModel.FirstFeedback }); feedbackList.Add(new Feedback() { Description = viewModel.SecondFeedback }); var questionLink = $"{baseUri}/Question"; var question = new Question() { QuestionTitle = viewModel.QuestionTitle, FileName = _imageServices.UploadImage(picture, "images/LangFirstQuestions"), Answer = answer, QuestionCategory = category, Feedback = feedbackList }; await WebApiService.PostCallApi <Question, Question>(questionLink, question); return(RedirectToAction(nameof(Index))); } }
public IActionResult Index() { string questionUri = $"{baseUri}"; return(View(WebApiService.GetApiResult <List <Question> >(questionUri))); }