protected async override void OnCreate(Bundle bundle)
        {
            try
            {
                base.OnCreate(bundle);
                SetContentView(Resource.Layout.MakeBookingSesh);

                ActionBar.SetHomeButtonEnabled(true);
                ActionBar.SetDisplayHomeAsUpEnabled(true);

                //progressDialog = ProgressDialog.Show(this, "", "Loading...");

                string WorkshopSetId = Intent.GetStringExtra("WorkshopSetId");
                _WorkshopSessions = await RESTClass.GetWorkshopSessions("?workshopSetId=" + WorkshopSetId);

                CreateExpendableListData();

                ExpandableListView elvExListBox = FindViewById <ExpandableListView> (Resource.Id.elvExListBox);
                elvExListBox.SetAdapter(new ExpandListSessionAdapter(this, dictGroup));

                elvExListBox.ChildClick += delegate(object sender, ExpandableListView.ChildClickEventArgs e) {
                    string           itmGroup = lstKeys [e.GroupPosition];
                    WorkshopSessions itmChild = dictGroup [itmGroup];
                };

                elvExListBox.GroupExpand += delegate(object sender, ExpandableListView.GroupExpandEventArgs e) {
                    if (lastExpandedPosition != -1 && e.GroupPosition != lastExpandedPosition)
                    {
                        elvExListBox.CollapseGroup(lastExpandedPosition);
                    }

                    lastExpandedPosition = e.GroupPosition;
                };

                //				Button btnViewDetails = FindViewById<Button>(Resource.Id.btnViewDetails);
                //				btnViewDetails.Click += delegate {
                //					StartActivity(new Intent(this, typeof(MakeBookingListActivity)));
                //				};
            }
            catch (Exception e)
            {
                ErrorHandling.LogError(e, this);
            }
            finally
            {
                //				progressDialog.Dismiss();
                //				progressDialog.Dispose ();
            }
        }
Exemple #2
0
//		Dictionary<string, WorkshopBooking> dictGroupCurr = new Dictionary<string, WorkshopBooking> ();
//		Dictionary<string, WorkshopBooking> dictGroupPast = new Dictionary<string, WorkshopBooking> ();
//		List<string> lstKeysCurr = new List<string> ();
//		List<string> lstKeysPast = new List<string> ();

        protected override async void OnCreate(Bundle bundle)
        {
            try
            {
                base.OnCreate(bundle);
                SetContentView(Resource.Layout.TabsLayout);

                ActionBar.SetHomeButtonEnabled(true);
                ActionBar.SetDisplayHomeAsUpEnabled(true);

                if (ProgressDialogLogin == null)
                {
                    ProgressDialogLogin = ProgressDialog.Show(this, "", "Loading...");
                }

                Globals.StuBookings = await RESTClass.GetWorkshopBookings(String.Format("?active=true&studentId={0}", Globals.LoggedStudent.studentID));

                FragmentTransaction  transaction = FragmentManager.BeginTransaction();
                ViewBookingsFragment sltFragment = new ViewBookingsFragment();
                transaction.Replace(Resource.Id.flTabs, sltFragment);
                transaction.Commit();

                if (ProgressDialogLogin != null)
                {
                    ProgressDialogLogin.Dismiss();
                    ProgressDialogLogin = null;
                }
            }
            catch (Exception e)
            {
                new AlertDialog.Builder(this)
                .SetMessage(e.Message + "\n" + e.StackTrace)
                .SetTitle("Application Error")
                .Show();
            }
            finally
            {
                if (ProgressDialogLogin != null)
                {
                    ProgressDialogLogin.Dismiss();
                    ProgressDialogLogin = null;
                }
            }
        }
Exemple #3
0
        public async Task <bool> GetWorkshops(Boolean blnOnline = true)
        {
            try
            {
//				if (blnOnline == true)
//				{
                WrkSets = await RESTClass.GetWorkshopList("?active=true");

//				}
//				else
//				{
//					WrkSets = new List<WorkshopSets> {};
//
//					WrkSets.Add(new WorkshopSets(1, "Cannot connect to server... Try again later", "01/02/2015"));
//					WrkSets.Add(new WorkshopSets(2, "Offline WritingSkills", "01/02/2015"));
//					WrkSets.Add(new WorkshopSets(3, "Offline Study + Reading skills", "01/02/2015"));
//					WrkSets.Add(new WorkshopSets(4, "Offline Presentation + Speaking Skills", "01/02/2015"));
//				}

                // create our adapter
                taskList = new Adapters.TaskListAdapter(this, WrkSets);

                //Hook up our adapter to our ListView
                lvWorkShops.Adapter = taskList;

                return(true);
            }
            catch (Exception e)
            {
                new AlertDialog.Builder(this)
                .SetMessage(e.Message + "\n" + e.StackTrace)
                .SetTitle("Application Error")
                .Show();
                return(false);
            }
        }
