public void DeleteRoadShouldNotHardDeleteRoad() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "DeleteRoad_Road_Db") .Options; var dbContext = new ApplicationDbContext(options); var roadsService = new RoadsService(dbContext, null, null, null, null, null); var road = new Road() { RoadName = "Road" }; dbContext.Roads.Add(road); dbContext.SaveChanges(); dbContext.Roads.Remove(road); dbContext.SaveChanges(); var result = roadsService.DeleteRoad(road.Id); Assert.False(result); }
public void DeleteRoad(Road road) { try { Logger.LogNewMessage($"Deleting road with id {road.Id}", LogType.INFO); RoadsService.DeleteRoad(road.Id); } catch (Exception ex) { Logger.LogNewMessage($"Error getting road with id {road.Id}. Message {ex.Message}", LogType.ERROR); } }
public async Task <ActionResult <Road> > DeleteRoad(int id) { return(await _roadsService.DeleteRoad(id)); }