Files
InventoryTracker/InventoryTraker.Web/Controllers/ProfileController.cs
T
2016-08-08 14:47:35 -04:00

35 lines
818 B
C#

using System.Web.Mvc;
using AutoMapper;
using InventoryTraker.Web.Identity;
using InventoryTraker.Web.Models;
using Microsoft.AspNet.Identity;
namespace InventoryTraker.Web.Controllers
{
public class ProfileController : ControllerBase
{
private readonly ApplicationUserManager _userManager;
public ProfileController(ApplicationUserManager userManager)
{
_userManager = userManager;
}
public ActionResult Index()
{
var user = _userManager.FindById(User.Identity.GetUserId());
var model = Mapper.Map<ProfileForm>(user);
return View(model);
}
public JsonResult Update(ProfileForm form)
{
var user = _userManager.FindById(User.Identity.GetUserId());
user.Email = form.EmailAddress;
user.UserName = form.FullName;
_userManager.Update(user);
return Json(true);
}
}
}