using AutoMapper;
using SessionCompanion.Database.Repositories.Base;
using SessionCompanion.Database.Tables;
using SessionCompanion.Services.Base;
using SessionCompanion.Services.Interfaces;
using SessionCompanion.ViewModels.UserViewModels;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Linq;
using Microsoft.EntityFrameworkCore;

namespace SessionCompanion.Services.Services
{
    public class UserService : ServiceBase<UserViewModel, User>, IUserService
    {
        public UserService(IMapper mapper, IRepository<User> repository) : base(mapper, repository)
        { }

        public async Task<UserViewModel> SearchUserByUsername(string userName)
        {
            var User = await Repository.Get(u => u.Username.Equals(userName)).FirstOrDefaultAsync();
            return Mapper.Map<UserViewModel>(User);
        }
    }
}