Exemple #4
0
        public static async Task SaveProfile(Student student)
        {
            WriteToStudentFile(student.studentID);
            KeyValuePair <string, object>[] values = new KeyValuePair <string, object>[] {
                new KeyValuePair <string, object>("StudentId", student.studentID),
                new KeyValuePair <string, object>("DateOfBirth", student.dob),
                new KeyValuePair <string, object>("Gender", student.gender),
                new KeyValuePair <string, object>("Degree", student.degree),
                new KeyValuePair <string, object>("Status", student.status),
                new KeyValuePair <string, object>("FirstLanguage", student.first_language),
                new KeyValuePair <string, object>("CountryOrigin", student.country_origin),
                new KeyValuePair <string, object>("Background", student.background),
                new KeyValuePair <string, object>("DegreeDetails", student.degree_details),
                new KeyValuePair <string, object>("AltContact", student.alternative_contact),
                new KeyValuePair <string, object>("PreferredName", student.preferred_name),
                new KeyValuePair <string, object>("HSC", student.HSC),
                new KeyValuePair <string, object>("HSCMark", student.HSC_mark),
                new KeyValuePair <string, object>("IELTS", student.IELTS),
                new KeyValuePair <string, object>("IELTSMark", student.IELTS_mark),
                new KeyValuePair <string, object>("TOEFL", student.TOEFL),
                new KeyValuePair <string, object>("TOEFLMark", student.TOEFL_mark),
                new KeyValuePair <string, object>("TAFE", student.TAFE),
                new KeyValuePair <string, object>("TAFEMark", student.TAFE_mark),
                new KeyValuePair <string, object>("CULT", student.CULT),
                new KeyValuePair <string, object>("CULTMark", student.CULT_mark),
                new KeyValuePair <string, object>("InsearchDEEP", student.InsearchDEEP),
                new KeyValuePair <string, object>("InsearchDEEPMark", student.InsearchDEEP_mark),
                new KeyValuePair <string, object>("InsearchDiploma", student.InsearchDiploma),
                new KeyValuePair <string, object>("InsearchDiplomaMark", student.InsearchDiploma_mark),
                new KeyValuePair <string, object>("FoundationCourse", student.foundationcourse),
                new KeyValuePair <string, object>("FoundationCourseMark", student.foundationcourse_mark),
                new KeyValuePair <string, object>("CreatorId", student.creatorID)
            };

            await RESTClass.PostStudent(values);
        }
