private void RemoveShoutout(object shoutout) { ShoutoutModel model = (ShoutoutModel)shoutout; this.Shoutouts.Remove(model); this.repository.Remove(model.Id); }
private void AddShoutout() { ShoutoutModel shoutoutModel = new ShoutoutModel { Id = Guid.NewGuid().ToString() }; this.Shoutouts.Add(shoutoutModel); }
protected override void Initialize() { IEnumerable <Shoutout> allShoutouts = this.repository.GetAll(); foreach (Shoutout shoutout in allShoutouts) { ShoutoutModel model = new ShoutoutModel(); this.mapper.MapToModel(shoutout, model); this.Shoutouts.Add(model); } this.Shoutouts.RegisterCollectionItemChanged(this.OnShoutoutChanged); }
private void OnShoutoutChanged(object sender, PropertyChangedEventArgs e) { ShoutoutModel model = (ShoutoutModel)sender; if (string.IsNullOrEmpty(model.Command) || string.IsNullOrEmpty(model.Message)) { return; } Shoutout shoutout = new Shoutout(); this.mapper.MapToEntity(model, shoutout); this.repository.AddOrUpdate(shoutout); }