Combine layouts
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using MileageTraker.Web.Models;
|
||||
using MileageTraker.Web.Context;
|
||||
using MileageTraker.Web.ViewModels.User;
|
||||
|
||||
namespace MileageTraker.Web.Controllers
|
||||
{
|
||||
[Authorize(Roles = "Administrator, Developer")]
|
||||
public class UserController : ControllerBase
|
||||
{
|
||||
public ActionResult Index()
|
||||
{
|
||||
return View(DataService.GetUsers().ToList());
|
||||
}
|
||||
|
||||
public ActionResult Details(Guid id)
|
||||
{
|
||||
var user = DataService.GetUser(id);
|
||||
if (user == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
return View(user);
|
||||
}
|
||||
|
||||
public ActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Create(CreateUserViewModel createUserViewModel)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
var user = createUserViewModel.CloneToUser();
|
||||
user.UserId = Guid.NewGuid();
|
||||
//db.Users.Add(user);
|
||||
//db.SaveChanges();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
return View(createUserViewModel);
|
||||
}
|
||||
|
||||
public ActionResult Edit(Guid id)
|
||||
{
|
||||
var user = DataService.GetUser(id);
|
||||
if (user == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
return View(user);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Edit(User user)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
//db.Entry(user).State = EntityState.Modified;
|
||||
//db.SaveChanges();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user