using ResourcesManager.Interfaces;
using ResourcesManager.Models;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;

namespace ResourcesManager.Repositories
{
    public class UserRepository : BaseRepository, IUserRepository
    {
        public UserRepository(ApplicationDbContext context) : base(context) { }

        public void DeleteUser(string id)
        {
            var user = Context.Users.Find(id);
            Context.Users.Remove(user);
            Save();
        }

        public ApplicationUser GetUserByID(string id)
        {
            return Context.Users.Find(id);
        }

        public IEnumerable<ApplicationUser> GetUsers()
        {
            return Context.Users;
        }

        public void InsertUser(ApplicationUser user)
        {
            Context.Users.Add(user);
            Save();
        }

        public void UpdateUser(ApplicationUser user)
        {
            Context.Entry(user).State = EntityState.Modified;
            Save();
        }
    }
}