예제 #1
0
        private async Task CreateASeasonAsync()
        {
            var json = JsonConvert.SerializeObject(SelectedSezoni);
            var g    = json.Remove(1, 7);

            App.client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json");
            HttpContent httpContent = new StringContent(g, Encoding.UTF8, "application/json");
            var         response    = await App.client.PostAsync(App.API_URL_BASE + "payments/sezonet", httpContent);

            if (response.IsSuccessStatusCode)
            {
                UserDialogs.Instance.Alert("Sezoni u shtua me sukses", "Sukses", "OK");
            }
            else
            {
                UserDialogs.Instance.Alert("Sezoni nuk u shtua me sukses", "Error", "OK");
            }
            var responseString = await response.Content.ReadAsStringAsync();

            Sezonet addedSeason = JsonConvert.DeserializeObject <Sezonet>(responseString);

            Sezonet.Add(addedSeason);
            HasSezone = Sezonet.Any();
            OnPropertyChanged("HasSezone");
        }
예제 #2
0
        private async Task GeneratePdfSeasonAsync()
        {
            using (UserDialogs.Instance.Loading("Loading"))
            {
                DateTime reuqestedDate  = DateTime.Now;
                var      selectedSeason = Sezonet.FirstOrDefault(x => x.Emri == SelectedSezoni.Emri);
                var      json           = JsonConvert.SerializeObject(selectedSeason);
                App.client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json");
                HttpContent httpContent = new StringContent(json, Encoding.UTF8, "application/json");
                var         response    = await App.client.PostAsync(App.API_URL_BASE + "rentedcars/pdf/season", httpContent);

                if (response.StatusCode != System.Net.HttpStatusCode.OK)
                {
                    UserDialogs.Instance.Alert("Probleme me server, Provoni Perseri", "Error", "Ok");
                }
                else
                {
                    var responseString = await response.Content.ReadAsStringAsync();

                    var pdfcontent = JsonConvert.DeserializeObject <byte[]>(responseString);
                    using (MemoryStream ms = new MemoryStream(pdfcontent))
                    {
                        //await Xamarin.Forms.DependencyService.Get<ISave>().SaveAndView("Output.pdf", "application/pdf", ms);
                    }
                    DependencyService.Get <IFileLauncher>().Open(pdfcontent, selectedSeason.Emri + "-" + selectedSeason.id + "-.pdf");
                }
            }
        }
예제 #3
0
        private async Task <ObservableCollection <Sezonet> > GetSezonet()
        {
            try
            {
                var response = await App.client.GetAsync(App.API_URL_BASE + "payments/sezonet");

                if (response.StatusCode != System.Net.HttpStatusCode.OK)
                {
                    UserDialogs.Instance.Alert("Probleme me server, Provoni Perseri", "Error", "Ok");
                    return(null);
                }
                else
                {
                    var responseString = await response.Content.ReadAsStringAsync();

                    var sezonet = JsonConvert.DeserializeObject <ObservableCollection <Sezonet> >(responseString);
                    Sezonet   = sezonet;
                    HasSezone = Sezonet.Any();
                    return(Sezonet);
                }
            }
            catch (Exception e)
            {
                return(null);
            }
        }
예제 #4
0
 public PaymentsViewModel()
 {
     GoToCmimetCommand             = new Command(async() => await GoToCmimetAsync());
     GoToTarifatCommand            = new Command(async() => await GoToTarifatAsync());
     GoToZbritjetCommand           = new Command(async() => await GoToZbritjetAsync());
     GoToSezonetCommand            = new Command(async() => await GoToSezonetAsync());
     AddASeasonCommand             = new Command(async() => await CreateASeasonAsync());
     AddACmimCommand               = new Command(async() => await CreateACmimAsync());
     GoToCreateCmimeCommand        = new Command(async() => await GoToCreateCmimetAsync());
     GoToCreateSeazonCommand       = new Command(async() => await GoToCreateSeazonAsync());
     GoToPersonalizedReportCommand = new Command(async() => await GoToPersonalizedReportAsync());
     GeneratePdfWithFilterCommand  = new Command(async() => await GeneratePdfWithFilterAsync());
     GeneratePdfWeeklyCommand      = new Command(async() => await GeneratePdfWeekly());
     GeneratePdfDailyCommand       = new Command(async() => await GeneratePdfDailyAsync());
     GeneratePdfMonthlyCommand     = new Command(async() => await GeneratePdfMonthlyAsync());
     GoToDailyRaportsCommand       = new Command(async(c) => await GoToDailyRaportsAsync(c.ToString()));
     GeneratePdfSeasonCommand      = new Command(async() => await GeneratePdfSeasonAsync());
     SelectedSezoni = new Sezonet();
     SelectedCmimi  = new Cmimet();
     Sezonet        = new ObservableCollection <Sezonet>();
     Cmimet         = new ObservableCollection <Cmimet>();
     DailyRaports   = DateTime.Now;
 }