Exemplo n.º 1
0
        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);

                    Task.Run(() => notifier.AddedNewToDoItemEventNotify(_item)).ConfigureAwait(false);
                }
            }
        }