<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Microsoft.AspNet.Identity;
using PhotoLife.Area.Admin.Models;
using PhotoLife.Authentication.Providers;
using PhotoLife.Services.Contracts;

namespace PhotoLife.Area.Admin.Controllers
{
    [Authorize(Roles = "Administrator")]
    public class UserAdminController : Controller
    {
        private readonly IUserService userService;
        private readonly IAuthenticationProvider authProvider;

        public UserAdminController(IUserService userService, IAuthenticationProvider authProvider)
        {
            if (userService == null)
            {
                throw new ArgumentNullException("userService");
            }

            if (authProvider == null)
            {
                throw new ArgumentNullException("authProvider");
            }

            this.userService = userService;
            this.authProvider = authProvider;
        }

        // GET: UserAdmin
        public ActionResult Index(int page =1, int count = 15)
        {
            var users = this.userService.GetUsers();

            var model = new List<UserViewModel>();

            foreach (var user in users)
            {
                var isAdmin = this.authProvider.IsInRole(user.Id, Constants.AdministratorRoleName);
                var viewModel = new UserViewModel(user, isAdmin);
                model.Add(viewModel);
            }


            return View();
        }
    }
}<commit_msg>Finish userAdminController<commit_after>﻿using System;
using System.Collections.Generic;
using System.Web.Mvc;
using PagedList;
using PhotoLife.Area.Admin.Models;
using PhotoLife.Authentication.Providers;
using PhotoLife.Services.Contracts;

namespace PhotoLife.Area.Admin.Controllers
{
    [Authorize(Roles = "Administrator")]
    public class UserAdminController : Controller
    {
        private readonly IUserService userService;
        private readonly IAuthenticationProvider authProvider;

        public UserAdminController(IUserService userService, IAuthenticationProvider authProvider)
        {
            if (userService == null)
            {
                throw new ArgumentNullException("userService");
            }

            if (authProvider == null)
            {
                throw new ArgumentNullException("authProvider");
            }

            this.userService = userService;
            this.authProvider = authProvider;
        }

        // GET: UserAdmin
        public ActionResult Index(int page = 1, int count = 15)
        {
            var users = this.userService.GetUsers();

            var model = new List<UserViewModel>();

            foreach (var user in users)
            {
                var isAdmin = this.authProvider.IsInRole(user.Id, "Administrator");
                var viewModel = new UserViewModel(user, isAdmin);
                model.Add(viewModel);
            }

            return this.View(model.ToPagedList(page, count));
        }

        public ActionResult RemoveAdmin(string userId, int page)
        {
            this.authProvider.RemoveFromRole(userId, "Administrator");

            return this.RedirectToAction("Index", new { page = page });
        }

        public ActionResult AddAdmin(string userId, int page)
        {
            this.authProvider.AddToRole(userId, "Administrator");

            return this.RedirectToAction("Index", new { page = page });
        }
    }
}
{'fraction_non_alphanumeric': 0.08459559874249786, 'fraction_numerical': 0.0017147756501857674, 'mean_word_length': 2.141831238779174, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5832516', 'n_tokens_mistral': 882, 'n_tokens_neox': 845, 'n_words': 202}