Beispiel #1
0
        public async Task <IActionResult> CreateVehicle([FromBody] VehicleResource vehicleResource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var vehicle = _mapper.Map <VehicleResource, Vehicle>(vehicleResource);

            vehicle.LastUpdate = DateTime.Now;
            context.Vehicles.Add(vehicle);
            await context.SaveChangesAsync();

            var result = Mapper.Map <Vehicle, VehicleResource>(vehicle);

            return(Ok(result));
        }
 public async Task Commit()
 {
     await context.SaveChangesAsync();
 }
Beispiel #3
0
        public async Task <bool> SaveChangesAsync()
        {
            var status = await context.SaveChangesAsync();

            return(status > 0);
        }