session-companion/SessionCompanion/SessionCompanion.Services/Services/UserService.cs
2020-12-09 23:09:57 +01:00

28 lines
902 B
C#

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> SearchUserByNickname(string userName)
{
var User = await Repository.Get(u => u.Nickname.Equals(userName)).FirstOrDefaultAsync();
return Mapper.Map<UserViewModel>(User);
}
}
}