public async Task <Torrent> AddAsync(Torrent torrent) { Guard.Against.NullInvalid(torrent, Resources.Torrent_Invalid_ErrorMessage); Guard.Against.NullString(torrent.Name, Resources.Torrent_InvalidName_ErrorMessage); Guard.Against.NullString(torrent.Content, Resources.Torrent_InvalidContent_ErrorMessage); Guard.Against.LessOne(torrent.SubcategoryId, Resources.Torrent_InvalidSubcategoryId_ErrorMessage); if (!await _subcategoryRepository.ExistAsync(torrent.SubcategoryId)) { throw new RutrackerException( string.Format(Resources.Subcategory_NotFoundById_ErrorMessage, torrent.SubcategoryId), ExceptionEventTypes.InvalidParameters); } torrent.TrackerId = null; torrent.Hash = null; torrent.Size = 0; torrent.IsStockTorrent = false; torrent.AddedDate = _dateService.Now(); var result = await _torrentRepository.AddAsync(torrent); await _unitOfWork.SaveChangesAsync(); var containerName = result.Id.ToString().PadLeft(10, '0'); await _storageService.CreateContainerAsync(containerName); return(result); }