Ejemplo n.º 1
0
        public async Task <IResultModel> Update(EmployeeBaseUpdateModel model)
        {
            var entity = await _repository.GetAsync(model.Id);

            if (entity == null)
            {
                return(ResultModel.NotExists);
            }

            _mapper.Map(model, entity);
            entity.JoinDate = entity.JoinDate.Date;

            var result = await _repository.UpdateAsync(entity);

            if (result)
            {
                var account = await _accountRepository.GetAsync(entity.AccountId);

                if (account != null)
                {
                    var syncModel = new AccountSyncModel
                    {
                        Id       = account.Id,
                        Name     = entity.Name,
                        Email    = account.Email,
                        Phone    = account.Phone,
                        Roles    = null,
                        UserName = account.UserName
                    };

                    await _accountService.Sync(syncModel);
                }

                //清除缓存
                await _cacheHandler.RemoveAsync(CacheKeys.EMPLOYEE_TREE);

                await _cacheHandler.RemoveAsync($"{CacheKeys.EMPLOYEE_BASE_INFO}:{entity.Id}");
            }
            return(ResultModel.Result(result));
        }
Ejemplo n.º 2
0
 public Task <IResultModel> Update(EmployeeBaseUpdateModel model)
 {
     return(_service.Update(model));
 }