示例#1
0
        private void SetRooms(long id)
        {
            RommServiceClient client = new RommServiceClient();

            RoomDto[] roomListDtos = client.getRoomListDtos(id);

            if (roomListDtos != null)
            {
                foreach (var item in roomListDtos)
                {
                    RoomListItem listItem = new RoomListItem();

                    listItem.Title    = item.name;
                    listItem.Subtitle = item.id;

                    if (item.exhibitionPhoto != null)
                    {
                        System.Net.WebRequest  request        = System.Net.WebRequest.Create(item.exhibitionPhoto);
                        System.Net.WebResponse response       = request.GetResponse();
                        System.IO.Stream       responseStream = response.GetResponseStream();
                        Bitmap bitmap = new Bitmap(responseStream);

                        listItem.Image = bitmap;
                    }



                    flowLayoutPanel1.Controls.Add(listItem);
                }
            }
        }
        private async void SetRooms(long id)
        {
            RommServiceClient client = new RommServiceClient();

            using (new OperationContextScope(client.InnerChannel))
            {
                Program.AddAccessHeaders();
                //RoomDto[] roomListDtos = client.getRoomListDtos(id);
                RoomDto[] roomListDtos = await getRoomDtoLISTREST(id);

                if (roomListDtos != null)
                {
                    foreach (var item in roomListDtos)
                    {
                        RoomListItem listItem = new RoomListItem();

                        listItem.Title    = item.name;
                        listItem.Subtitle = item.id;

                        if (item.exhibitionPhoto != null)
                        {
                            System.Net.WebRequest  request        = System.Net.WebRequest.Create(item.exhibitionPhoto);
                            System.Net.WebResponse response       = request.GetResponse();
                            System.IO.Stream       responseStream = response.GetResponseStream();
                            Bitmap bitmap = new Bitmap(responseStream);

                            listItem.Image = bitmap;
                        }


                        flowLayoutPanel1.Controls.Add(listItem);
                    }
                }
            }
        }
        private void sendComment_Click(object sender, EventArgs e)
        {
            UserRating rating = new UserRating();

            rating.personName  = textBox1.Text;
            rating.description = textBox1.Text;

            try
            {
                UserRatingClient client = new UserRatingClient();
                using (new OperationContextScope(client.InnerChannel))
                {
                    Program.AddAccessHeaders();
                    client.addUserRating(rating, 181, _ID);
                }

                RommServiceClient client2 = new RommServiceClient();
                using (new OperationContextScope(client2.InnerChannel))
                {
                    Program.AddAccessHeaders();
                    RoomDto room = client2.getRoomDto(_ID);
                }

                if (room.userRatings != null)
                {
                    flowLayoutPanel2.Controls.Clear();
                    foreach (var item in room.userRatings.Reverse())
                    {
                        CommentItem comment = new CommentItem(item.personName, item.description);
                        flowLayoutPanel2.Controls.Add(comment);
                    }
                }
                //SetRoomDetails(_ID);

                MessageBox.Show("Comment succesfully added!", "Comment", MessageBoxButtons.OK);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Comment", MessageBoxButtons.OK);
            }

            textBox1.Text = "";
        }
        private async void SetRoomDetails(long id)
        {
            RommServiceClient client = new RommServiceClient();

            using (new OperationContextScope(client.InnerChannel))
            {
                Program.AddAccessHeaders();
                //room = client.getRoomDto(id);
                room = await getRoomDtoREST(id);

                nameRoom.Text       = room.name;
                descriptionTb.Text  = room.description;
                pricePerPerson.Text = "Price per person: " + room.pricePerPerson + "$";
                persons.Text        = "Max persons: " + room.maxPersons;
                idTb.Text           = _ID + ":" + room.id;

                if (room.equipments != null)
                {
                    listView2.View = View.List;

                    foreach (var item in room.equipments)
                    {
                        var listViewItem = new ListViewItem(item);
                        listView2.Items.Add(listViewItem);
                    }
                }

                if (room.photos != null)
                {
                    pictureBox1.Image = GetBitmapFromUrl(room.photos[0]);

                    listView1.View     = View.Tile;
                    listView1.TileSize = new Size(100, 100);

                    myImageList           = new ImageList();
                    myImageList.ImageSize = new Size(90, 90);
                    foreach (var item in room.photos)
                    {
                        myImageList.Images.Add(GetBitmapFromUrl(item));
                    }

                    listView1.LargeImageList = myImageList;
                    for (int j = 0; j < myImageList.Images.Count; j++)
                    {
                        ListViewItem item = new ListViewItem();
                        item.ImageIndex = j;
                        listView1.Items.Add(item);
                    }
                }

                if (room.rules != null)
                {
                    //listView3.View = View.Tile;
                    //listView1.TileSize = new Size(100, 40);
                    foreach (var item in room.rules)
                    {
                        RuleItemcs rule = new RuleItemcs(item.name, item.description);
                        flowLayoutPanel1.Controls.Add(rule);
                        //TextBox lvi = new TextBox();
                        //lvi.Multiline = true;
                        //lvi.Width = 260;
                        //lvi.Text = "["+item.name+"] \n";
                        //lvi.Text += item.description;
                        //listView3.Items.Add(lvi);
                    }
                }

                if (room.userRatings != null)
                {
                    foreach (var item in room.userRatings.Reverse())
                    {
                        CommentItem comment = new CommentItem(item.personName, item.description);
                        flowLayoutPanel2.Controls.Add(comment);
                    }
                }
            }

            price.Text = "Price: " + room.maxPersons * room.pricePerPerson + "$";
        }