public async Task <IActionResult> CreateCar(SamochodyPostDTO samochodyToAdd) { try { var guid = await samochodyRepository.addCar(samochodyToAdd); return(guid == Guid.Empty ? (IActionResult)StatusCode(500) : Ok(guid)); } catch (Exception e) { return(StatusCode(500)); } }
public async Task <Guid> addCar(SamochodyPostDTO SamochodyPostDTO) { Samochody car = new Samochody() { Id = Guid.NewGuid(), Marka = SamochodyPostDTO.Marka, Model = SamochodyPostDTO.Model, KM = SamochodyPostDTO.KM, Silnik = SamochodyPostDTO.Silnik, Sciezka = SamochodyPostDTO.Sciezka }; await samochodyContext.Samochody.AddAsync(car); await saveAll(); return(car.Id); }