Exemplo n.º 1
0
        private void DeleteGroup(int groupId)
        {
            if (groupId != -1)
            {
                try
                {
                    TcpClient tcpClient = new TcpClient();
                    tcpClient.Connect(ServerIp, ServerPort);
                    WriteToStream(tcpClient.GetStream(), $"DELG {groupId}");
                    tcpClient.Close();

                    Classes.Group bufGroup = Groups.Where(g => g.Id == SelectedGroupId).FirstOrDefault();
                    Groups.Remove(bufGroup);
                    SelectedGroupId           = -1;
                    NoteMenuBorder.Visibility = Visibility.Hidden;
                    LoadGroups();
                }
                catch (Exception)
                {
                    ShowErrorWindow("Something went wrong");
                }
            }
            else
            {
                ShowErrorWindow("Group is not selected");
            }
        }
Exemplo n.º 2
0
        private void CreateGroup()
        {
            try
            {
                TcpClient tcpClient = new TcpClient();
                tcpClient.Connect(ServerIp, ServerPort);
                WriteToStream(tcpClient.GetStream(), $"CRTG {Login}");

                string        json     = ReadStringFromStream(tcpClient.GetStream());
                Classes.Group newGroup = JsonConvert.DeserializeObject <Classes.Group>(json);
                tcpClient.Close();

                Groups.Add(newGroup);
                AddGroup("g" + newGroup.Id, newGroup.Title, true);
            }
            catch (Exception)
            {
                ShowErrorWindow("Something went wrong");
            }
        }