Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,HosName,IdentityUserID")] Hospital_Administrator hospital_Administrator)
        {
            if (id != hospital_Administrator.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(hospital_Administrator);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!Hospital_AdministratorExists(hospital_Administrator.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdentityUserID"] = new SelectList(_context.Users, "Id", "Id", hospital_Administrator.IdentityUserID);
            return(View(hospital_Administrator));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create(Hospital_Administrator hospital_Administrator)
        {
            if (ModelState.IsValid)
            {
                var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
                hospital_Administrator.IdentityUserID = userId;
                _context.Add(hospital_Administrator);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View());
        }