public async Task <IActionResult> CreateTeachingUnit([FromBody] CreateTeachingUnitDto act, CancellationToken ct) { _logger.LogInformation("called CreateActionPlan {0}", act.ToString()); var id = await _TeachingUnitService.CreateTeachingUnitAsync(act, ct); if (id == null) { return(UnprocessableEntity()); } else { return(CreatedAtRoute("GetTeachingUnit", new { id }, act)); } }
public async Task <int?> CreateTeachingUnitAsync(CreateTeachingUnitDto CreateTeachingUnitDto, CancellationToken ct) { TeachingUnit TeachingUnitEntity = _mapper.Mapper.Map <TeachingUnit>(CreateTeachingUnitDto); _uow.TeachingUnit.CreateTeachingUnit(TeachingUnitEntity); if (await _uow.SaveChangesAsync(ct) > 0) { return(TeachingUnitEntity.Id); } else { return(null); } }