public static TodoItem Map(MongoTodoItem mongoItem) { var item = new TodoItem() { Id = mongoItem.Id, Text = mongoItem.Description, Done = mongoItem.Done }; return item; }
public static MongoTodoItem Map(TodoItem item) { var mongoItem = new MongoTodoItem() { Id = item.Id, Description = item.Text, Done = item.Done }; return mongoItem; }
public void Map_HasDataInMongoTodoItem_MapsToCorrectTodoItem() { var mongoItem = new MongoTodoItem() { Id = "MyAwesomeId1", Description = "Buy the all ellusive milk please", Done = false }; var todo = TodoMapper.Map(mongoItem); Assert.NotNull(todo); Assert.Equal(mongoItem.Done, todo.Done); Assert.Equal(mongoItem.Id, todo.Id); Assert.Equal(mongoItem.Description, todo.Text); }
private async Task<HttpResponseMessage> SaveTodoAndGetResponse(TodoItem item) { var exists = await _repo.Exists(item.Text); if (item.Id == null && exists == false) { var mongoItem = new MongoTodoItem() { Done = item.Done, Description = item.Text }; await _repo.Save(item); return Request.CreateResponse<string>(HttpStatusCode.Created, "Todo created"); } else { return Request.CreateResponse<string>(HttpStatusCode.Conflict, "Item allready exists in database"); } }