public ActionResult EditMemberMySelf(EditMember member, HttpPostedFileBase file)
        {
            try
            {
                ViewBag.Saved = true;
                ViewBag.Retired = false;
                Guid id = member.MemberId;
                if (member.MemberId == new Guid())
                    id = RDN.Library.Classes.Account.User.GetMemberId();
                var edit = RDN.Library.Cache.MemberCache.GetMemberDisplay(id);

                MemberDisplay newMemberWithImage = null;

                edit.Bio = member.Bio;
                if (!String.IsNullOrEmpty(member.DerbyName))
                    edit.DerbyName = member.DerbyName.Trim();
                if (member.DOB != null && member.DOB > DateTime.Now.AddYears(-100))
                    edit.DOB = member.DOB;
                else if (member.DOB == new DateTime())
                    edit.DOB = new DateTime();
                edit.Email = member.Email;
                if (!String.IsNullOrEmpty(member.Email))
                    edit.Email = member.Email.Trim();
                edit.DayJob = member.DayJob;
                if (member.StartedSkating != null && member.StartedSkating > DateTime.Now.AddYears(-100))
                    edit.StartedSkating = member.StartedSkating;
                if (member.StoppedSkating != null && member.StoppedSkating > DateTime.Now.AddYears(-100))
                    edit.StoppedSkating = member.StoppedSkating;

                edit.InsuranceNumOther = member.InsuranceNumOther;
                edit.InsuranceNumOtherExpires = member.InsuranceNumOtherExpires;
                edit.InsuranceNumUsars = member.InsuranceNumUsars;
                edit.InsuranceNumUsarsExpires = member.InsuranceNumUsarsExpires;
                edit.InsuranceNumWftda = member.InsuranceNumWftda;
                edit.InsuranceNumWftdaExpires = member.InsuranceNumWftdaExpires;
                edit.InsuranceNumCRDI = member.InsuranceNumCRDI;
                edit.InsuranceNumCRDIExpires = member.InsuranceNumCRDIExpires;

                edit.IsProfileRemovedFromPublicView = member.IsProfileRemovedFromPublicView;
                if (!String.IsNullOrEmpty(member.Firstname))
                    edit.Firstname = member.Firstname.Trim();
                else
                    edit.Firstname = member.Firstname;
                edit.Gender = member.Gender;
                edit.HeightFeet = member.HeightFeet;
                edit.HeightInches = member.HeightInches;
                edit.LastName = member.LastName;

                edit.MemberId = member.MemberId;
                edit.PhoneNumber = member.PhoneNumber;
                edit.Photos = member.Photos;
                edit.PlayerNumber = member.PlayerNumber;
                edit.WeightLbs = member.WeightLbs;
                edit.IsRetired = member.IsRetired;

                edit.Address = member.Address;
                edit.Address2 = member.Address2;
                edit.City = member.City;
                edit.State = member.State;
                edit.ZipCode = member.ZipCode;

                ViewData["genderSelectList"] = member.Gender.ToSelectList();
                var countries = RDN.Library.Classes.Location.LocationFactory.GetCountries();
                member.Countries = new SelectList(countries, "CountryId", "Name");
                edit.CountryId = member.Country;

                foreach (var leag in edit.Leagues)
                {
                    if (!String.IsNullOrEmpty(HttpContext.Request.Form[leag.LeagueId + "-LEAGUEDepartureDate"]))
                    {
                        DateTime outDT;
                        bool success = DateTime.TryParse(HttpContext.Request.Form[leag.LeagueId + "-LEAGUEDepartureDate"], out outDT);
                        if (success)
                            leag.DepartureDate = outDT;
                    }
                }

                if (file != null)
                    newMemberWithImage = RDN.Library.Classes.Account.User.UpdateMemberDisplayForMember(edit, file.InputStream, file.FileName);
                else
                    newMemberWithImage = RDN.Library.Classes.Account.User.UpdateMemberDisplayForMember(edit);

                RDN.Library.Cache.MemberCache.Clear(id);
                MemberCache.ClearApiCache(id);

                return Redirect(Url.Content("~/member/edit?u=" + SiteMessagesEnum.s));
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType(), additionalInformation: member.MemberId.ToString());
            }
            return Redirect(Url.Content("~/?u=" + SiteMessagesEnum.sww));
        }
        public ActionResult UnRetireSelf(EditMember member)
        {
            try
            {
                ViewBag.Saved = false;

                RDN.Library.Classes.Account.User.UnRetireMember(member.MemberId);
                RDN.Library.Cache.MemberCache.Clear(member.MemberId);
                MemberCache.ClearApiCache(member.MemberId);

                return Redirect(Url.Content("~/member/edit"));
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return Redirect(Url.Content("~/?u=" + SiteMessagesEnum.sww));
        }
        public ActionResult EditMemberMySelf(string id)
        {
            try
            {
                NameValueCollection nameValueCollection = HttpUtility.ParseQueryString(Request.Url.Query);
                string u = nameValueCollection["u"];
                if (u == SiteMessagesEnum.s.ToString())
                {
                    SiteMessage message = new SiteMessage();
                    message.MessageType = SiteMessageType.Success;
                    message.Message = "Successfully Updated Profile.";
                    this.AddMessage(message);
                }
                var memid = RDN.Library.Classes.Account.User.GetMemberId();
                ViewBag.Retired = false;
                MemberDisplay member = null;
                //if an admin wants to edit the member.
                if (id != null && MemberCache.IsAdministrator(memid))
                {
                    member = RDN.Library.Cache.MemberCache.GetMemberDisplay(new Guid(id));
                }
                else
                {
                    //for everyone else.
                    member = RDN.Library.Cache.MemberCache.GetMemberDisplay(memid);
                }

                EditMember edit = new EditMember();
                edit.IsProfileRemovedFromPublicView = member.IsProfileRemovedFromPublicView;
                edit.IsRetired = member.IsRetired;
                edit.Bio = member.Bio;
                edit.DerbyName = member.DerbyName;
                edit.DOB = member.DOB;
                edit.Email = member.Email;
                edit.DayJob = member.DayJob;
                edit.StartedSkating = member.StartedSkating;
                edit.StoppedSkating = member.StoppedSkating;
                edit.InsuranceNumOther = member.InsuranceNumOther;
                edit.InsuranceNumOtherExpires = member.InsuranceNumOtherExpires;
                edit.InsuranceNumUsars = member.InsuranceNumUsars;
                edit.InsuranceNumUsarsExpires = member.InsuranceNumUsarsExpires;
                edit.InsuranceNumWftda = member.InsuranceNumWftda;
                edit.InsuranceNumWftdaExpires = member.InsuranceNumWftdaExpires;
                edit.InsuranceNumCRDI = member.InsuranceNumCRDI;
                edit.InsuranceNumCRDIExpires = member.InsuranceNumCRDIExpires;


                foreach (var fed in member.FederationsApartOf)
                {
                    FederationDisplay fe = new FederationDisplay();
                    fe.FederationComments = fed.FederationComments;
                    fe.FederationId = fed.FederationId;
                    fe.FederationName = fed.FederationName;
                    fe.MADEClassRank = fed.MADEClassRank;
                    fe.MemberType = fed.MemberType;
                    fe.OwnerType = fed.OwnerType;
                    edit.FederationsApartOf.Add(fe);
                }

                edit.Leagues = member.Leagues;
                edit.Firstname = member.Firstname;
                edit.Gender = member.Gender;
                edit.HeightFeet = member.HeightFeet;
                edit.HeightInches = member.HeightInches;
                edit.LastName = member.LastName;
                edit.MemberId = member.MemberId;
                edit.UserId = member.UserId;
                edit.PhoneNumber = member.PhoneNumber;
                edit.Photos = member.Photos;

                edit.PlayerNumber = member.PlayerNumber;
                edit.WeightLbs = member.WeightLbs;
                ViewData["genderSelectList"] = member.Gender.ToSelectList();
                var countries = RDN.Library.Classes.Location.LocationFactory.GetCountries();
                edit.Countries = new SelectList(countries, "CountryId", "Name");
                if (member.ContactCard.Addresses.Count > 0)
                {
                    foreach (var add in member.ContactCard.Addresses)
                    {
                        edit.Address = add.Address1;
                        edit.Address2 = add.Address2;
                        edit.City = add.CityRaw;
                        edit.State = add.StateRaw;
                        edit.ZipCode = add.Zip;
                        if (countries.Where(x => x.Code == add.Country).FirstOrDefault() != null)
                            edit.Country = countries.Where(x => x.Code == add.Country).FirstOrDefault().CountryId;
                    }
                }

                return View(edit);
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return Redirect(Url.Content("~/?u=" + SiteMessagesEnum.sww));
        }