session-companion/SessionCompanion/SessionCompanion.Services/Services/UserService.cs

28 lines
902 B
C#
Raw Normal View History

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)
{ }
2020-12-09 22:47:25 +01:00
public async Task<UserViewModel> SearchUserByUsername(string userName)
2020-12-09 23:09:57 +01:00
{
var User = await Repository.Get(u => u.Username.Equals(userName)).FirstOrDefaultAsync();
2020-12-09 23:09:57 +01:00
return Mapper.Map<UserViewModel>(User);
}
}
}