Exemplo n.º 1
0
 public async Task <IActionResult> CreateCharacteristic(CreateCharacteristicDto newCharacteristic)
 {
     return(Ok(await _characteristicService.CreateCharacteristic(newCharacteristic)));
 }
        public async Task <ServiceResponse <List <GetCharacteristicDto> > > CreateCharacteristic(CreateCharacteristicDto newCharacteristic)
        {
            ServiceResponse <List <GetCharacteristicDto> > serviceResponse = new ServiceResponse <List <GetCharacteristicDto> >();
            Characteristic Characteristic = _mapper.Map <Characteristic>(newCharacteristic);

            Characteristic.User = await _context.Users.FirstOrDefaultAsync(u => u.Id == GetUserId());

            await _context.Characteristics.AddAsync(Characteristic);

            await _context.SaveChangesAsync();

            serviceResponse.Data = await GetAllRecords();

            return(serviceResponse);
        }