public async Task <IActionResult> AddThemeToRecord(Guid recordId, UpdateRecordThemesDto themes)
        {
            if (recordId != themes.RecordId)
            {
                return(BadRequest("Not consistent request"));
            }

            try
            {
                await _recordsThemesService.AddRecordTheme(recordId, themes.ThemesIds);

                return(Ok());
            }
            catch (ArgumentException exc)
            {
                return(BadRequest(exc.Message));
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> CreateRecord(CreateRecordDto createDto)
        {
            try
            {
                var recId = await _recordService.AddRecord(createDto.Date, createDto.RecordName, createDto.RecordText);

                if (createDto.ThemesIds.Length > 0)
                {
                    await _recordsThemesService.AddRecordTheme(recId, createDto.ThemesIds);
                }
                var newRecordUri = $@"{await _appSettingsService.GetHostAndPort()}/api/v1.0/records/{recId}";
                return(Created(newRecordUri, recId));
            }
            catch (ArgumentException exc)
            {
                return(BadRequest(exc.Message));
            }
        }