Package models

Examples of models.Todo


        if (json != null)
        {
            for (JsonNode node: json)
            {
                ToDo incoming = Json.fromJson(node, ToDo.class);
                if (incoming.id == null)
                {
                    incoming.save();
                }
                else
                {
                    incoming.update();
                }
                saved.add(incoming);
            }
        }
View Full Code Here


    @BodyParser.Of(BodyParser.Json.class)
    public static Result save()
    {
        JsonNode json = request().body().asJson();
        ToDo incoming = Json.fromJson(json, ToDo.class);

        incoming.save();

        return ok(Json.toJson(incoming));
    }
View Full Code Here

    public static Result update(Long id)
    {
        // the ID parameter isn't used here, since it's already in the JSON body
        // PUTs should have an identifier, you could use it to confirm against the model you're sending, etc
        JsonNode json = request().body().asJson();
        ToDo incoming = Json.fromJson(json, ToDo.class);

        incoming.update();

        return ok(Json.toJson(incoming));
    }
View Full Code Here

        return ok(Json.toJson(incoming));
    }

    public static Result delete(Long id)
    {
        ToDo toDo = ToDo.findById(id);
        if (toDo != null)
        {
            toDo.delete();
        }
        return noContent();
    }
View Full Code Here

    @BodyParser.Of(BodyParser.Json.class)
    public static Result create()
    {
        JsonNode json = request().body().asJson();
        ToDo incoming = Json.fromJson(json, ToDo.class);

        incoming.save();

        return ok(Json.toJson(incoming));
    }
View Full Code Here

    public static Result update(Long id)
    {
        // the ID parameter isn't used here, since it's already in the JSON body
        // PUTs should have an identifier, you could use it to confirm against the model you're sending, etc
        JsonNode json = request().body().asJson();
        ToDo incoming = Json.fromJson(json, ToDo.class);

        incoming.update();

        return ok(Json.toJson(incoming));
    }
View Full Code Here

        return ok(Json.toJson(incoming));
    }

    public static Result delete(Long id)
    {
        ToDo toDo = ToDo.findById(id);
        if (toDo != null)
        {
            toDo.delete();
        }
        return noContent();
    }
View Full Code Here

                Result result = callAction(routes.ref.TodoController.createTodo(), fakeRequest);
               
                assertThat(status(result)).isEqualTo(OK);
               
                Todo todo = Json.fromJson(Json.parse(contentAsString(result)), Todo.class);
                assertThat(todo.id).isNotNull();
                assertThat(todo.value).isEqualTo("make it work");
                assertThat(todo.user).isNull(); // this should not be serialized
            }
        });
View Full Code Here

TOP

Related Classes of models.Todo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.