using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainBusiness.Interfaces;
using skydiveLogs_api.DomainService.Repositories;
using System;
using System.Collections.Generic;

namespace skydiveLogs_api.DomainBusiness
{
    public class UserImageService : IUserImageService
    {
        #region Public Constructors

        public UserImageService(IUserImageRepository imageRepository,
                                IIdentityService identityService)
        {
            _imageRepository = imageRepository;
            _identityService = identityService;
        }

        #endregion Public Constructors

        #region Public Methods

        /// <summary>
        /// Adds a new image to the system.
        /// </summary>
        /// <param name="newImage">The UserImage entity containing the new image data.</param>
        public void AddNewImage(UserImage newImage)
        {
            newImage.User = _identityService.ConnectedUser;
            _imageRepository.Add(newImage);
        }

        /// <summary>
        /// Deletes an image by its ID.
        /// </summary>
        /// <param name="id">The image ID to delete.</param>
        public void DeleteImageById(int id)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Retrieves all images.
        /// </summary>
        /// <returns>A collection of UserImage entities containing all images.</returns>
        public IEnumerable<UserImage> GetAllImages()
        {
            return _imageRepository.GetAll(_identityService.ConnectedUser);
        }

        /// <summary>
        /// Retrieves an image by its ID.
        /// </summary>
        /// <param name="id">The image ID to retrieve.</param>
        /// <returns>A UserImage entity containing the image details.</returns>
        public UserImage GetImageById(int id)
        {
            return _imageRepository.GetById(id);
        }

        /// <summary>
        /// Updates an existing image.
        /// </summary>
        /// <param name="id">The image ID to update.</param>
        /// <param name="Image">UserImage entity containing the updated image data.</param>
        public void UpdateImage(int id, UserImage Image)
        {
            throw new NotImplementedException();
        }

        #endregion Public Methods

        #region Private Fields

        private readonly IIdentityService _identityService;
        private readonly IUserImageRepository _imageRepository;

        #endregion Private Fields
    }
}
