示例#1
0
        public async Task <ActionResultResponse> Delete(string tenantId, string albumId)
        {
            var info = await _albumRepository.GetInfo(albumId);

            if (info == null)
            {
                return(new ActionResultResponse(-1, _websiteResourceService.GetString("Album does not exists. Please try again.")));
            }

            if (info.TenantId != tenantId)
            {
                return(new ActionResultResponse(-2, _sharedResourceService.GetString(ErrorMessage.NotHavePermission)));
            }

            var result = await _albumRepository.Delete(albumId);

            if (result <= 0)
            {
                return(new ActionResultResponse(-3, _sharedResourceService.GetString(ErrorMessage.SomethingWentWrong)));
            }

            if (info.Type == AlbumType.Photo)
            {
                await _albumTranslationRepository.Delete(albumId);
            }

            if (info.Type == AlbumType.Video)
            {
                var listVideo = await _videoRepository.GetsByAlbumId(albumId);

                if (listVideo != null && listVideo.Any())
                {
                    await _videoRepository.DeleteListVideo(listVideo);
                }
            }
            await _photoRepository.DeleteByAlbumId(albumId);

            return(new ActionResultResponse(result, _websiteResourceService.GetString("Delete album successful.")));
        }