示例#1
0
        /// <summary>
        /// Получение тезиса из БД
        /// </summary>
        /// <param name="thesisId"></param>
        public async Task <DtoThesisEdit> GetFromDbAsync(int thesisId)
        {
            var thesis = await _repoTheses.GetThesisByIdAsync(thesisId);

            var authors = await _repoAuthors.GetAuthorsByExtIdAsync(thesis.AuthorExternalId);

            var editThesis = _mapper.Map <DtoThesisEdit>(thesis);

            editThesis.Authors = _mapper.Map <List <DtoAuthorEdit> >(authors);
            return(editThesis);
        }
示例#2
0
        /// <summary>
        /// Логика редактирования тезиса
        /// </summary>
        /// <param name="thesisEdit"></param>
        public async Task EditThesisAsync(DtoThesisEdit thesisEdit)
        {
            var thesis = await _repoTheses.GetThesisByIdAsync(thesisEdit.Id);

            var authors = await _repoAuthors.GetAuthorsByExtIdAsync(thesis.AuthorExternalId);

            _mapper.Map(thesisEdit, thesis);
            var mappedAuthors = authors.CustomMap(thesisEdit.Authors);

            await _repoAuthors.UpdateAuthorsRangeAsync(mappedAuthors);

            await _repoTheses.UpdateThesisAsync(thesis);

            await _servTheses.UpdateThesesCashAsync();

            await _servTheses.UpdateThesesFiltersCashAsync();
        }