protected async void BookNow(DetailModel model) { DatabaseReference database = FirebaseDatabase.Instance.Reference; var stringEndPoint = database.Child("Booked").Push().Key; var stringpath = database.Child("Booked").Child(stringEndPoint); stringpath.Child("cust_id").SetValue(FirebaseAuth.Instance.CurrentUser.Uid); stringpath.Child("date").SetValue(model.availabledate); stringpath.Child("emp_id").SetValue(model.emp_id); stringpath.Child("id").SetValue(stringEndPoint); stringpath.Child("time").SetValue(model.availabletime); stringpath.Child("availableslotid").SetValue(model.availableslotid); stringpath.Child("cust_name").SetValue(model.cuse_name); stringpath.Child("book_status").SetValue("pending"); var pathForEmplBook = database.Child("employee").Child(model.emp_id).Child("avaibility").Child(model.availableslotid); pathForEmplBook.Child("status").SetValue("false"); Toast.MakeText(Activity, "Booking Success!!", ToastLength.Short).Show(); ((DashboardActivity)Activity).moveToCalander(); }
public override void OnViewCreated(View view, Bundle savedInstanceState) { base.OnViewCreated(view, savedInstanceState); //toolbar Android.Support.V7.Widget.Toolbar toolbar = (Android.Support.V7.Widget.Toolbar)((DashboardActivity)Activity).FindViewById(Resource.Id.toolbar); TextView mTitle = (TextView)toolbar.FindViewById(Resource.Id.toolbar_title); if (mTitle != null) { mTitle.Text = "Booking"; } detailModel = (FirebaseAppDemo.DetailModel)Arguments.GetSerializable("time"); lnrSummary = (Android.Widget.LinearLayout)view.FindViewById(Resource.Id.lnrSummary); txtSummary = (Android.Widget.TextView)view.FindViewById(Resource.Id.txt_summary_booking); onItemClick = this; onInit(view, detailModel); txtSummary.Click += delegate { OnItemClick(arrayListBooking[0].emp_id); }; }
private void getEmployeeData(DetailModel detailModel) { //var user = FirebaseAuth.Instance.CurrentUser; DatabaseReference database = FirebaseDatabase.Instance.Reference; Query query = database.Child("employee"); query.AddListenerForSingleValueEvent(this); }
public void OnDataChange(DataSnapshot snapshot) { if (snapshot.Exists()) { arrayListReservation.Clear(); var obj = snapshot.Children; int complete = 0; int pending = 0; int cancel = 0; foreach (DataSnapshot snapshotChild in obj.ToEnumerable()) { if (snapshotChild.GetValue(true) == null) { continue; } DetailModel model = new DetailModel(); model.emp_id = snapshotChild.Child("emp_id")?.GetValue(true)?.ToString(); model.bookstatus = snapshotChild.Child("book_status")?.GetValue(true)?.ToString(); model.worktime = snapshotChild.Child("date")?.GetValue(true)?.ToString(); model.cuse_name = snapshotChild.Child("cust_name")?.GetValue(true)?.ToString(); if (model.bookstatus.Equals("complete")) { complete++; } else if (model.bookstatus.Equals("pending")) { pending++; } else if (model.bookstatus.Equals("cancel")) { cancel++; } arrayListReservation.Add(model); } setCustomTabs(complete, pending, cancel); reservationAdapter.NotifyDataSetChanged(); } }
public void moveToEmployeeDetail(DetailModel model) { Bundle utilBundle = new Bundle(); utilBundle.PutSerializable("time", model); Android.Support.V4.App.Fragment fragment = new EmployeeList(); if (fragment != null) { SupportFragmentManager.BeginTransaction() .Replace(Resource.Id.content_frame, fragment) .AddToBackStack(null) .Commit(); fragment.Arguments = utilBundle; } }
public void moveToSummary(DetailModel model) { Android.Support.V4.App.Fragment fragment = new SummaryFragment(); Bundle utilBundle = new Bundle(); utilBundle.PutSerializable("SomeTag", (Java.IO.ISerializable)model); if (fragment != null) { SupportFragmentManager.BeginTransaction() .Replace(Resource.Id.content_frame, fragment) .AddToBackStack(null) .Commit(); fragment.Arguments = utilBundle; } }
private void onInit(View view, DetailModel model) { txtHeaderTime = (TextView)view.FindViewById(Resource.Id.txt_header_time); txtEmpName = (TextView)view.FindViewById(Resource.Id.txt_employee_name_summary); txtEmpLocation = (TextView)view.FindViewById(Resource.Id.txt_employee_location_summary); txtWorkingTime = (TextView)view.FindViewById(Resource.Id.txt_working_time); txtCustomerName = (TextView)view.FindViewById(Resource.Id.txt_customer_name); txtEmail = (TextView)view.FindViewById(Resource.Id.txt_email); txtMobile = (TextView)view.FindViewById(Resource.Id.txt_mobile); txtWorkingLocation = (TextView)view.FindViewById(Resource.Id.txt_working_location); txtNetPrice = (TextView)view.FindViewById(Resource.Id.txt_net_price); txtVat = (TextView)view.FindViewById(Resource.Id.txt_vat); txtTotal = (TextView)view.FindViewById(Resource.Id.txt_total); txtBookNow = (TextView)view.FindViewById(Resource.Id.txt_book_now); txtBookNow.Click += delegate { BookNow(model); }; txtEmpName.Text = model.name; txtHeaderTime.Text = model.worktime; txtEmpLocation.Text = model.distance; txtWorkingTime.Text = model.availabletime; txtCustomerName.Text = model.cuse_name; txtEmail.Text = model.email; txtMobile.Text = model.mobile; txtWorkingLocation.Text = model.location; txtNetPrice.Text = model.net_price; txtVat.Text = model.vat; txtTotal.Text = ("250 EURO"); var dateToGet = new DateTime(int.Parse(model.availabledate.Substring(6)), int.Parse(model.availabledate.Substring(3, 2)), int.Parse(model.availabledate.Substring(0, 2)), int.Parse(model.availabletime), 0, 0); var format = "MMMM dd, hh:mm"; var dtString = dateToGet.ToString(format); txtHeaderTime.Text = dtString; }
public override void OnViewCreated(View view, Bundle savedInstanceState) { base.OnViewCreated(view, savedInstanceState); //toolbar Android.Support.V7.Widget.Toolbar toolbar = (Android.Support.V7.Widget.Toolbar)((DashboardActivity)Activity).FindViewById(Resource.Id.toolbar); TextView mTitle = (TextView)toolbar.FindViewById(Resource.Id.toolbar_title); if (mTitle != null) { mTitle.Text = "Summary"; } DetailModel detailModel = (FirebaseAppDemo.DetailModel)Arguments.GetSerializable("SomeTag"); if (detailModel != null) { onInit(view, detailModel); } }
private void onInit(View view, DetailModel detailModel) { recyclerView = (RecyclerView)view.FindViewById(Resource.Id.recycler_view); txtTimeBooking = view.FindViewById <TextView>(Resource.Id.txt_time_booking); var dateToGet = new DateTime(int.Parse(detailModel.availabledate.Substring(6)), int.Parse(detailModel.availabledate.Substring(3, 2)), int.Parse(detailModel.availabledate.Substring(0, 2)), int.Parse(detailModel.availabletime), 0, 0); var format = "MMMM dd, hh:mm"; var dtString = dateToGet.ToString(format); txtTimeBooking.Text = dtString; arrayListBooking = new List <DetailModel>(); bookingAdapter = new BookingRecyclerViewAdapter(Activity, arrayListBooking, recyclerView, (FirebaseAppDemo.DashboardActivity)Activity, onItemClick); RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(Activity); recyclerView.SetLayoutManager(mLayoutManager); recyclerView.SetAdapter(bookingAdapter); getEmployeeData(detailModel); }
public void OnDataChange(DataSnapshot snapshot) { DetailModel model = new DetailModel(); model.time = time; model.status = "Available"; model.location = snapshot.Child("distance")?.GetValue(true)?.ToString(); model.money = snapshot.Child("net_price")?.GetValue(true)?.ToString(); for (int i = 0; i < list.Count(); i++) { if (list[i].time.Equals(time)) { list[i] = model; break; } } adapter.NotifyDataSetChanged(); }
public void OnDataChange(DataSnapshot snapshot) { if (snapshot.Exists()) { arrayListBooking.Clear(); var obj = snapshot.Children; foreach (DataSnapshot snapshotChild in obj.ToEnumerable()) { if (snapshotChild.GetValue(true) == null) { continue; } DetailModel model = new DetailModel(); model.cuse_name = snapshotChild.Child("cust_name")?.GetValue(true)?.ToString(); model.distance = snapshotChild.Child("distance")?.GetValue(true)?.ToString(); model.email = snapshotChild.Child("email")?.GetValue(true)?.ToString(); model.id = snapshotChild.Child("id")?.GetValue(true)?.ToString(); model.location = snapshotChild.Child("location")?.GetValue(true)?.ToString(); model.mobile = snapshotChild.Child("mobile")?.GetValue(true)?.ToString(); model.name = snapshotChild.Child("name")?.GetValue(true)?.ToString(); model.net_price = snapshotChild.Child("net_price")?.GetValue(true)?.ToString(); model.pic = snapshotChild.Child("pic")?.GetValue(true)?.ToString(); model.status = snapshotChild.Child("status")?.GetValue(true)?.ToString(); model.vat = snapshotChild.Child("vat")?.GetValue(true)?.ToString(); model.worktime = snapshotChild.Child("worktime")?.GetValue(true)?.ToString(); model.emp_id = snapshotChild.Child("emp_id")?.GetValue(true)?.ToString(); var data = snapshotChild.Child("avaibility").Value; //model.availabletime = snapshotChild.Child("availabletime")?.GetValue(true)?.ToString(); //model.availabledate = snapshotChild.Child("availabledate")?.GetValue(true)?.ToString(); model.showtime = detailModel.availabletime; string output = JsonConvert.SerializeObject(data); var arraycombination = Newtonsoft.Json.JsonConvert.DeserializeObject <List <AvailablityModelClass> >(output); model.availableslotList = arraycombination; for (int i = 0; i < model.availableslotList.Count; i++) { if (model.availableslotList[i].availabletime.Equals(detailModel.availabletime) && detailModel.availabledate.Equals(model.availableslotList[i].availabledate) && model.availableslotList[i].status.Equals("true")) { model.time = model.availableslotList[i].availabletime; model.availabledate = model.availableslotList[i].availabledate; model.availabletime = model.availableslotList[i].availabletime; model.status = model.availableslotList[i].status; model.availableslotid = model.availableslotList[i].id; arrayListBooking.Add(model); break; } } } if (arrayListBooking.Count == 1) { lnrSummary.Visibility = ViewStates.Visible; } else { lnrSummary.Visibility = ViewStates.Gone; } if (bookingAdapter != null) { bookingAdapter.NotifyDataSetChanged(); } } }
public void OnDataChange(DataSnapshot snapshot) { if (snapshot.Exists()) { arrayList.Clear(); string date = currentDate; for (int i = 9; i < 15; i++) { DetailModel model = new DetailModel(); model.time = i.ToString(); model.showtime = "Not Available"; model.location = ""; model.money = ""; model.date = date; arrayList.Add(model); } var obj = snapshot.Children; List <DetailModel> arrayListTemp = new List <DetailModel>(); for (int i = 0; i < arrayList.Count; i++) { arrayListTemp.Add(arrayList[i]); } foreach (DataSnapshot snapshotChild in obj.ToEnumerable()) { if (snapshotChild.GetValue(true) == null) { continue; } DetailModel model = new DetailModel(); model.showtime = "Available"; model.location = snapshotChild.Child("distance")?.GetValue(true)?.ToString(); model.money = snapshotChild.Child("net_price")?.GetValue(true)?.ToString(); model.emp_id = snapshotChild.Child("emp_id")?.GetValue(true)?.ToString(); var data = snapshotChild.Child("avaibility").Value; string output = JsonConvert.SerializeObject(data); var arraycombination = Newtonsoft.Json.JsonConvert.DeserializeObject <List <AvailablityModelClass> >(output); model.availableslotList = arraycombination; for (int i = 0; i < model.availableslotList.Count; i++) { for (int j = 0; j < arrayList.Count(); j++) { if (arrayList[j].time.Equals(model.availableslotList[i].availabletime) && date.Equals(model.availableslotList[i].availabledate) && model.availableslotList[i].status.Equals("true")) { model.time = model.availableslotList[i].availabletime; model.availabledate = model.availableslotList[i].availabledate; model.availabletime = model.availableslotList[i].availabletime; model.status = model.availableslotList[i].status; arrayListTemp[j] = model; break; } } } } arrayList.Clear(); arrayList = arrayListTemp; try { recyclerAdapter = new RecyclerViewAdapter(Activity, arrayList, recyclerView, (FirebaseAppDemo.DashboardActivity)Activity); recyclerView.SetAdapter(recyclerAdapter); } catch (Exception e) { } recyclerAdapter.NotifyDataSetChanged(); } else { arrayList.Clear(); for (int i = 9; i < 15; i++) { DetailModel model = new DetailModel(); model.time = i.ToString(); model.status = "Not Available"; model.location = ""; model.money = ""; arrayList.Add(model); } recyclerAdapter.NotifyDataSetChanged(); } if (progressBar != null) { progressBar.Visibility = ViewStates.Gone; } }