using BaseDomain.Results; using SumaTube.Domain.ValueObjects; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SumaTube.Domain.Entities.Videos { public class UserVideo { public Id Id { get; private set; } public string Name { get; private set; } public List VideoGroups { get; private set; } = new List(); public UserVideo(int userId, string name) { this.Id = Guid.NewGuid(); this.Name = name; } public Result AddVideoGroup(string name, string description) { if (!VideoGroups.Any(v => v.Name == name)) { this.VideoGroups.Add(new VideoGroup(name, description)); return true; } return false; } public Result AddVideo(string collectionName, string url) { var videoCollectionItem = VideoGroups.Find(v => v.Name == collectionName); if (videoCollectionItem != null) { if (videoCollectionItem.Videos.Any(v => v.Url == url)) return false; videoCollectionItem.AddVideo(this.Id.Value, url); return true; } return false; } public static UserVideo Create(int userId, string name) => new UserVideo(userId, name); } }