using System.Collections.Generic; using System.Web.Mvc; using Neo.Afx.Services.Integration; using Neo.Afx.Services.Workflows; using Neo.Afx.ViewModels; using Neo.LegitimateLicences.Data.Models; using Neo.LegitimateLicences.Web.Models; using Neo.Afx.Admin.Security; using System.Linq; using System; namespace Neo.LegitimateLicences.Web.Controllers { [Authorize] public class ProfileController : Neo.LegitimateLicences.Common.ControllerBase { #region MyProfile public ActionResult MyProfile() { #region Get Profile Model var model = new ProfileModel(); var database = new SecurityDatabase(); model.Settings = database.GetUserSettings(Profile.UserID).Where(a => a.SettingName != "RegionID").ToList(); var user = database.GetUser(Profile.UserID, Profile.UserID); model.FirstName = user.FirstName; model.LastName = user.LastName; model.KnownAs = user.KnownAs; model.UserProfileDocID = user.UserProfileDocID; #endregion return View("~/Views/Home/MyProfile.cshtml", model); } #endregion #region JSON endpoints #region SaveProfile [HttpPost] public JsonResult SaveProfile(string firstName, string lastName, string knownAs, string cell, long? userProfileDocID, List settings) { var database = new SecurityDatabase(); var errorMessage = ""; try { database.SaveUser(Profile.UserID, knownAs, lastName, firstName, Profile.Email, Profile.Email, cell, Profile.OfficeLocationID.Value, userProfileDocID, Profile.UserID); database.SaveUserSetting(settings, Profile.UserID, Profile.UserID); } catch (Exception ex) { errorMessage = Neo.Afx.Common.ExceptionHelper.GetInnermostMessage(ex); } var results = new { ErrorMessage = errorMessage }; return Json(results, Neo.Afx.Mvc.JsonSerializerOptions.None); } #endregion #endregion } }