private void InitUserSession() { try { _SessionData = new UserDataSession() { UserName = User.Identity.Name, }; DataMapping.Entities.UserProfile user = UserProfilesLogic.GetUserByUserName(User.Identity.Name); _SessionData.UserId = user.UserId; _SessionData.profileImageUrl = user.ProfilePictureUrl; if (Roles.IsUserInRole("Admin")) { _SessionData.UserRole = UserRoles.Admin; } else if (Roles.IsUserInRole("Employee")) { _SessionData.UserRole = UserRoles.Employee; } Session["UserSession"] = _SessionData; } catch (Exception e) { LogsLogic.InsertLog(new Log() { Message = e.Message, StackTrace = e.StackTrace, StoryName = "ManagementProject/Base/InitUserSession" }); } }
public ActionResult Create(int roleId) { DataMapping.Entities.UserProfile user = new DataMapping.Entities.UserProfile { RolesId = roleId }; return(View(user)); }
public static void CreateUserProject(UsersProjectModel userProject) { DateTime myDate = DateTimeHelper.Today(); DataMapping.Entities.UserProfile user = UserProfilesLogic.GetUserByUserName(userProject.UserName); userProject.UserId = user.UserId; UsersProjectRepositories.CreateUserProject(userProject, myDate); }
public ActionResult Create(DataMapping.Entities.UserProfile User) { if (ModelState.IsValid) { try { if (Session["PublicImageUrl"] != null) { User.ProfilePictureUrl = Session["PublicImageUrl"].ToString(); } else { User.ProfilePictureUrl = null; } WebSecurity.CreateUserAndAccount(User.UserName, User.Password); if (User.RolesId == 1) { DataMapping.Entities.UserProfile userModel = AdminLogic.GetAdminByName(User.UserName); AdminLogic.UpdateAdminById(User, userModel.UserId); } Session["PublicImageUrl"] = ""; return(RedirectToAction("Index", new { roleId = User.RolesId })); // return PartialView("JavascriptRedirect", new JavascriptRedirectModel("/Home/Index")); } catch (Exception e) { LogsLogic.InsertLog(new Log() { Message = e.Message, StackTrace = e.StackTrace, StoryName = "MoreHolidays/Users/Create(Post)" }); Session["PublicImageUrl"] = ""; return(View()); } //Parameters = new JavaScriptSerializer().Serialize(project) } Session["PublicImageUrl"] = ""; return(View()); }
// GET: Users public ActionResult Index(int roleId) { DataMapping.Entities.UserProfile user = new DataMapping.Entities.UserProfile(); user.RolesId = roleId; return(View(user)); }