using AutoMapper;
using VentaUniformes.Application.Interfaces;
using VentaUniformes.Domain.Entities.User;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VentaUniformes.Application.Persistencia.user.commands.CreateUser
{
    public class CreateUserCommand: IcreateUserCommand
    {
        private readonly IPersistenciaService _persistenciaService;
        private IMapper _mapper;

        public CreateUserCommand(IPersistenciaService persistenciaService, IMapper mapper)
        {
            _persistenciaService = persistenciaService;
            _mapper = mapper;
        }
        public async Task<CreateUserModel>Execute(CreateUserModel model)
        {
            var entity = _mapper.Map<UserEntity>(model);
            //aqui se guarda realmente
           await _persistenciaService.AddUser(entity);
            return model;
        }
    }
}
