public async Task <IActionResult> PutAccountDetail(int id, AccountDetail accountDetail)
        {
            if (id != accountDetail.AccountID)
            {
                return(BadRequest());
            }

            _context.Entry(accountDetail).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AccountDetailExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #2
0
        public async Task <IActionResult> resetPassword(PasswordDetail modeldetail)
        {
            //create a var to check if the old password is match
            var checkPass = await _context.AccountDetails.FirstOrDefaultAsync(e => e.UserPassword == modeldetail.OldPassword);

            var checkNamepass = await _context.AccountDetails.FirstOrDefaultAsync(c => c.UserPassword == modeldetail.OldPassword);

            //do the compare if the password of that username is existing inside the database then go head
            if (checkNamepass != null)
            {
                //if there is a user and password match inside the database msqll then go head make change to the checkword
                checkNamepass.UserPassword    = modeldetail.NewPassword;
                checkNamepass.ConfirmPassword = modeldetail.ConfirmNewPassword;
                await _context.SaveChangesAsync();


                return(Ok(modeldetail));
            }
            else //otherwise just return bad request which identity it's wrong
            {
                return(BadRequest());
            }
        }