Beispiel #1
0
 public void AddNewToDoItem(AddNewToDoItemCommandModel model)
 {
     string todoListId = database.IdMaps.GetAggregateId<ToDoList>(int.Parse(model.ToDoListId)).ToString();
     bus.Send<AddNewToDoItemCommand>(new AddNewToDoItemCommand(todoListId, model.Id, model.CreationDate, model.Description, model.DueDate, model.Importance));
     string _newId = database.IdMaps.GetModelId<ToDoItem>(new Guid(model.Id)).ToString();
     model.Id = _newId;
 }
        public IHttpActionResult AddItemToList(AddNewToDoItemCommandModel model)
        {
            if (!ModelState.IsValid)
                return BadRequest(ModelState);

            try
            {
                Worker.AddNewToDoItem(model);
                string uri = Url.Link("GetTodoItemById", new { Id = model.Id});
                var _Uri = new Uri(uri);
                return Redirect(_Uri);
                //return Ok();
            }
            catch (Exception ex)
            {
                return BadRequest(ex.Message);
            }
        }