Beispiel #1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (HttpContext.Session.GetString("Test") != "1")
            {
                return(RedirectToPage("/Login"));
            }
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(Role).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RoleExists(Role.RoleID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnPostAsync()
        {
            if (HttpContext.Session.GetString("Test") != "1")
            {
                return(RedirectToPage("/Login"));
            }
            if (!ModelState.IsValid)
            {
                ViewData["CohortID"] = new SelectList(_context.Cohorts, "CohortID", "CohortID");
                ViewData["RoleID"]   = new SelectList(_context.Roles, "RoleID", "RoleName");
                return(Page());
            }

            _context.Attach(User).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserExists(User.UserID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }