public EditPrecenseViewModel(Presence presence) { LogManager.GetLog(GetType()).Info("Create"); this._presence = presence; Name = _presence.Child.GetFullName(); CurrentState = State.NotArrivedYet; if (_presence.BroughtBy != null) { CurrentState = State.HasArrived; BroughtByName = _presence.BroughtBy.GetFullName(); _broughtAt = _presence.BroughtAt; } if (_presence.TakenBy != null) { CurrentState = State.HasLeft; TakenByName = _presence.TakenBy.GetFullName(); _takenAt = _presence.TakenAt; } CurrentTime = DateTime.Now; if (HasLeft == false) { using (var db = new PetoeterDb(PetoeterDb.FileName)) { // find account var account = GetAccount(db.Accounts.FindAll()); if (account != null) { Resposibles = (from m in account.Members select new MemberUI { Name = m.GetFullName(), Tag = m }).ToList(); Resposibles.AddRange(from m in db.Members.Find(mem => mem.Phone == "GrandParents") select new MemberUI { Name = m.FirstName, Tag = m }); } } } }
public override void YesAction() { LogManager.GetLog(GetType()).Info("YesAction"); if (SelectedItem != null) { using (var db = new PetoeterDb(PetoeterDb.FileName)) { var presence = new Presence { Child = SelectedItem.Tag, Date = DateTimeProvider.Now().Date, Updated = DateTimeProvider.Now(), TimeCode = 9 }; db.Presences.Insert(presence); }; } base.YesAction(); }