public void Handle(AddedNewToDoItemEvent @event) { using (var db = new ToDoContext()) { int listId = _identityMapper.GetModelId <ToDoList>(@event.ToDoListId); ToDoList list = db.Lists.First(t => t.Id.Equals(listId)); if (list != null) { var _item = new Model.ToDoItem() { //Id = @event.ToDoItemId, ToDoListId = listId, Description = @event.Description, CreationDate = @event.CreationDate, DueDate = @event.DueDate, Importance = @event.Importance, ClosingDate = null, UserId = 0 }; list.Items.Add(_item); db.SaveChanges(); _identityMapper.Map <ToDoItem>(_item.Id, @event.ToDoItemId); } } }
void Apply(AddedNewToDoItemEvent @event) { Id = @event.ToDoItemId; ToDoListId = @event.ToDoListId; Description = @event.Description; CreationDate = @event.CreationDate; DueDate = @event.DueDate; Importance = @event.Importance; ClosingDate = null; }
void Apply(AddedNewToDoItemEvent @event) { Id = @event.ToDoItemId; ToDoListId = @event.ToDoListId; Description = @event.Description; CreationDate = @event.CreationDate; DueDate = @event.DueDate; Importance = @event.Importance; ClosingDate = null; }