Esempio n. 1
0
        public ActionResult EditProfile(UserProfile model, FormCollection collection)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    int day   = Int16.Parse(collection["day"]);
                    int month = Int16.Parse(collection["month"]);
                    int year  = Int16.Parse(collection["year"]);

                    model.BirthDate         = new DateTime(year, month, day);
                    model.ProfilePictureUrl = SessionData.ImgUrl;
                    UserProfilesLogic.UpdateUserProfile(model);
                    SessionData.profileImageUrl = model.ProfilePictureUrl;
                    SessionData.ImgUrl          = null;
                    return(RedirectToAction("Index", "Home"));
                }
                model = UserProfilesLogic.GetUserByUserName(SessionData.UserName);
            }
            catch (Exception e)
            {
                LogsLogic.InsertLog(new Log()
                {
                    Message    = e.Message,
                    StackTrace = e.StackTrace,
                    StoryName  = "ManagmentProject/Profile/EditProfile(Post)",
                    Parameters = "UserProfile=" + new JavaScriptSerializer().Serialize(model) + "&Collection=" + new JavaScriptSerializer().Serialize(collection)
                });
            }
            return(View(model));
        }
Esempio n. 2
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"
                });
            }
        }
Esempio n. 3
0
        public ActionResult EditProfile()
        {
            UserProfile model = new UserProfile();

            try
            {
                model = UserProfilesLogic.GetUserByUserName(SessionData.UserName);
            }
            catch (Exception e)
            {
                LogsLogic.InsertLog(new Log()
                {
                    Message    = e.Message,
                    StackTrace = e.StackTrace,
                    StoryName  = "ManagmentProject/Profile/EditProfile"
                });
            }
            return(View(model));
        }