public async Task <AtNotify> ResetPasswordAccountObject(AccountObjectDm_ResetPassword input, string userId)
        {
            try
            {
                var model = await _context.AccountObject.FirstOrDefaultAsync(c => c.Id == input.Id);

                if (model == null)
                {
                    return(AtNotify.NotFound);
                }
                if (!model.AtRowVersion.SequenceEqual(input.AtRowVersion))
                {
                    return(AtNotify.PhienGiaoDichHetHan);
                }

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


                model.PassWord           = EncryptProvider.Sha1(input.PassWord);
                model.AtLastModifiedBy   = userId;
                model.AtLastModifiedDate = GetDateTimeFromServer();
                await _context.SaveChangesAsync();


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

                await WrtiteAudittingLog(new MSC_AudittingLog { Description = "Đổi mật khẩu AccountObject 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;
            }
        }
Beispiel #2
0
        public async Task <ActionResult <AtResult <AccountObjectDm_ResetPassword> > > AccountObject_ResetPassword([FromBody]   AccountObjectDm_ResetPassword input)
        {
            if (await CheckPermission(_context))
            {
                try
                {
                    var ouput = await _logicAccountObj.ResetPasswordAccountObject(input, UserId);

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

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