using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using EQNetwork.Objects;
using EQNetwork.Interfaces;
using EQNetwork.Utility;

namespace EQNetwork.Services
{
    public partial class CollectionService : ICollectionService
    {
        private EQProcess _eq;
        public CollectionService(EQProcess eq)
        {
            _eq = eq;
        }

        private IEQApiService _api { get { return _eq.EQApiService; } }

        public Collection Get(int collectionId) { return _api.Collection_Get(collectionId); }
        public Collection Get(Guid collectionGuid) { return _api.Collection_Get(collectionGuid); }

        public void Create(ref Collection collection) { _api.Collection_Create(ref collection); }

        public void Update(ref Collection collection) { _api.Collection_Update(ref collection); }
        public void UploadIcon(int collectionId, string path) { UploadIcon(collectionId, new FileUploadSpec(path)); }
        public void UploadIcon(int collectionId, FileUploadSpec fileUploadSpec)
        {
            Collection collection = new Collection();
            collection.CollectionId = collectionId;
            collection.Icon = fileUploadSpec;
            Update(ref collection);
        }
        public void DeleteIcon(int collectionId)
        {
            Collection collection = new Collection();
            collection.CollectionId = collectionId;
            collection.Icon = null;
            Update(ref collection);
        }

        public void Delete(Collection collection) { _api.Collection_Delete(collection); }
        public void Delete(int collectionId) { _api.Collection_Delete(collectionId); }

        public List<ContentFile> ListContentFiles(int collectionId, ListContentFilesContext listContentFilesContext, PagingParameters pagingParameters) { return _api.Collection_ListContentFiles(collectionId, listContentFilesContext, pagingParameters); }

        public void AddRelationship(int collectionId, Db.User_CollectionType user_CollectionType) { _api.Collection_AddRelationship(collectionId, user_CollectionType); }
        public void AddRelationship(int collectionId, Db.User_CollectionType user_CollectionType,
            int? collectionTriggerId, bool? silent) { _api.Collection_AddRelationship(collectionId, user_CollectionType, collectionTriggerId, silent); }

        public void SocialAdd(int collectionId, string action, Db.SocialService? exclude, bool? force) { _api.Collection_SocialAdd(collectionId, action, exclude, force); }
        public void SocialRemove(int collectionId, string action, bool? force) { _api.Collection_SocialRemove(collectionId, action, force); }

        public void MarkAsViewed(int collectionId) { _api.Collection_Viewed(collectionId); }
    }
}
