Ejemplo n.º 1
0
        public async static Task <ResponseObject> PutAsJsonAsync(string uri, EditObject d, string token)
        {
            var itemJson = JsonConvert.SerializeObject(d);
            var content  = new StringContent(itemJson);

            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            var authValue = new AuthenticationHeaderValue(token);
            var http      = new HttpClient()
            {
                DefaultRequestHeaders = { Authorization = authValue }
            };
            var response = await http.PutAsync(uri, content);

            var status = response.IsSuccessStatusCode;

            ResponseObject data = new ResponseObject();

            if (status == true)
            {
                data.status = true;
                return(data);
            }
            else
            {
                data.status = false;
                return(data);
            }
        }
 private void Modify_Click(object sender, RoutedEventArgs e)
 {
     Ring.IsActive = true;
     if (EventList.SelectedIndex >= 0)
     {
         Ring.IsActive        = false;
         No_Events.Visibility = Visibility.Collapsed;
         int           index = EventList.SelectedIndex;
         EditObject    obj1  = obj[index];
         SelectedEvent s     = new SelectedEvent();
         s.obj   = obj1;
         s.token = token;
         this.Frame.Navigate(typeof(Edit), s);
     }
     else
     {
         Ring.IsActive        = false;
         No_Events.Visibility = Visibility.Visible;
     }
 }
Ejemplo n.º 3
0
        public async void submit_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Ring.IsActive      = true;
                submit.IsEnabled   = false;
                Invalid.Visibility = Visibility.Collapsed;
                EditObject d = new EditObject();
                d.eventName = TextBox1.Text.ToString();
                d.eventType = type;
                d._id       = obj._id.ToString();

                if (Department.IsEnabled == true)
                {
                    d.department = dept;
                }
                else
                {
                    d.department = "";
                }

                d.tagline     = TextBox2.Text.ToString();
                d.description = TextBox3.Text.ToString();
                d.teamSize    = Convert.ToInt32(TextBox4.Text);
                d.entryFee    = Convert.ToInt32(TextBox5.Text);

                ArrayList prize = new ArrayList();
                prize.Add(Winner.Text.ToString());
                prize.Add(Runner_Up.Text.ToString());

                d.prizeMoney = new List <int>();
                int p_Count = 0;
                while (p_Count < prize.Count)
                {
                    d.prizeMoney.Add(Convert.ToInt32(prize[p_Count]));
                    p_Count++;
                }

                ArrayList names = new ArrayList();
                ArrayList phone = new ArrayList();
                ArrayList round = new ArrayList();

                names.Add(TextBox6.Text.ToString());
                phone.Add(TextBox7.Text.ToString());
                round.Add(TextBox8.Text.ToString());

                int counter = 2;
                while (counter < m_Count)
                {
                    TextBox n = (TextBox)this.Manager.FindName("ManagerName" + (counter));
                    TextBox p = (TextBox)this.Manager.FindName("Number" + (counter));
                    counter++;

                    names.Add(n.Text.ToString());
                    phone.Add(p.Text.ToString());
                }

                counter = 2;
                while (counter < r_Count)
                {
                    TextBox r = (TextBox)this.Rounds.FindName("Round" + (counter));
                    counter++;

                    round.Add(r.Text.ToString());
                }

                d.managers = new List <Manager>();
                int k = 0, l = 0;

                while (k < names.Count)
                {
                    Manager m1 = new Manager();
                    m1.name  = names[k].ToString();
                    m1.phone = phone[k].ToString();
                    d.managers.Add(m1);
                    k++;
                }

                d.rounds = new List <string>();
                while (l < round.Count)
                {
                    d.rounds.Add(round[l].ToString());
                    l++;
                }

                string         uri = "http://udaan18-events-api.herokuapp.com/events";
                ResponseObject response = await Submit.PutAsJsonAsync(uri, d, token);

                if (response.status == true)
                {
                    Ring.IsActive = false;
                    this.Frame.Navigate(typeof(Finish), token);
                }
                else
                {
                    Ring.IsActive      = false;
                    Invalid.Text       = "Submission unsuccessfull. (Are you missing any field..?)";
                    Invalid.Visibility = Visibility.Visible;
                    submit.IsEnabled   = true;
                }
            }
            catch (Exception)
            {
                Ring.IsActive      = false;
                Invalid.Text       = "Each field is complusory..!";
                Invalid.Visibility = Visibility.Visible;
                submit.IsEnabled   = true;
            }
        }
