using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Shride.Models
{
  public class UserRepository : IUserRepository
  {

    private UserDbContext context;

    public UserRepository(UserDbContext ctx)
    {
      context = ctx;
    }

    public async Task<IdentityUser> GetUser(String name)
    {
      IdentityUser currentUser = await context.Users.FindAsync(name); //userManager.FindByNameAsync(name);
      return currentUser;
    }

    public async Task CreateUser(User newUser)
    {
      IdentityUser user = await GetUser(newUser.Name);
      if(user == null)
      {
        await context.Users.AddAsync(user);// userManager.CreateAsync(user, newUser.Password);
        context.SaveChanges();
      }
    }

    // Skapa roller
  }
}
