コード例 #1
0
ファイル: ClubService.cs プロジェクト: OlesyaRiznyk/EPlast
        /// <inheritdoc />
        public async Task RemoveAsync(int ClubId)
        {
            var Club = await _repoWrapper.Club.GetFirstOrDefaultAsync(c => c.ID == ClubId);

            if (Club.Logo != null)
            {
                await _ClubBlobStorage.DeleteBlobAsync(Club.Logo);
            }

            _repoWrapper.Club.Delete(Club);
            await _repoWrapper.SaveAsync();
        }
コード例 #2
0
        private async Task <string> UploadPhotoAsyncFromBase64(int clubId, string imageBase64)
        {
            var oldImageName = (await _repoWrapper.Club.GetFirstOrDefaultAsync(x => x.ID == clubId)).Logo;

            if (string.IsNullOrWhiteSpace(imageBase64) || imageBase64.Length <= 0)
            {
                return(oldImageName);
            }
            var base64Parts = imageBase64.Split(',');
            var ext         = base64Parts[0].Split(new[] { '/', ';' }, 3)[1];
            var fileName    = Guid.NewGuid() + "." + ext;
            await _clubBlobStorage.UploadBlobForBase64Async(base64Parts[1], fileName);

            if (!string.IsNullOrEmpty(oldImageName) && !string.Equals(oldImageName, "default_club_image.png") && oldImageName.Length < 30)
            {
                await _clubBlobStorage.DeleteBlobAsync(oldImageName);
            }

            return(fileName);
        }