private void writeDataInList() { using (var db = new PSDBContext()) { AddressesCollection.Clear(); db.Addresses.Where(login => login.User.Login == userViewModel.UserLogin).ToList().ForEach(a => { AddressesCollection.Add(new Address { Title = a.Title }); }); } }
public void writeDataWithDateTimeInTable() { using (var db = new PSDBContext()) { AddressesCollection.Clear(); db.Addresses.Where(login => login.User.Login == userViewModel.UserLogin).ToList().ForEach(ad => AddressesCollection.Add(new Address { Title = ad.Title }) ); ServicesCollection.Clear(); db.Services.Where(login => login.User.Login == userViewModel.UserLogin).ToList().ForEach(ad => ServicesCollection.Add(new Service { Title = ad.Title }) ); RatesCollection.Clear(); db.Rates.Where(login => login.User.Login == userViewModel.UserLogin).ToList().ForEach(ad => RatesCollection.Add(new Rate { Title = ad.Title, MeasureTitle = ad.MeasureTitle, Price = ad.Price.ToString() }) ); VICollection.Clear(); db.VolumeIndications.Where(login => login.User.Login == userViewModel.UserLogin && login.DatePaid == SelectedDate).ToList().ForEach(vi => VICollection.Add(new VolumeIndication { SelectedAddress = AddressesCollection.FirstOrDefault(adcol => adcol.Title == vi.Address.Title), SelectedService = ServicesCollection.FirstOrDefault(adcol => adcol.Title == vi.Service.Title), SelectedRate = RatesCollection.FirstOrDefault(adcol => adcol.Title == vi.Rate.Title), PrevIndication = vi.PrevIndication.ToString(), CurIndication = vi.CurIndication.ToString(), Total = vi.Total.ToString(), SelectedDate = vi.DatePaid, Id = vi.Id } )); } }