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)); }
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)); }
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); }
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)); }