Пример #1
0
        public async Task <List <Result> > UpdateAvatarFileNameForUserWithIdAsync(string userId, string fileName)
        {
            var user = await _userManager.Users.Include(x => x.NickNames).Include(x => x.FavoritePlayer).FirstOrDefaultAsync(x => x.Id == userId);

            user.AvatarFileName = fileName;
            var results = await new List <Result>().Get(_dbClient.UpdateUserAsync(user), ResultMessages.ChangeAvatar);

            if (results.Any(x => x.Type == ResultType.Success))
            {
                _uploadRepository.DeleteFilesInDirectory("avatars", x => x.Name.Contains(userId) && !x.Name.Equals(fileName));
            }
            return(results);
        }