Package models

Examples of models.Audience


@SecureSocial.SecuredAction(ajaxCall = true)
public class AudienceRestController extends BaseController {

    public static Result get(Long id) {
        Audience audience = Audience.find.byId(id);
        if (audience == null || !audience.getEvent().equals(getEvent())) {
            return noContent();
        }
        return ok(toJson(audience));
    }
View Full Code Here


        User user = getLoggedUser();
        if (!user.admin && !user.hasEvent(getEvent())) {
            return forbidden();
        }

        Audience audience = Audience.find.byId(id);
        if (audience != null && audience.getEvent().equals(getEvent())) {
            audience.delete();
        }
        // HTTP 204 en cas de succès (NO CONTENT)
        return noContent();
    }
View Full Code Here

        if (audienceForm.hasErrors()) {
            return badRequest(toJson(TransformValidationErrors.transform(audienceForm.errors())));
        }

        Audience formAudience = audienceForm.get();

        if (formAudience.getId() == null) {
            // Nouveau Track
            if (Audience.findByTitleAndEvent(formAudience.getTitle(),getEvent()) != null) {
                return badRequest(toJson(TransformValidationErrors.transform(Messages.get("error.audience.already.exist"))));
            }

            formAudience.setEvent(getEvent());
            formAudience.save();
        } else {
            // Mise à jour d'un track
            Audience dbAudience = Audience.find.byId(formAudience.getId());
            if (!formAudience.getTitle().equals(dbAudience.getTitle())
                    && Audience.findByTitleAndEvent(formAudience.getTitle(),getEvent()) != null) {
                return badRequest(toJson(TransformValidationErrors.transform(Messages.get("error.audience.already.exist"))));
            }


            dbAudience.setTitle(formAudience.getTitle());
            dbAudience.setDescription(formAudience.getDescription());
            dbAudience.update();
        }

        // HTTP 204 en cas de succès (NO CONTENT)
        return noContent();
    }
View Full Code Here

TOP

Related Classes of models.Audience

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.