Exemplo n.º 1
0
        private async void init()
        {
            session_management = new Session_management(this.ApplicationContext);
            progressDialog     = new ProgressDialog(this);
            progressDialog.SetMessage("Loading...");
            progressDialog.SetCancelable(false);

            sessionManagement = new Session_management(this);
            sessionManagement.cleardatetime();

            dname              = Intent.GetStringExtra("dName");
            addressid          = Intent.GetStringExtra("dId");
            btn_AddAddress     = (Button)FindViewById(Resource.Id.btn_AddAddress);
            txtTotalItems      = (TextView)FindViewById(Resource.Id.txtTotalItems);
            btn_Contine        = (TextView)FindViewById(Resource.Id.btn_Contine);
            recycler_itemsList = (RecyclerView)FindViewById(Resource.Id.recycler_itemsList);
            //recyclerTimeSlot = (RecyclerView)FindViewById(Resource.Id.recyclerTimeSlot);
            pPrice         = (TextView)FindViewById(Resource.Id.pPrice);
            pMrp           = (TextView)FindViewById(Resource.Id.pMrp);
            totalItms      = (TextView)FindViewById(Resource.Id.totalItms);
            price          = (TextView)FindViewById(Resource.Id.price);
            DeliveryCharge = (TextView)FindViewById(Resource.Id.DeliveryCharge);
            Amounttotal    = (TextView)FindViewById(Resource.Id.Amounttotal);
            txt_totalPrice = (TextView)FindViewById(Resource.Id.txt_totalPrice);
            back           = (LinearLayout)FindViewById(Resource.Id.back);



            back.Click += delegate
            {
                Finish();
            };

            btn_AddAddress.Click += delegate
            {
                Intent In = new Intent(ApplicationContext, typeof(Add_address));
                StartActivity(In);
            };


            SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
            var  startDate          = DateTime.Now.AddMonths(-1);
            Date sdate = format.Parse(startDate.Date.ToShortDateString());

            var  endDate = DateTime.Now.AddMonths(1);
            Date edate   = format.Parse(endDate.Date.ToShortDateString());

            string todaydate = sdate.ToString();

            dateDayModelClasses1 = new List <timing_model>();
            //horizontalCalendar = FindViewById<HorizontalCalendar>(Resource.Id.calendarView1);
            //horizontalCalendar = new HorizontalCalendar.Builder(this, Resource.Id.calendarView1)
            //    .StartDate(sdate)
            //    .EndDate(edate)
            //    .DatesNumberOnScreen(5)
            //    .MonthFormat("MMM")
            //    .DayNameFormat("dd")
            //    .DayNumberFormat("EEE")
            //    .TextSize(11f, 20f, 12f)
            //    .TextColor(Color.Gray, Color.Black)
            //    .Build();
            //horizontalCalendarListner = new OnDateSelected(DateSelected);
            sessionManagement = new Session_management(this);
            var UserId         = Convert.ToInt32(sessionManagement.getUserDetails().Get(BaseURL.KEY_ID).ToString());
            var getCheckoutURL = new System.Uri(BaseURL.GetCheckoutList + UserId);

            CheckoutList = new List <ProcessCheckout>();

            using (var client = new HttpClient())
            {
                var checkoutData = await client.GetStringAsync(getCheckoutURL);

                CheckoutList = JsonConvert.DeserializeObject <List <ProcessCheckout> >(checkoutData);
                var deliverycharges = CheckoutList.Select(x => x.ShippingCharges).Sum();
                DeliveryCharge.Text = deliverycharges.ToString();
                totalprice          = DeliveryCharge.Text.ToString() + price.Text.ToString();
                Amounttotal.Text    = totalprice;
            }

            updateData();
            btn_Contine.Click += Btn_Contine_Click;
        }
Exemplo n.º 2
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container,
                                          Bundle savedInstanceState)
        {
            // Inflate the layout for this fragment
            View view = inflater.Inflate(Resource.Layout.fragment_cart, container, false);

            recyclerView = (RecyclerView)view.FindViewById(Resource.Id.recyclerCart);
            btn_ShopNOw  = (Button)view.FindViewById(Resource.Id.btn_ShopNOw);
            viewCart     = (RelativeLayout)view.FindViewById(Resource.Id.viewCartItems);
            tv_total     = (TextView)view.FindViewById(Resource.Id.txt_totalamount);
            totalItems   = (TextView)view.FindViewById(Resource.Id.txt_totalQuan);
            noData       = (RelativeLayout)view.FindViewById(Resource.Id.noData);
            ((MainActivity)this.Activity).Title = (GetString(Resource.String.cart));
            sessionManagement = new Session_management(Activity);
            sessionManagement.cleardatetime();

            ll_Checkout = (LinearLayout)view.FindViewById(Resource.Id.ll_Checkout);
            getCartData();

            btn_ShopNOw.Click += delegate
            {
                Intent intent = new Intent(Activity, typeof(MainActivity));
                StartActivity(intent);
            };

            ll_Checkout.Click += async delegate
            {
                if (isOnline())
                {
                    if (sessionManagement.isLoggedIn())
                    {
                        if (StoreCartData.Count == 0)
                        {
                            noData.Visibility   = ViewStates.Visible;
                            viewCart.Visibility = ViewStates.Gone;
                        }
                        else
                        {
                            progressDialog = new Android.App.ProgressDialog(this.Context);
                            progressDialog.Indeterminate = true;
                            progressDialog.SetProgressStyle(ProgressDialogStyle.Spinner);
                            progressDialog.SetMessage("Loading...");
                            progressDialog.SetCancelable(false);
                            progressDialog.Show();
                            int UserId = 0;
                            if (sessionManagement.isLoggedIn())
                            {
                                UserId = Convert.ToInt32(sessionManagement.getUserDetails().Get(BaseURL.KEY_ID).ToString());
                            }
                            var processCheckout = BaseURL.ProcessToCheckout + UserId;

                            using (var client = new HttpClient())
                            {
                                StringContent content  = new StringContent("");
                                var           response = await client.PostAsync(processCheckout, content);

                                if (response.StatusCode == HttpStatusCode.OK)
                                {
                                    Intent intent = new Intent(this.Activity, typeof(OrderSummary));
                                    StartActivity(intent);
                                }
                            }
                        }
                    }
                    else
                    {
                        if (StoreCartData.Count == 0)
                        {
                            noData.Visibility   = ViewStates.Visible;
                            viewCart.Visibility = ViewStates.Gone;
                        }
                        else
                        {
                            Intent intent = new Intent(this.Activity, typeof(OrderSummary));
                            StartActivity(intent);
                        }
                    }
                }
                ;
            };

            recyclerView.SetLayoutManager(new LinearLayoutManager(Activity));

            updateData();


            return(view);
        }