Esempio n. 1
0
        public IHttpActionResult Put([FromBody] SubthemeDto dto)
        {
            Subtheme entity = ModelMapper.Map <Subtheme>(dto);

            this.subthemes.Change(entity);
            return(Ok());
        }
Esempio n. 2
0
        public IHttpActionResult Get(int id)
        {
            Subtheme    entity = this.subthemes.Get(id);
            SubthemeDto dto    = ModelMapper.Map <SubthemeDto>(entity);

            return(Ok(dto));
        }
Esempio n. 3
0
        public IHttpActionResult Post([FromBody] SubthemeDto dto)
        {
            Subtheme entity = ModelMapper.Map <Subtheme>(dto);

            this.subthemes.Add(entity);
            dto = ModelMapper.Map <SubthemeDto>(entity);
            return(Ok(dto));
        }
        private void AuthorizePut(HttpActionContext actionContext)
        {
            int organiserId;

            string controller = actionContext.ControllerContext.ControllerDescriptor.ControllerName;

            switch (controller)
            {
            case "Organisation":
                OrganisationDto organisationDto = (OrganisationDto)actionContext.ActionArguments["dto"];
                Organisation    organisation    = this.Organisations.Get(organisationDto.Id);
                organiserId = organisation.OrganiserId;
                break;

            case "Subtheme":
                SubthemeDto subthemeDto = (SubthemeDto)actionContext.ActionArguments["dto"];
                Subtheme    subtheme    = this.Subthemes.Get(subthemeDto.Id);
                organiserId = subtheme.OrganiserId;
                break;

            case "Theme":
                ThemeDto themeDto = (ThemeDto)actionContext.ActionArguments["dto"];
                Theme    theme    = this.Themes.Get(themeDto.Id);
                organiserId = themeDto.OrganiserId;
                break;

            case "Session":
                SessionDto sessionDto = (SessionDto)actionContext.ActionArguments["dto"];
                Session    session    = this.Sessions.Get(sessionDto.Id, collections: true);

                this.AuthorizeOrganiser(session.Organisers);

                return;

            default:        // will be unauthorized
                organiserId = -1;
                break;
            }

            this.AuthorizeOrganiser(organiserId);
        }
        private void AuthorizePost(HttpActionContext actionContext)
        {
            int organiserId;

            string controller = actionContext.ControllerContext.ControllerDescriptor.ControllerName;

            switch (controller)
            {
            case "Session":
            {
                SessionDto sessionDto = (SessionDto)actionContext.ActionArguments["dto"];
                Subtheme   subtheme   = this.Subthemes.Get(sessionDto.SubthemeId);
                organiserId = subtheme.OrganiserId;
            }
            break;

            case "Subtheme":
            {
                SubthemeDto subthemeDto = (SubthemeDto)actionContext.ActionArguments["dto"];
                Theme       theme       = this.Themes.Get(subthemeDto.ThemeId);
                organiserId = theme.OrganiserId;
            }
            break;

            case "Theme":
            {
                ThemeDto     themeDto     = (ThemeDto)actionContext.ActionArguments["dto"];
                Organisation organisation = this.Organisations.Get(themeDto.OrganisationId);
                organiserId = organisation.OrganiserId;
            }
            break;

            default:        // to prevent the dto from being null
                organiserId = -1;
                break;
            }

            this.AuthorizeOrganiser(organiserId);
        }