Ejemplo n.º 1
0
        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"
                });
            }
        }
Ejemplo n.º 2
0
 public ActionResult Create(int roleId)
 {
     DataMapping.Entities.UserProfile user = new DataMapping.Entities.UserProfile {
         RolesId = roleId
     };
     return(View(user));
 }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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());
        }
Ejemplo n.º 5
0
 // GET: Users
 public ActionResult Index(int roleId)
 {
     DataMapping.Entities.UserProfile user = new DataMapping.Entities.UserProfile();
     user.RolesId = roleId;
     return(View(user));
 }