コード例 #1
0
        public async Task <IActionResult> Save([FromBody] DtoBrandedTemplate dto)
        {
            var template = Mapper.Map <BrandedTemplate>(dto);

            _context.BrandedTemplates.Add(template);
            await _context.SaveChangesAsync()
            .ConfigureAwait(false);

            return(Ok(template.Id));
        }
コード例 #2
0
        public async Task <IActionResult> Post([FromBody] DtoFaculty dto)
        {
            var entity = Mapper.Map <Faculty>(dto);

            _context.Faculties.Add(entity);

            await _context
            .SaveChangesAsync()
            .ConfigureAwait(false);

            return(Ok(entity.Id));
        }
コード例 #3
0
        private async Task <long> AddUniversity()
        {
            var institution = new EducationalInstitution
            {
                Name        = "Томский Политехнический Университет",
                SiteUrl     = "http://tpu.ru/",
                Acronym     = "НИ ТПУ",
                Description = "Политех",
                AreaId      = await _context.Areas.Select(x => x.Id).FirstAsync()
            };

            _context.EducationalInstitutions.Add(institution);
            await _context.SaveChangesAsync();

            var @event = new EducationalInstitutionsChanged
            {
                Created = new[] { Mapper.Map <DtoEducationalInstitution>(institution) }
            };

            _eventBus.Publish(@event);

            return(institution.Id);
        }
コード例 #4
0
        public async Task <IActionResult> Post([FromBody] DtoEducationalInstitution dto)
        {
            var entity = Mapper.Map <EducationalInstitution>(dto);

            _context.EducationalInstitutions.Add(entity);

            await _context
            .SaveChangesAsync()
            .ConfigureAwait(false);

            dto.Id = entity.Id;
            var @event = new EducationalInstitutionsChanged
            {
                Created = new List <DtoEducationalInstitution> {
                    dto
                }
            };

            _eventBus.Publish(@event);

            return(Ok(entity.Id));
        }