Exemplo n.º 1
0
        async void buttonOk_Clicked(object sender, EventArgs e)
        {
            if (await this.DisplayAlert("Byb", "Information correct?", "Yes, correct", "Cancel") != true)
            {
                return;
            }

            VenueEditWebModel edit = new VenueEditWebModel();

            edit.VenueID = Venue.ID;
            if (this.picker10fTables.SelectedIndex >= 0)
            {
                edit.NumberOf10fSnookerTables = this.picker10fTables.SelectedIndex;
            }
            if (this.picker12fTables.SelectedIndex >= 0)
            {
                edit.NumberOf12fSnookerTables = this.picker12fTables.SelectedIndex;
            }
            edit.PhoneNumber = this.entryPhone.Text;
            edit.Website     = this.entryWebsite.Text;
            edit.Address     = this.entryAddress.Text;
            edit.IsInvalid   = !this.switchValidVenue.IsToggled;

            PleaseWaitPage waitPage = new PleaseWaitPage();
            await App.Navigator.NavPage.Navigation.PushModalAsync(waitPage);

            bool ok = await App.WebService.VerifyOrEditVenue(edit);

            await App.Navigator.NavPage.Navigation.PopModalAsync();

            if (ok == false)
            {
                await DisplayAlert("Byb", "Couldn't post this to the web service. Internet issues?", "OK");

                return;
            }

            // update the venue in the Cache
            var updatedVenue = await App.WebService.GetVenue(Venue.ID);

            App.Cache.Venues.Put(updatedVenue);

            // let other pages know
            App.Navigator.DoOnVenueEdited(Venue.ID);
        }
Exemplo n.º 2
0
        public async Task <bool> VerifyOrEditVenue(VenueEditWebModel venueEdit)
        {
            string url = WebApiUrl + "Venues/VerifyOrEditVenue";

            try
            {
                string json = await this.sendPostRequestAndReceiveResponse(url, venueEdit, true);

                bool ok = JsonConvert.DeserializeObject <bool>(json);
                return(ok);
            }
            catch (Exception exc)
            {
                LastExceptionUrl = url;
                LastException    = exc;
                return(false);
            }
        }
Exemplo n.º 3
0
        public bool VerifyOrEditVenue(VenueEditWebModel venueEdit)
        {
            var athlete = new UserProfileLogic(db).GetAthleteForUserName(User.Identity.Name);
            var venue   = db.Venues.Single(i => i.VenueID == venueEdit.VenueID);

            string backup = string.Format("{0}|||||{1}|||||{2}|||||{3}|||||{4}|||||{5}|||||{6}",
                                          venue.PhoneNumber ?? "", venue.Website ?? "", venue.Address ?? "", venue.PoiID ?? "", venue.NumberOf10fSnookerTables ?? -1, venue.NumberOf12fSnookerTables ?? -1, venue.IsInvalid);

            bool isEdited = false;

            if (venueEdit.NumberOf10fSnookerTables != null && venue.NumberOf10fSnookerTables != venueEdit.NumberOf10fSnookerTables)
            {
                isEdited = true;
                venue.NumberOf10fSnookerTables = venueEdit.NumberOf10fSnookerTables;
            }
            if (venueEdit.NumberOf12fSnookerTables != null && venue.NumberOf12fSnookerTables != venueEdit.NumberOf12fSnookerTables)
            {
                isEdited = true;
                venue.NumberOf12fSnookerTables = venueEdit.NumberOf12fSnookerTables;
            }
            if (venueEdit.HasAddress != venue.HasAddress)
            {
                isEdited      = true;
                venue.Address = venueEdit.Address;
            }
            if (venueEdit.HasWebsite != venue.HasWebsite)
            {
                isEdited      = true;
                venue.Website = venueEdit.Website;
            }
            if (venueEdit.HasPhoneNumber != venue.HasPhoneNumber)
            {
                isEdited          = true;
                venue.PhoneNumber = venueEdit.PhoneNumber;
            }
            if (venueEdit.HasPoiID != venue.HasPOIid)
            {
                isEdited    = true;
                venue.PoiID = venueEdit.PoiID;
            }
            if (venueEdit.IsInvalid != venue.IsInvalid)
            {
                isEdited        = true;
                venue.IsInvalid = venueEdit.IsInvalid;
            }

            VenueEditTypeEnum type = VenueEditTypeEnum.ConfirmOnly;

            if (isEdited)
            {
                type = VenueEditTypeEnum.EditedMeta;
            }

            VenueEdit edit = new VenueEdit()
            {
                AthleteID = athlete.AthleteID,
                VenueID   = venue.VenueID,
                Time      = DateTime.UtcNow,
                Type      = (int)type,
                Backup    = backup
            };

            db.VenueEdits.Add(edit);
            db.SaveChanges();

            return(true);
        }