public async void GetDiscount() { // lay du lieu tu db myAPI = RestService.For <IMyAPI>("https://goldenspa.azurewebsites.net"); var result = await myAPI.GetListPromotion(); mAdapterDiscount = new Home_Discount_Customer_Adapter(result); mRecyclerViewDiscount.SetAdapter(mAdapterDiscount); mAdapterDiscount.ItemClick += (s, e) => { var intent = new Intent(Activity, typeof(Customer.activity_Service_Customer)); intent.PutExtra("ServiceId", result[e].MaDV); intent.PutExtra("ServiceName", result[e].NameService); intent.PutExtra("PromotionName", result[e].NamePromotion); intent.PutExtra("Index", e.ToString()); StartActivity(intent); //int photoNum = e + 1; //Toast.MakeText(Context, "This is photo number " + photoNum, ToastLength.Short).Show(); }; }
private async void getRelativeDiscount() { myAPI = RestService.For <IMyAPI>("https://goldenspa.azurewebsites.net"); var result = await myAPI.GetListPromotion(); mRelativeDiscount_List = new List <ListPromotion>(result.Count); int max = 5; if (result.Count <= max) { for (int i = 0; i < max; i++) { if (i != Int32.Parse(Intent.GetStringExtra("Index"))) { var DataSample_Services_Outlet_ViewModel = new ListPromotion(); DataSample_Services_Outlet_ViewModel.MaDV = result[i].MaDV; DataSample_Services_Outlet_ViewModel.Image = result[i].Image; DataSample_Services_Outlet_ViewModel.NameService = result[i].NameService; DataSample_Services_Outlet_ViewModel.price = result[i].price; DataSample_Services_Outlet_ViewModel.Discount = result[i].Discount; DataSample_Services_Outlet_ViewModel.TotalOutlets = result[i].TotalOutlets; mRelativeDiscount_List.Add(DataSample_Services_Outlet_ViewModel); } } } else { for (int i = 0; i < max; i++) { if (i != Int32.Parse(Intent.GetStringExtra("Index"))) { var DataSample_Services_Outlet_ViewModel = new ListPromotion(); DataSample_Services_Outlet_ViewModel.MaDV = result[i].MaDV; DataSample_Services_Outlet_ViewModel.Image = result[i].Image; DataSample_Services_Outlet_ViewModel.NameService = result[i].NameService; DataSample_Services_Outlet_ViewModel.price = result[i].price; DataSample_Services_Outlet_ViewModel.Discount = result[i].Discount; DataSample_Services_Outlet_ViewModel.TotalOutlets = result[i].TotalOutlets; mRelativeDiscount_List.Add(DataSample_Services_Outlet_ViewModel); } else { max++; } } } mAdapterRelativeDiscount = new Service_RelativeDiscount_Customer_Adapter(mRelativeDiscount_List); mRecyclerViewRelativeDiscount.SetAdapter(mAdapterRelativeDiscount); mAdapterRelativeDiscount.ItemClick += (s, e) => { Finish(); var intent = new Intent(this, typeof(Customer.activity_Service_Customer)); intent.PutExtra("ServiceId", mRelativeDiscount_List[e].MaDV); intent.PutExtra("ServiceName", mRelativeDiscount_List[e].NameService); intent.PutExtra("PromotionName", mRelativeDiscount_List[e].NamePromotion); intent.PutExtra("Index", e.ToString()); StartActivity(intent); }; }