Beispiel #1
0
        public async Task <IActionResult> Edit(Guid id, [Bind("guid")] OutcomeAssessmentViewModel outcomeAssessmentViewModel)
        {
            if (!IsLoggedIn())
            {
                return(RedirectToAction("Index", "Account"));
            }
            ViewBag.Admin = User.Claims.ToList()[2].Value;
            if (id != outcomeAssessmentViewModel.guid)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(outcomeAssessmentViewModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OutcomeAssessmentViewModelExists(outcomeAssessmentViewModel.guid))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(outcomeAssessmentViewModel));
        }
Beispiel #2
0
        // GET: OutcomeAssessmentViewModels
        public async Task <IActionResult> Index()
        {
            if (!IsLoggedIn())
            {
                return(RedirectToAction("Index", "Account"));
            }

            ViewBag.Admin = User.Claims.ToList()[2].Value;

            OutcomeAssessmentViewModel oa = new OutcomeAssessmentViewModel();
            Assessment a = await _context.Assessment
                           .FirstOrDefaultAsync(m => m.Id == 1);

            Outcome o = await _context.Outcome
                        .FirstOrDefaultAsync(m => m.Id == 1);

            oa.assessment = a;
            oa.outcome    = o;
            oa.guid       = Guid.NewGuid();

            List <OutcomeAssessmentViewModel> loa = new List <OutcomeAssessmentViewModel>();

            loa.Add(oa);

            //return View(await _context.OutcomeAssessmentViewModel.ToListAsync());
            return(View(loa));
        }
Beispiel #3
0
        public async Task <IActionResult> Create([Bind("guid")] OutcomeAssessmentViewModel outcomeAssessmentViewModel)
        {
            if (!IsLoggedIn())
            {
                return(RedirectToAction("Index", "Account"));
            }
            ViewBag.Admin = User.Claims.ToList()[2].Value;
            if (ModelState.IsValid)
            {
                outcomeAssessmentViewModel.guid = Guid.NewGuid();
                //_context.Add(outcomeAssessmentViewModel);
                //await _context.SaveChangesAsync();
                Assessment a = await _context.Assessment
                               .FirstOrDefaultAsync(m => m.Id == 1);

                Outcome o = await _context.Outcome
                            .FirstOrDefaultAsync(m => m.Id == 1);

                outcomeAssessmentViewModel.assessment = a;
                outcomeAssessmentViewModel.outcome    = o;
                return(RedirectToAction(nameof(Index)));
            }
            return(View(outcomeAssessmentViewModel));
        }