public FoodObject1() { DatabaseL db = new DatabaseL(); var query = db.selectallFood(); var query1 = query.Where(x => x.mCatID == 2); fud = query1.ToArray(); //this.photos = listPhoto; random = new Random(); }
public FoodObject() { try { DatabaseL db = new DatabaseL(); var query = db.selectallFood(); var query1 = query.Where(x => x.mCatID == 1); fud = query1.ToArray(); //this.photos = listPhoto; random = new Random(); } catch (Exception ex) { } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_food_detail); food_name = FindViewById <TextView>(Resource.Id.food_name); food_price = FindViewById <TextView>(Resource.Id.food_price); food_description = FindViewById <TextView>(Resource.Id.food_description); food_image = FindViewById <ImageView>(Resource.Id.img_food); collapsingToolbarLayout = FindViewById <CollapsingToolbarLayout>(Resource.Id.collapsing); btnCart = FindViewById <FloatingActionButton>(Resource.Id.btnCart); numberButton = FindViewById <Button>(Resource.Id.number_button); Food_name = Intent.GetStringExtra("foodName").Trim(); collapsingToolbarLayout.SetExpandedTitleTextAppearance(Resource.Style.ExpandedAppbar); collapsingToolbarLayout.SetExpandedTitleTextAppearance(Resource.Style.CollapsedAppbar); int foodid; bool res = int.TryParse(Food_name, out foodid); var data = db.selectallFood(); //Call Table var data1 = data.Where(x => x.mFid == foodid).FirstOrDefault(); //Linq Query food_name.Text = data1.mCaption; food_price.Text = data1.mPrice.ToString(); food_description.Text = data1.mDescription; food_image.SetImageResource(data1.mPhotoID); //Cart button btnCart.Click += delegate { ISharedPreferences pref = Application.Context.GetSharedPreferences("UserInfo", FileCreationMode.Private); string userName = pref.GetString("Usermail", String.Empty); try { var query = db.selectallUser(); var query1 = query.Where(x => x.Email == userName).FirstOrDefault(); Intent cartIntent = new Intent(this, typeof(Cart)); cartIntent.PutExtra("usrID", query1.Uid.ToString()); this.StartActivity(cartIntent); } catch (Exception ex) { Toast.MakeText(Application.Context, ex.ToString(), ToastLength.Short).Show(); } }; // Add item button numberButton.Click += delegate { ISharedPreferences pref = Application.Context.GetSharedPreferences("UserInfo", FileCreationMode.Private); string userName = pref.GetString("Usermail", String.Empty); try { var query = db.selectallUser(); var query1 = query.Where(x => x.Email == userName).FirstOrDefault(); UserCart cart = new UserCart() { fdID = foodid, usrID = query1.Uid }; db.insertUserCart(cart); Toast.MakeText(Application.Context, data1.mCaption + " added to cart!", ToastLength.Short).Show(); } catch (Exception ex) { Toast.MakeText(Application.Context, ex.ToString(), ToastLength.Short).Show(); } }; }