public CreateOpponentAdvertStep2(CreateOpponentAdvertViewModel model)
 {
     InitializeComponent();
     mainModel                  = model;
     datePickerDate.Date        = DateTime.Now;
     datePickerDate.Format      = "dd/MM/yyyy dddd";
     datePickerDate.MinimumDate = DateTime.Today;
     datePickerDate.MaximumDate = DateTime.Today.AddDays(90);
 }
        public async Task <CreateOpponentAdvertViewModel> CreateOpponentAdvert(CreateOpponentAdvertViewModel model)
        {
            User currentUser = new User();

            if (App.Current.Properties.ContainsKey("loggedUser"))
            {
                currentUser = App.Current.Properties["loggedUser"] as User;
                TeamPlayer teamPlayer = App.Current.Properties["loggedUserTeamPlayer"] as TeamPlayer;
                model.OwnerId = currentUser.Id;
                model.teamId  = teamPlayer.TeamId;
                try
                {
                    using (var client = new HttpClient())
                    {
                        model.OwnerId      = currentUser.Id;
                        client.BaseAddress = new Uri("http://www.harbisaha.com/");
                        client.DefaultRequestHeaders.Accept.Clear();
                        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                        var                 uri = new Uri("http://www.harbisaha.com/api/OpponentAdvert/CreateOpponentAdvert");
                        string              serializedObject = JsonConvert.SerializeObject(model);
                        HttpContent         contentPost      = new StringContent(serializedObject, Encoding.UTF8, "application/json");
                        HttpResponseMessage response         = await client.PostAsync(uri, contentPost);

                        if (response.IsSuccessStatusCode)
                        {
                            var data = await response.Content.ReadAsStringAsync();

                            CreateOpponentAdvertViewModel modelToReturn = JsonConvert.DeserializeObject <CreateOpponentAdvertViewModel>(data);
                            return(modelToReturn);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
            else
            {
                return(null);
            }
        }
Beispiel #3
0
        private async void BtnForward_Clicked(object sender, EventArgs e)
        {
            info = editorAdvertInfos.Text;
            mainModel.AdvertInfos = info;
            //MessagingCenter.Send(this, "MainCreatingOpponentAdvertPage", info);
            //await DisplayAlert("HERE", "Buradayız", "OK");
            await Navigation.PushPopupAsync(new AnimationPages.AnimationPopUpPage1_Waiting("Oluşturuluyor..."));

            CreateOpponentAdvertViewModel _model = await service.CreateOpponentAdvert(mainModel);

            if (_model != null)
            {
                await Navigation.PopPopupAsync();
                await DisplayAlert("BAŞARILI", "Rakip Arama İlanınız Oluşturuldu", "OK");

                App.Current.MainPage = new NavigationPage(new IndexPageMain());
            }
            else
            {
                await Navigation.PopPopupAsync();
                await DisplayAlert("HATA", "Bir sorun oluştu", "OK");
            }
        }
Beispiel #4
0
 public CreateOpponentAdvertStep3(CreateOpponentAdvertViewModel model)
 {
     InitializeComponent();
     mainModel = model;
 }