private static PrintTalonData FindTalon(Policy policy) { var talon = talons.FirstOrDefault(x => x.SnPol == policy.SNPOL); if (talon == null) { talon = new PrintTalonData(policy); talons.Add(talon); while(talons.Count > 100) talons.RemoveAt(0); } return talon; }
private void Assign(PrintTalonData updatedTalon) { foreach (var propertyInfo in GetType().GetProperties().Where(x => x.CanWrite)) { propertyInfo.SetValue(this, propertyInfo.GetValue(updatedTalon, null), null); } }
public static void Update(PrintTalonData updatedTalon) { var talon = talons.FirstOrDefault(x => x.SnPol == updatedTalon.SnPol); if (talon == null) { talon = new PrintTalonData(); talons.Add(talon); } talon.Assign(updatedTalon); var card = DataContext.CardSet.FirstOrDefault(x => x.SnPol == updatedTalon.SnPol); if(card == null) { card = Card.CreateCard(0, updatedTalon.SnPol, updatedTalon.CardNum); DataContext.CardSet.AddObject(card); } card.DocDateTime = updatedTalon.DocDateTime; card.Snils = updatedTalon.Snils; DataContext.SaveChanges(); }