public async Task <ActionResult> Create([FromBody] Models.Parking parking) { Infrastracture.Entities.Parking parkingTable = new Infrastracture.Entities.Parking(); parkingTable.Pid = Guid.NewGuid(); parkingTable.Date = parking.Fromdate; parkingTable.NumberOfslots = 10 - parking.noOfSlots; parkingTable.BookedSlots = parkingTable.NumberOfslots; parkingTable.Cars.Add(new Infrastracture.Entities.Car() { Cid = Guid.NewGuid(), CarNumber = parking.CarNumber, Fromdate = DateTime.UtcNow, Todate = DateTime.UtcNow, Pid = parkingTable.Pid }); try { var result = _parkingManegmentContext.Add(parkingTable); await _parkingManegmentContext.SaveChangesAsync(); return(Ok()); } catch (Exception ex) { throw ex; } }
public async Task CreateParking(Entities.Parking parking) { try { _parkingManegmentContext.Add(parking); await _parkingManegmentContext.SaveChangesAsync(); } catch (Exception ex) { throw ex; } }