Esempio n. 1
0
        //Creating an instance of the dashboard's fragment
        public static LandlordDashboard NewInstance()
        {
            var frag1 = new LandlordDashboard {
                Arguments = new Bundle()
            };

            return(frag1);
        }
Esempio n. 2
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            //Set new names to fields
            v        = inflater.Inflate(Resource.Layout.AppPropertyView, container, false);
            submit   = v.FindViewById <Button>(Resource.Id.submitProperty);
            address1 = v.FindViewById <EditText>(Resource.Id.getAddress1);
            address2 = v.FindViewById <EditText>(Resource.Id.getAddress2);
            city     = v.FindViewById <EditText>(Resource.Id.getCity);
            price    = v.FindViewById <EditText>(Resource.Id.getPrice);
            postcode = v.FindViewById <EditText>(Resource.Id.getPostcode);
            bedrooms = v.FindViewById <Spinner>(Resource.Id.bedroomSpinner);
            addImage = v.FindViewById <Button>(Resource.Id.addImage);
            //Get user ID from the previous page
            id = int.Parse(ap.getAccessKey());

            //Set for drop down boxs
            bedrooms.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(bedrooms_ItemSelected);
            var bedroomAdapter = ArrayAdapter.CreateFromResource(
                Android.App.Application.Context, Resource.Array.bedroom_array, Android.Resource.Layout.SimpleSpinnerItem);

            bedroomAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            bedrooms.Adapter = bedroomAdapter;

            bathrooms = v.FindViewById <Spinner>(Resource.Id.bathroomSpinner);

            bathrooms.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(bathrooms_ItemSelected);
            var bathroomsAdapter = ArrayAdapter.CreateFromResource(
                Android.App.Application.Context, Resource.Array.bathroom_array, Android.Resource.Layout.SimpleSpinnerItem);

            bathroomsAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            bathrooms.Adapter = bathroomsAdapter;

            //set drop downs for accomodation type
            accomType = v.FindViewById <Spinner>(Resource.Id.typeSpinner);

            accomType.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(type_ItemSelected);
            var accomTypeAdapter = ArrayAdapter.CreateFromResource(
                Android.App.Application.Context, Resource.Array.type_array, Android.Resource.Layout.SimpleSpinnerItem);

            accomTypeAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            accomType.Adapter = accomTypeAdapter;

            //Set wifi and bills to new name
            wifi  = v.FindViewById <RadioGroup>(Resource.Id.getWifi);
            bills = v.FindViewById <RadioGroup>(Resource.Id.getBills);

            submit.Click += async delegate
            {
                //URL which will use php to add a new property
                string url = "http://housechecker.co.uk/api/new_property.php?";
                //Set data to fetched url
                string data = await FetchUserAsync(url);

                //Exporting user data
                url = "http://housechecker.co.uk/api/export.php";
                JsonValue json = await GetData(url);

                string jsonString = json.ToString();
                //Get list of users
                List <Student> userList = JsonConvert.DeserializeObject <List <Student> >(jsonString);

                var companySelected = userList.Where(a => a.Id == id).FirstOrDefault();

                //Set message which says that it has been added
                string message = "Hello, " + companySelected.CompanyName
                                 + ", you have successfully added the accomodation: " + address1.Text;
                string subject = "New property added";
                string to      = companySelected.Email;
                //Send email to URL
                url  = "http://housechecker.co.uk/api/email.php";
                data = await SendEmail(url, to, message, subject);

                //New fragment for when emailed
                FragmentTransaction fragmentTx        = FragmentManager.BeginTransaction();
                LandlordDashboard   landlordDashboard = new LandlordDashboard();

                fragmentTx.Replace(Resource.Id.content_frame, landlordDashboard);
                fragmentTx.Commit();
            };
            return(v);
        }