Пример #1
0
        public async Task <IActionResult> UpdateAsync([FromRoute] int applicationId, [FromBody] ApplicationRequestDto dto)
        {
            Application application;

            if (this.UserHasScope(ApplicationScopes.Admin))
            {
                application = await _updateApplicationService.UpdateAsync(dto.ToApplication(applicationId), dto.user_id ?? this.GetUserId());
            }
            else
            {
                application = await _updateApplicationService.UpdateAsync(dto.ToApplication(applicationId), this.GetUserId());
            }

            var updated = ApplicationResponseDto.FromApplication(application);

            return(Ok(updated));
        }
Пример #2
0
        public async Task <IActionResult> FindAsync([FromRoute] int applicationId)
        {
            Application application;

            if (this.UserHasScope(ApplicationScopes.Admin))
            {
                application = await _findApplicationService.FindAsync(applicationId);
            }
            else
            {
                application = await _findApplicationService.FindAsync(applicationId, this.GetUserId());
            }

            var found = ApplicationResponseDto.FromApplication(application);

            return(Ok(found));
        }
Пример #3
0
        public async Task <IActionResult> CreateAsync([FromBody] ApplicationRequestDto dto)
        {
            Application application;

            if (this.UserHasScope(ApplicationScopes.Admin))
            {
                application = await _addApplicationService.AddAsync(dto.ToApplication(), dto.user_id ?? this.GetUserId());
            }
            else
            {
                application = await _addApplicationService.AddAsync(dto.ToApplication(), this.GetUserId());
            }

            var created = ApplicationResponseDto.FromApplication(application);

            return(Created($"{_siteSettings.ListenUri}/applications/{application.ApplicationId}", created));
        }