Ejemplo n.º 4
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            s     = (SelectedEvent)e.Parameter;
            obj   = s.obj;
            token = s.token;

            if (obj.eventType == "Technical")
            {
                Type.SelectedIndex   = 0;
                Department.IsEnabled = true;
                if (obj.department.ToString() == "Computer/IT")
                {
                    Department.SelectedIndex = 0;
                }
                else if (obj.department.ToString() == "Civil")
                {
                    Department.SelectedIndex = 1;
                }
                else if (obj.department.ToString() == "Electrical")
                {
                    Department.SelectedIndex = 2;
                }
                else if (obj.department.ToString() == "Mechanical/Production")
                {
                    Department.SelectedIndex = 3;
                }
                else
                {
                    Department.SelectedIndex = 4;
                }
            }
            else if (obj.eventType == "Non-Technical")
            {
                Type.SelectedIndex   = 1;
                Department.IsEnabled = false;
            }
            else if (obj.eventType == "Cultural")
            {
                Type.SelectedIndex   = 2;
                Department.IsEnabled = false;
            }
            else if (obj.eventType == "Treasure_Hunt")
            {
                Type.SelectedIndex   = 3;
                Department.IsEnabled = false;
            }
            else if (obj.eventType == "Girls")
            {
                Type.SelectedIndex   = 4;
                Department.IsEnabled = false;
            }
            else
            {
                Type.SelectedIndex   = 5;
                Department.IsEnabled = false;
            }
            TextBox1.Text         = obj.eventName.ToString();
            TextBox2.Text         = obj.tagline.ToString();
            TextBox3.TextWrapping = TextWrapping.Wrap;
            TextBox3.Text         = obj.description.ToString();
            TextBox4.Text         = obj.teamSize.ToString();
            TextBox5.Text         = obj.entryFee.ToString();
            List <int> prizeList = obj.prizeMoney.ToList();

            Winner.Text    = prizeList[0].ToString();
            Runner_Up.Text = prizeList[1].ToString();

            List <Manager> m1 = obj.managers.ToList();

            TextBox6.TextWrapping = TextWrapping.Wrap;
            TextBox6.Text         = m1[0].name.ToString();
            TextBox7.TextWrapping = TextWrapping.Wrap;
            TextBox7.Text         = m1[0].phone.ToString();
            TextBox8.TextWrapping = TextWrapping.Wrap;
            TextBox8.Text         = obj.rounds[0].ToString();
            TextBox6.TextWrapping = TextWrapping.Wrap;
            m_Count = m1.Count() + 1;
            r_Count = obj.rounds.Count + 1;

            j = 1;
            i = 2;
            while (i < m_Count)
            {
                Warning1.Visibility = Visibility.Collapsed;

                TextBlock tb = new TextBlock();
                tb.Name   = "Manager" + i;
                tb.Text   = "Manager " + i;
                tb.Margin = new Thickness(0, 10, 0, 0);
                tb.HorizontalAlignment = HorizontalAlignment.Stretch;
                tb.VerticalAlignment   = VerticalAlignment.Stretch;
                tb.Foreground          = TextBox1.Foreground;
                Manager.Children.Add(tb);
                Rounds.UpdateLayout();

                TextBox t = new TextBox();
                t.Name                = "ManagerName" + i;
                t.PlaceholderText     = "Name";
                t.Text                = m1[j].name.ToString();
                t.HorizontalAlignment = HorizontalAlignment.Stretch;
                t.VerticalAlignment   = VerticalAlignment.Stretch;
                t.Margin              = new Thickness(0, 10, 0, 0);
                t.Foreground          = TextBox1.Foreground;
                t.TextWrapping        = TextWrapping.Wrap;
                Manager.Children.Add(t);
                Rounds.UpdateLayout();

                TextBox n = new TextBox();
                n.Name                = "Number" + i;
                n.PlaceholderText     = "Phone Number";
                n.Text                = m1[j].phone.ToString();
                n.HorizontalAlignment = HorizontalAlignment.Stretch;
                n.VerticalAlignment   = VerticalAlignment.Stretch;
                n.Margin              = new Thickness(0, 10, 0, 0);
                n.Foreground          = TextBox1.Foreground;
                n.TextWrapping        = TextWrapping.Wrap;
                Manager.Children.Add(n);
                Rounds.UpdateLayout();

                j++;
                i++;
            }

            j = 1;
            i = 2;
            while (i < r_Count)
            {
                Warning2.Visibility = Visibility.Collapsed;
                TextBox t = new TextBox();
                t.Name                = "Round" + i;
                t.PlaceholderText     = "Round " + i;
                t.Text                = obj.rounds[j].ToString();
                t.HorizontalAlignment = HorizontalAlignment.Stretch;
                t.VerticalAlignment   = VerticalAlignment.Stretch;
                t.Height              = 100;
                t.Margin              = new Thickness(0, 10, 0, 0);
                t.Foreground          = TextBox1.Foreground;
                t.TextWrapping        = TextWrapping.Wrap;
                Rounds.Children.Add(t);
                Rounds.UpdateLayout();
                j++;
                i++;
            }
        }