using AutoMapper;
using VentaUniformes.Application.configuration;
using VentaUniformes.Application.Persistencia.user.commands.CreateUser;
using VentaUniformes.Application.Persistencia.user.commands.DeleteUser;
using VentaUniformes.Application.Persistencia.user.commands.UpdateUser;
using VentaUniformes.Application.Persistencia.user.Queries.GetAllUser;
using VentaUniformes.Application.Persistencia.user.Queries.GetUserById;
using VentaUniformes.Application.Persistencia.user.Queries.GetUserByPassAndName;
using VentaUniformes.Application.Sesion.Commands.CreateSesion;
using VentaUniformes.Application.Validators.Sesion;
using VentaUniformes.Application.Validators.User;
using FluentValidation;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VentaUniformes.Application.Persistencia.Producto.Queries.GetAllProduct;
using VentaUniformes.Application.VentasView;
using VentaUniformes.Application.VentasView.historico;
using VentaUniformes.Application.VentasView.Editar;
namespace VentaUniformes.Application
{
    public static class DependencyInjectionService
    {
        public static IServiceCollection AddAplication(this IServiceCollection services)
        {
            var mapper = new MapperConfiguration(confg =>
            {
                confg.AddProfile(new MapperProfile());
                }
            );
            #region user
            services.AddTransient< IcreateUserCommand,CreateUserCommand>();
            services.AddTransient<IupdateUserCommand, UpdateUserCommand>();
            services.AddTransient<IDeleteUserCommand, DeleteUserCommand>();
            services.AddTransient<IGetUserByIdQuery, GetUserByIdQuery>();

            services.AddTransient<IGetAllUserQuery,   GetAllUserQuery>();
            services.AddTransient<IGetUserByPassAndNameQuery, GetUserByPassAndNameQuery>();


            #endregion

            #region userValidator

            services.AddScoped<IValidator<CreateUserModel>,CreateUserValidator>();
            services.AddScoped<IValidator<UpdateUserModel>, UpdateUserValidator>();

            services.AddScoped<IValidator<(string, string)>, GetUserByPassAndNameValidator>();
            services.AddScoped<IValidator<InCreateSesionModel>, InCreateSesionValidator>();


            #endregion
            #region product

            services.AddTransient<IGetAllProductQuery, GetAllProductQuery >();



            #endregion
            #region ventasView
            services.AddTransient<IVentasViewService, VentasViewService>();


            services.AddTransient<IVentasHistoricoViewService, VentasHistoricoViewService>();
            services.AddTransient<IEditarVentaViewService, EditarVentaViewService>();

            
            #endregion
            #region Sesion

            services.AddTransient<ICreateSesionCommand, CreateSesionCommand>();
            #endregion

            services.AddSingleton(mapper.CreateMapper());
            return services;
        }
    }
}
