예제 #1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CalificacionExists(Calificacion.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
        public bool UpsertUser(UpsertUserCommand upsertUserCommand)
        {
            var user     = _mapper.Map <User>(upsertUserCommand);
            var isUpdate = user.UserId != 0;
            var entry    = _identityContext.Attach(user);

            if (isUpdate)
            {
                entry.State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                entry.Property(u => u.Password).IsModified = false;
            }
            _identityContext.SaveChanges();
            return(true);
        }
예제 #3
0
        // Constructors
        public UnauthorizedHandler(IdentityContext <TUser> identityContext)
        {
            #region Contracts

            if (identityContext == null)
            {
                throw new ArgumentNullException();
            }

            #endregion

            // Default
            _identityContext = identityContext;

            // Attach
            _identityContext.Attach(this);
        }