using Serwer.Core.Domain; using Serwer.Core.Repositories; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Serwer.Infrastructure.Repositories { public class UserRepository : IUserRepository { private static ISet _users = new HashSet(); public async Task AddAsync(User user) { await Task.FromResult(_users.Add(user)); } public async Task> GetAllAsync() { return await Task.FromResult(_users); } public async Task GetAsync(Guid id) { return await Task.FromResult(_users.SingleOrDefault(x => x.Id == id)); } public async Task GetAsync(string login) { return await Task.FromResult(_users.SingleOrDefault(x => x.Login == login)); } public async Task RemoveAsync(Guid id) { var user = await GetAsync(id); _users.Remove(user); } public async Task UpdateAsync(User user) { var dbuser = await GetAsync(user.Id); dbuser.SetEmail(user.Email); dbuser.SetLogin(user.Login); dbuser.SetName(user.Name); dbuser.SetSurname(user.Surname); dbuser.SetPassword(user.Password); } } }