using Microsoft.AspNet.Identity;
|
|
using Microsoft.AspNet.Identity.EntityFramework;
|
|
using Sevomin.Models;
|
|
using Sevomin.Models.Helpers;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Web.Mvc;
|
|
|
|
namespace Sevomin.WebFrontend.Controllers
|
|
{
|
|
public class GodController : AuthorizedController
|
|
{
|
|
[Authorize(Roles = "God")]
|
|
public ActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[AllowAnonymous]
|
|
public async Task<ActionResult> iddqd()
|
|
{
|
|
UserManager.UserValidator = new UserValidator<User>(UserManager);
|
|
RoleManager<IdentityRole> roleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(SevominDbContext.Current));
|
|
if (!(await roleManager.RoleExistsAsync("God")))
|
|
await roleManager.CreateAsync(new IdentityRole("God"));
|
|
if ((await UserManager.FindByNameAsync("sevomin")) == null)
|
|
{
|
|
var user = new User("sevomin");
|
|
user.SignUpDate = DateTime.UtcNow;
|
|
await UserManager.CreateAsync(user, "wePwntheNight");
|
|
}
|
|
|
|
var res = await UserManager.AddToRoleAsync((await UserManager.FindByNameAsync("sevomin")).Id, "God");
|
|
|
|
return HttpNotFound();
|
|
}
|
|
|
|
[Authorize(Roles = "God")]
|
|
[HttpPost]
|
|
public void UpdateParam(long paramId, string commentAvalin, string commentDovomin)
|
|
{
|
|
var param = SevominDbContext.Current.Parameters.FirstOrDefault(p => p.Id == paramId);
|
|
if (param != null)
|
|
{
|
|
param.CommentAvalin = commentAvalin;
|
|
param.CommentDovomin = commentDovomin;
|
|
|
|
SevominDbContext.Current.SaveChanges();
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|