コード例 #1
0
        public async Task <AtNotify> DoiMatKhauCaNhan(AccountObjectDm_UpdatePass input, string userId)
        {
            try
            {
                var model = await _context.AccountObject.FirstOrDefaultAsync(c => c.Id == userId);

                if (model == null)
                {
                    return(AtNotify.NotFound);
                }
                var data_old = JsonConvert.SerializeObject(new AccountObjectDm_ResetPassword
                {
                    Id           = model.Id,
                    AtRowVersion = model.AtRowVersion,
                    PassWord     = model.PassWord
                });
                if (!string.IsNullOrWhiteSpace(input.newPass) && !string.IsNullOrWhiteSpace(input.oldPass))
                {
                    if (EncryptProvider.Sha1(input.oldPass) == model.PassWord)
                    {
                        model.PassWord           = EncryptProvider.Sha1(input.newPass);
                        model.AtLastModifiedBy   = userId;
                        model.AtLastModifiedDate = GetDateTimeFromServer();
                        await _context.SaveChangesAsync();
                    }
                    else
                    {
                        return(AtNotify.UpdateFail);
                    }
                }

                var data_new = JsonConvert.SerializeObject(new AccountObjectDm_ResetPassword
                {
                    Id           = model.Id,
                    AtRowVersion = model.AtRowVersion,
                    PassWord     = model.PassWord
                });

                await WrtiteAudittingLog(new MSC_AudittingLog { Description = "Sửa mật khẩu cá nhân với ID: " + model.Id, UserID = userId, Data_New = data_new, Data_Old = data_old }, AtSerialNoConts.CODE_LOG_CREATE);

                return(AtNotify.UpdateCompelete);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
        public async Task <ActionResult <AtResult <AccountObjectDm_UpdatePass> > > AccountObject_UpdatePass([FromBody]   AccountObjectDm_UpdatePass input)
        {
            if (await CheckPermission(_context))
            {
                try
                {
                    var ouput = await _logicAccountObj.DoiMatKhauCaNhan(input, UserId);

                    if (ouput == AtNotify.PhienGiaoDichHetHan || ouput == AtNotify.NotFound)
                    {
                        return(new AtResult <AccountObjectDm_UpdatePass>(ouput));
                    }

                    return(new AtResult <AccountObjectDm_UpdatePass>(input));
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            else
            {
                return(new AtResult <AccountObjectDm_UpdatePass>(AtNotify.KhongCoQuyenTruyCap));
            }
        }