public ActionResult UserProfile(UserProfileModel up)
        {
            if (Session["UserID"] == null)
            {
                return(RedirectToAction("Login", "Authentication", new { ReturnUrl = "/RegisteredUser/UserProfile" }));
            }

            int UserID = Convert.ToInt32(User.Identity.Name);

            if (ModelState.IsValid)
            {
                DateTime Birthdate = up.DOB == null ? DateTime.MinValue : (System.DateTime)up.DOB;

                if (up.ProfilePictureFile != null && !MimeMapping.GetMimeMapping(up.ProfilePictureFile.FileName).Contains("image"))
                {
                    ModelState.AddModelError("ProfilePictureFile", "Only Images Are Allowed");
                    up.ProfilePicture = UserRepository.GetUserData(Convert.ToInt32(User.Identity.Name)).ProfilePicture;
                }
                else if (up.DOB != null && (DateTime.Compare(Birthdate, DateTime.Now.AddYears(-130)) < 0 || DateTime.Compare(Birthdate, DateTime.Now) > 0))
                {
                    ModelState.AddModelError("DOB", "Please Enter Valid Date");
                    up.ProfilePicture = UserRepository.GetUserData(Convert.ToInt32(User.Identity.Name)).ProfilePicture;
                }
                else
                {
                    UserProfileModel updated = UserRepository.addUserProfile(up, UserID, Server.MapPath(@"~/"));

                    if (updated != null)
                    {
                        ViewBag.Message = "User Profile Updated";
                        up = updated;
                        return(RedirectToAction("Login", "Authentication", new { ReturnURL = @"/RegisteredUser/UserProfile" }));
                    }
                    else
                    {
                        ViewBag.Message = "Something went wrong please try again";
                    }
                }
            }


            ViewBag.Genders              = DropdownItems.Genders();
            ViewBag.CountryCodes         = DropdownItems.CountryCodes();
            ViewBag.Countries            = NotesFilters.Countries();
            ViewBag.LoadValidationScript = true;
            ViewBag.Title      = "UserProfile";
            ViewBag.Authorized = true;
            return(View(up));
        }
        public ActionResult UserProfile()
        {
            if (Session["UserID"] == null)
            {
                return(RedirectToAction("Login", "Authentication", new { ReturnUrl = "/RegisteredUser/UserProfile" }));
            }

            UserProfileModel userProfile = UserRepository.GetUserData(Convert.ToInt32(User.Identity.Name));

            ViewBag.Genders              = DropdownItems.Genders();
            ViewBag.CountryCodes         = DropdownItems.CountryCodes();
            ViewBag.Countries            = NotesFilters.Countries();
            ViewBag.LoadValidationScript = true;
            ViewBag.Title      = "UserProfile";
            ViewBag.Authorized = true;
            return(View(userProfile));
        }