예제 #1
0
 public static MemberDisplayEdit SaveMemberEdit(Guid memId, Guid uid, MemberDisplayEdit member)
 {
     var response = Network.SendPackage(Network.ConvertObjectToStream(new MemberPassParams() { Mid = memId, Uid = uid, Member = member }), MobileConfig.MEMBER_EDIT_SAVE_GET_URL);
     var stream = response.GetResponseStream();
     StreamReader read = new StreamReader(stream);
     string json = read.ReadToEnd();
     return Json.DeserializeObject<MemberDisplayEdit>(json);
 }
        public EditProfile()
        {
            InitializeComponent();
            try
            {
                member = new MemberDisplayEdit();
                var dict = Enum.GetValues(typeof(GenderEnum))
                           .Cast<GenderEnum>()
                           .ToDictionary(t => (int)t, t => EnumExt.ToFreindlyName(t));

                Gender.ItemsSource = dict;

                progressIndicator = new ProgressIndicator();

                SystemTray.SetProgressIndicator(this, progressIndicator);
                progressIndicator.IsIndeterminate = true;
                progressIndicator.Text = "Pulling Member...";
                progressIndicator.IsVisible = true;
                Task.Run(new Action(() =>
                {
                    member = UserMobileWP.GetMemberEdit(SettingsMobile.Instance.User.MemberId, SettingsMobile.Instance.User.LoginId);
                    if (member != null && member.IsSuccessful)
                    {
                        Dispatcher.BeginInvoke(delegate
                        {
                            try
                            {
                                progressIndicator.IsVisible = false;
                                if (!String.IsNullOrEmpty(member.DerbyName)) DerbyName.Text = member.DerbyName;

                                if (!String.IsNullOrEmpty(member.PlayerNumber)) DerbyNumber.Text = member.PlayerNumber;
                                if (!String.IsNullOrEmpty(member.Firstname)) FirstName.Text = member.Firstname;
                                if (!String.IsNullOrEmpty(member.LastName)) LastName.Text = member.LastName;
                                Gender.SelectedItem = dict.Where(x => x.Key == (int)member.Gender).FirstOrDefault();
                                HeightFeet.Text = member.HeightFeet.ToString();
                                HeightInches.Text = member.HeightInches.ToString();
                                Weight.Text = member.WeightLbs.ToString();
                                DOB.Value = member.DOB;
                                if (!String.IsNullOrEmpty(member.PhoneNumber)) Phone.Text = member.PhoneNumber;
                                if (!String.IsNullOrEmpty(member.Email)) Email.Text = member.Email;
                                if (!String.IsNullOrEmpty(member.DayJob)) Job.Text = member.DayJob;

                                StartSkating.Value = member.StartedSkating;
                                StopSkating.Value = member.StoppedSkating;
                                if (!String.IsNullOrEmpty(member.InsuranceNumWftda)) WFTDANum.Text = member.InsuranceNumWftda;
                                WFTDAExpires.Value = member.InsuranceNumWftdaExpires;
                                if (!String.IsNullOrEmpty(member.InsuranceNumUsars)) USARSNum.Text = member.InsuranceNumUsars;
                                USARSExpires.Value = member.InsuranceNumUsarsExpires;
                                if (!String.IsNullOrEmpty(member.InsuranceNumCRDI)) CRDINum.Text = member.InsuranceNumCRDI;
                                CRDIExpires.Value = member.InsuranceNumCRDIExpires;
                                if (!String.IsNullOrEmpty(member.InsuranceNumOther)) OtherNum.Text = member.InsuranceNumOther;
                                OtherExpires.Value = member.InsuranceNumOtherExpires;
                                HideProfileFromPublic.IsChecked = member.IsProfileRemovedFromPublicView;
                                if (!String.IsNullOrEmpty(member.Address)) Address1.Text = member.Address;
                                if (!String.IsNullOrEmpty(member.Address2)) Address2.Text = member.Address2;
                                if (!String.IsNullOrEmpty(member.City)) City.Text = member.City;
                                if (!String.IsNullOrEmpty(member.State)) State.Text = member.State;
                                if (!String.IsNullOrEmpty(member.ZipCode)) Zip.Text = member.ZipCode;
                                Country.ItemsSource = member.Countries;
                                if (member.Country > 0)
                                    Country.SelectedItem = member.Countries.Where(x => x.CountryId == member.Country).FirstOrDefault();

                            }
                            catch (Exception exception)
                            {
                                ErrorHandler.Save(exception, MobileTypeEnum.WP8);
                            }
                        });
                    }

                }));
            }
            catch (Exception exception)
            {
                ErrorHandler.Save(exception, MobileTypeEnum.WP8);
            }
        }
        public ActionResult EditMember()
        {
            try
            {
                if (HttpContext.Request.InputStream != null)
                {
                    Stream stream = HttpContext.Request.InputStream;
                    var ob = Network.LoadObject<MemberPassParams>(ref stream);
                    var mem = MemberCache.GetMemberDisplay(ob.Mid);
                    if (ob.Uid == mem.UserId)
                    {

                        MemberDisplayEdit m = new MemberDisplayEdit();
                        m.IsSuccessful = true;
                        m.Countries = ApiCache.GetCountriesInfo();
                        if (mem.ContactCard.Addresses.Count > 0)
                        {
                            foreach (var add in mem.ContactCard.Addresses)
                            {
                                m.Address = add.Address1;
                                m.Address2 = add.Address2;
                                m.City = add.CityRaw;
                                m.State = add.StateRaw;
                                m.ZipCode = add.Zip;
                                if (m.Countries.Where(x => x.Code == add.Country).FirstOrDefault() != null)
                                    m.Country = m.Countries.Where(x => x.Code == add.Country).FirstOrDefault().CountryId;
                            }
                        }

                        m.DayJob = mem.DayJob;
                        m.DerbyName = mem.DerbyName;
                        m.DerbyNameUrl = mem.DerbyNameUrl;
                        m.DOB = mem.DOB;
                        m.Email = mem.Email;
                        m.Firstname = mem.Firstname;
                        m.Gender = mem.Gender;
                        m.HeightFeet = mem.HeightFeet;
                        m.HeightInches = mem.HeightInches;
                        m.InsuranceNumCRDI = mem.InsuranceNumCRDI;
                        m.InsuranceNumCRDIExpires = mem.InsuranceNumCRDIExpires;
                        m.InsuranceNumOther = mem.InsuranceNumOther;
                        m.InsuranceNumOtherExpires = mem.InsuranceNumOtherExpires;
                        m.InsuranceNumUsars = mem.InsuranceNumUsars;
                        m.InsuranceNumUsarsExpires = mem.InsuranceNumUsarsExpires;
                        m.InsuranceNumWftda = mem.InsuranceNumWftda;
                        m.InsuranceNumWftdaExpires = mem.InsuranceNumWftdaExpires;
                        m.IsProfileRemovedFromPublicView = mem.IsProfileRemovedFromPublicView;
                        m.IsRetired = mem.IsRetired;
                        m.LastName = mem.LastName;
                        m.MemberId = mem.MemberId;
                        m.PhoneNumber = mem.PhoneNumber;
                        m.PlayerNumber = mem.PlayerNumber;
                        m.StartedSkating = mem.StartedSkating;
                        m.StoppedSkating = mem.StoppedSkating;
                        if (mem.Photos.FirstOrDefault() != null)
                            m.ThumbUrl = mem.Photos.FirstOrDefault().ImageThumbUrl;
                        m.WeightLbs = mem.WeightLbs;
                        return Json(m, JsonRequestBehavior.AllowGet);

                    }
                }
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, GetType());
            }
            return Json(new MemberDisplayEdit() { IsSuccessful = false }, JsonRequestBehavior.AllowGet);
        }