public void Insert(Person p) { var target = new Person { ID = GenerateID(), Name = p.Name, Age = p.Age }; DataStore.Add(target); p.ID = target.ID; }
public PersonViewModel(Person model) { this.Model = model; this.Name = model.ToReactivePropertyAsSynchronized( x => x.Name, ignoreValidationErrorValue: true) .SetValidateAttribute(() => this.Name); this.Age = model.ToReactivePropertyAsSynchronized( x => x.Age, convert: x => x.ToString(), convertBack: x => int.Parse(x), ignoreValidationErrorValue: true) .SetValidateAttribute(() => this.Age); this.HasErrors = new[] { this.Name.ObserveHasError, this.Age.ObserveHasError } .CombineLatest(x => x.Any(y => y)) .ToReactiveProperty(); }
public void Update(Person p) { var target = DataStore.Single(x => x.ID == p.ID); target.Name = p.Name; target.Age = p.Age; }
public PersonChanged(Person person) { this.Person = person; }
/// <summary> /// 変更対象を指定する /// </summary> /// <param name="id"></param> public void SetEditTarget(long id) { this.EditTarget = this.repository.Find(id); }