Exemple #5
0
        protected async override void OnCreate(Bundle bundle)
        {
            try
            {
                base.OnCreate(bundle);
                SetContentView(Resource.Layout.Search);
                List <string>       WorkshopList;
                List <WorkshopSets> WrkSets;
                EditText            txtsearch      = FindViewById <EditText>(Resource.Id.txtsearch);
                Spinner             searchWorkshop = FindViewById <Spinner>(Resource.Id.ddpworkshop);
                ExpandableListView  ddpSearchList  = FindViewById <ExpandableListView> (Resource.Id.ddpSearch);
                ImageButton         btnsearch      = FindViewById <ImageButton>(Resource.Id.imgsearch);
                ListView            workshoplist   = FindViewById <ListView>(Resource.Id.lvlWorkShops);
                string search;


                WorkshopList = new List <string>();
                WorkshopList.Add("Session");
                WorkshopList.Add("Workshop");
                WorkshopList.Add("Programs");
                ArrayAdapter <String> adapter = new ArrayAdapter <String>(this, Android.Resource.Layout.SimpleDropDownItem1Line, WorkshopList);
                searchWorkshop.Adapter = adapter;

                btnsearch.Click += async delegate
                {
                    try
                    {
                        search = txtsearch.Text;
                        string searchBy;
                        searchBy = searchWorkshop.SelectedItem.ToString();

                        progressDialog = ProgressDialog.Show(this, "", "Searching...");

                        if (searchBy == "Session")
                        {
                            //string WorkshopSetId = Intent.GetStringExtra(search);
                            _WorkshopSessions = await RESTClass.GetWorkshopSessions("?workshopSetId=" + search);

                            //_WorkshopSessions = await RESTClass.GetWorkshopSessions("?topic=" + WorkshopSetId + "&active=true&etc.");
                        }
                        else if (searchBy == "Workshop")
                        {
                            WrkSets = await RESTClass.GetWorkshopList("?active=true");

                            taskList             = new Adapters.SearchAdapter(this, WrkSets);
                            workshoplist.Adapter = taskList;
                            //	lvWorkShops.Adapter = taskList;


                            //			new AlertDialog.Builder (this)
                            //				.SetMessage(taskList.GetId(0))
                            //				.SetTitle("Application Error")
                            //				.Show();
                        }
                        else if (searchBy == "Programs")
                        {
                            //await Ge
                        }
                        dictGroup.Clear();
                        CreateExpendableListData();

                        ddpSearchList.SetAdapter(new ExpandListSessionAdapter(this, dictGroup));
                    }
                    catch (Exception e)
                    {
                        ErrorHandling.LogError(e, this);
                    }
                    finally
                    {
                        progressDialog.Dismiss();
                        progressDialog.Dispose();
                    }
                };

                ddpSearchList.ChildClick += delegate(object sender, ExpandableListView.ChildClickEventArgs e)
                {
                    try
                    {
                        string           itmGroup = lstKeys [e.GroupPosition];
                        WorkshopSessions itmChild = dictGroup [itmGroup];
                    }
                    catch (Exception Ex)
                    {
                        ErrorHandling.LogError(Ex, this);
                    }
                };

                ddpSearchList.GroupExpand += delegate(object sender, ExpandableListView.GroupExpandEventArgs e)
                {
                    if (lastExpandedPosition != -1 && e.GroupPosition != lastExpandedPosition)
                    {
                        ddpSearchList.CollapseGroup(lastExpandedPosition);
                    }

                    lastExpandedPosition = e.GroupPosition;
                };

                //				Button btnViewDetails = FindViewById<Button>(Resource.Id.btnViewDetails);
                //				btnViewDetails.Click += delegate {
                //					StartActivity(new Intent(this, typeof(MakeBookingListActivity)));
                //				} ;
            }
            catch (Exception e)
            {
                ErrorHandling.LogError(e, this);
            }
            finally
            {
                //				progressDialog.Dismiss();
                //				progressDialog.Dispose ();
            }
        }
        protected override void OnCreate(Bundle bundle)
        {
            string         userId              = "";
            string         password            = "";
            ProgressDialog ProgressDialogLogin = null;

            try
            {
                base.OnCreate(bundle);
                SetContentView(Resource.Layout.Login);

                Button       btnLogin    = FindViewById <Button>(Resource.Id.btnLogin);
                EditText     tbStudentID = FindViewById <EditText>(Resource.Id.tbStudentID);
                EditText     tbPassword  = FindViewById <EditText>(Resource.Id.tbPassword);
                LinearLayout llRoot      = FindViewById <LinearLayout>(Resource.Id.llRoot);
                TextView     txtmessage  = FindViewById <TextView>(Resource.Id.txtmessage);

                txtmessage.Visibility = ViewStates.Invisible;
                tbStudentID.Text      = userId;
                tbPassword.Text       = password;

                llRoot.Click += delegate {
                    //Dismiss Keybaord
                    InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService);
                    imm.HideSoftInputFromWindow(tbStudentID.WindowToken, 0);
                    btnLogin.RequestFocus();
                };

                btnLogin.Click += async delegate {
                    try
                    {
                        userId = tbStudentID.Text;

                        if (String.IsNullOrWhiteSpace(tbStudentID.Text) || String.IsNullOrWhiteSpace(tbPassword.Text))
                        {
                            txtmessage.Text       = "Please enter your Student Id and Password.";
                            txtmessage.Visibility = ViewStates.Visible;
                        }
                        else
                        {
                            if (ProgressDialogLogin == null)
                            {
                                ProgressDialogLogin = ProgressDialog.Show(this, "", "Logging In...");

                                Student student = await RESTClass.GetStudent(userId);

                                if (student != null)
                                {
                                    Globals.LoggedStudent = student;

                                    if (Globals.StudentExists(student.studentID))                                     //Finds out if the studentid is in the text file and fills out globals if true
                                    {
                                        Globals.IsNewStudent = false;
                                        Globals.SetGlobalVars(student.studentID);
                                        StartActivity(new Intent(this, typeof(MainMenuActivity)));
                                    }
                                    else
                                    {
                                        Globals.IsNewStudent = true;
                                        StartActivity(new Intent(this, typeof(ProfileActivity)));
                                    }
                                }
                                else
                                {
                                    txtmessage.Text       = "This is not a vaid UTS ID.";
                                    txtmessage.Visibility = ViewStates.Visible;
                                }

                                if (ProgressDialogLogin != null)
                                {
                                    ProgressDialogLogin.Dismiss();
                                    ProgressDialogLogin = null;
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        ErrorHandling.LogError(e, this);
                        if (ProgressDialogLogin != null)
                        {
                            ProgressDialogLogin.Dismiss();
                            ProgressDialogLogin = null;
                        }
                    }
                };
            }
            catch (Exception e)
            {
                ErrorHandling.LogError(e, this);
            }
            finally
            {
                if (ProgressDialogLogin != null)
                {
                    ProgressDialogLogin.Dismiss();
                    ProgressDialogLogin = null;
                }
            }
        }
        public override View GetChildView(int groupPosition, int childPosition, bool isLastChild,
                                          View convertView, ViewGroup parent)
        {
            try
            {
                DateTime StartDte = DateTime.Today;
                DateTime EndDte   = DateTime.Today;

                var item = _dictGroup [_lstGroupID [groupPosition]];

                if (convertView == null)
                {
                    convertView = _activity.LayoutInflater.Inflate(Resource.Layout.ListControl_BookingChild, null);
                }

                TextView tvRoom       = convertView.FindViewById <TextView> (Resource.Id.tvRoom);
                TextView tvStartDate  = convertView.FindViewById <TextView> (Resource.Id.tvStartDate);
                TextView tvTime       = convertView.FindViewById <TextView> (Resource.Id.tvTime);
                TextView tvFinishDate = convertView.FindViewById <TextView> (Resource.Id.tvFinishDate);
                TextView tvGroup      = convertView.FindViewById <TextView> (Resource.Id.tvGroup);
                TextView tvPlaces     = convertView.FindViewById <TextView> (Resource.Id.tvPlaces);
                TextView tvWaitlist   = convertView.FindViewById <TextView> (Resource.Id.tvWaitlist);

                Button btnViewDetails = convertView.FindViewById <Button> (Resource.Id.btnViewDetails);
                Button btnBook        = convertView.FindViewById <Button> (Resource.Id.btnBook);

                if (item.StartDate != null)
                {                 // 07/31/2012 17:00:00
                    StartDte = DateTime.ParseExact(item.StartDate, "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture);
                }

                if (item.EndDate != null)
                {
                    EndDte = DateTime.ParseExact(item.EndDate, "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture);
                }

                SetTVText(tvRoom, item.campus);
                SetTVText(tvStartDate, StartDte.ToShortDateString());
                SetTVText(tvTime, StartDte.ToShortTimeString().Remove(5) + " - " + EndDte.ToShortTimeString().Remove(5));                 // get just the time aspect from dates
                SetTVText(tvFinishDate, EndDte.ToShortDateString());
                SetTVText(tvGroup, ((item.targetingGroup != null) ? item.targetingGroup : "No Target"));
                SetTVText(tvPlaces, item.maximum - item.BookingCount);
                SetTVText(tvWaitlist, 0);

                btnBook.SetTextColor(Color.White);
                if (btnBook.HasOnClickListeners == false)
                {
                    btnBook.Click += delegate {
                        if (tvPlaces.Text.Trim() == "0")                         //If there are places left in the session
                        {
                            new AlertDialog.Builder(_activity)
                            .SetTitle("Session Full")
                            .SetMessage("The session you are attempting to book is currently full, would you like to be added to the waitlist?" +
                                        " You will be automatically added to the session when a spot becomes available.")
                            .SetCancelable(true)
                            .SetPositiveButton("Confirm", async delegate(object sender, DialogClickEventArgs e) {
                                await RESTClass.PostMakeWaitlist(item.WorkshopId.ToString(), Globals.LoggedStudent.studentID, Globals.LoggedStudent.studentID);
                            })
                            .Show();
                        }
                        else
                        {
                            new AlertDialog.Builder(_activity)
                            .SetTitle("Booked")
                            .SetMessage("Are you sure you want to book this session?")
                            .SetCancelable(true)
                            .SetPositiveButton("Confirm", async delegate(object sender, DialogClickEventArgs e) {
                                await RESTClass.PostMakeBooking(item.WorkshopId.ToString(), Globals.LoggedStudent.studentID, Globals.LoggedStudent.studentID);
                                //create calendar item
//									ContentValues eventValues = new ContentValues ();
//
//									eventValues.Put (CalendarContract.Events.InterfaceConsts.CalendarId,
//										_calId);
//									eventValues.Put (CalendarContract.Events.InterfaceConsts.Title,
//										"Test Event from M4A");
//									eventValues.Put (CalendarContract.Events.InterfaceConsts.Description,
//										"This is an event created from Xamarin.Android");
//									eventValues.Put (CalendarContract.Events.InterfaceConsts.Dtstart,
//										GetDateTimeMS (2011, 12, 15, 10, 0));
//									eventValues.Put (CalendarContract.Events.InterfaceConsts.Dtend,
//										GetDateTimeMS (2011, 12, 15, 11, 0));
//
//									eventValues.Put(CalendarContract.Events.InterfaceConsts.EventTimezone,
//										"UTC");
//									eventValues.Put(CalendarContract.Events.InterfaceConsts.EventEndTimezone,
//										"UTC");
//
//									var uri = ContentResolver.Insert (CalendarContract.Events.ContentUri,
//										eventValues);alendarContract.Calendars.InterfaceConsts.AccountName
//									};
                            })
                            .Show();
                        }
                    };
                }

                return(convertView);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        public override View GetChildView(int groupPosition, int childPosition, bool isLastChild,
                                          View convertView, ViewGroup parent)
        {
            try
            {
                DateTime StartDte = DateTime.Today;
                DateTime EndDte   = DateTime.Today;

                var item = _dictGroup [_lstGroupID [groupPosition]];

                if (convertView == null)
                {
                    convertView = _activity.LayoutInflater.Inflate(Resource.Layout.ListControl_BookingChild, null);
                }

                TextView tvRoom       = convertView.FindViewById <TextView> (Resource.Id.tvRoom);
                TextView tvStartDate  = convertView.FindViewById <TextView> (Resource.Id.tvStartDate);
                TextView tvTime       = convertView.FindViewById <TextView> (Resource.Id.tvTime);
                TextView tvFinishDate = convertView.FindViewById <TextView> (Resource.Id.tvFinishDate);
                TextView tvGroup      = convertView.FindViewById <TextView> (Resource.Id.tvGroup);
                TextView tvPlaces     = convertView.FindViewById <TextView> (Resource.Id.tvPlaces);
                TextView tvWaitlist   = convertView.FindViewById <TextView> (Resource.Id.tvWaitlist);

                Button btnViewDetails = convertView.FindViewById <Button> (Resource.Id.btnViewDetails);
                Button btnBook        = convertView.FindViewById <Button> (Resource.Id.btnBook);

                if (item.starting != null)
                {                 // 07/31/2012 17:00:00
                    StartDte = DateTime.ParseExact(item.starting, "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture);
                }

                if (item.ending != null)
                {
                    EndDte = DateTime.ParseExact(item.ending, "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture);
                }

                SetTVText(tvRoom, item.campusID);
                SetTVText(tvStartDate, StartDte.ToShortDateString());
                SetTVText(tvTime, StartDte.ToShortTimeString().Remove(5) + " - " + EndDte.ToShortTimeString().Remove(5));                 // get just the time aspect from dates
                SetTVText(tvFinishDate, EndDte.ToShortDateString());
                SetTVText(tvGroup, ((item.targetingGroup != null) ? item.targetingGroup : "No Target"));

                TextView lblPlacesAvailable = convertView.FindViewById <TextView> (Resource.Id.lblPlacesAvailable);
                TextView lblOnWaitlist      = convertView.FindViewById <TextView> (Resource.Id.lblOnWaitlist);
                lblOnWaitlist.Visibility      = ViewStates.Gone;
                lblPlacesAvailable.Visibility = ViewStates.Gone;
                tvPlaces.Visibility           = ViewStates.Gone;
                tvWaitlist.Visibility         = ViewStates.Gone;
                //SetTVText(tvPlaces, "Placeholder");//item.maximum - item.cutoff);
                //SetTVText(tvWaitlist, -1);

                btnBook.SetTextColor(Color.White);
                if (DateTime.ParseExact(item.ending, "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture) < DateTime.Now)                 //past
                {
                    btnBook.Visibility = ViewStates.Gone;
                }
                else
                {
                    btnBook.SetText("Cancel", Button.BufferType.Normal);
                    if (btnBook.HasOnClickListeners == false)
                    {
                        btnBook.Click += delegate {
                            new AlertDialog.Builder(_activity)
                            .SetTitle("Booked")
                            .SetMessage("Are you sure you want to cancel this booking?")
                            .SetCancelable(true)
                            .SetPositiveButton("Confirm", async delegate(object sender, DialogClickEventArgs e) {
                                await RESTClass.PostCancelBooking(item.workshopID.ToString(), Globals.LoggedStudent.studentID, Globals.LoggedStudent.studentID);
                            })
                            .Show();
                        };
                    }
                }

                return(convertView);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
 public async Task <List <WorkshopBooking> > GetBookings()
 {
     return(await RESTClass.GetWorkshopBookings("active=true&studentId=" + Globals.LoggedStudent));
 }