コード例 #1
0
ファイル: DataManager.cs プロジェクト: Marbax/C_Sharp
        private void InitData()
        {
            List <string> tmp_photo = new List <string>();

            tmp_photo.Add(@"..\..\img\1.jpg");
            tmp_photo.Add(@"..\..\img\2.jpg");
            tmp_photo.Add(@"..\..\img\3.jpg");

            for (int i = 0; i < 10; i++)
            {
                ApartmentsData.Add(new Apartment($"Apartment-{i}", $"Description-{i}", i * 200.2,
                                                 new DateTime(2010, 2, 1), new DateTime(2010, 2, 4), tmp_photo.ToArray()));
                ClientsData.Add(new Client($"Client-{i}", $"3809{i}3{i + 1}2{i + 2}", ApartmentsData.ToArray()));
            }
        }
コード例 #2
0
        private void OnAddClientCommand()
        {
            ClientWindow window = new ClientWindow();

            bool?result = window.ShowDialog();

            if (result == true)
            {
                Client client = (window.DataContext as ClientWindowViewModel).Client;

                if (client != null)
                {
                    int maxId = 0;
                    if (ClientsData.Count != 0)
                    {
                        maxId = ClientsData.Select(x => x.Id).Max();
                    }
                    client.Id = maxId + 1;
                    ClientsData.Add(client);
                }
            }
        }