static void Main(string[] args) { TravelContext context = new TravelContext(Way.火车); context.Travel(); Console.Read(); }
public OverviewRepository(IConfiguration configuration, IPhotoRepository photoRepository, TravelContext travelContext = null) { _context = travelContext ?? new TravelContext(); _config = configuration; _photoRepository = photoRepository; }
public JourneyRepository(IPhotoRepository photoRepository, IConfiguration configuration, TravelContext context = null, IFileSystem fileSystem = null) { _context = context ?? new TravelContext(); _photoRepository = photoRepository; _config = configuration; _fileSystem = fileSystem ?? new FileSystem(); }
public void Delete() { InitializeDataBase(); // Use a clean instance of the context to run the test using (var context = new TravelContext(options)) { ClientController clientController = new ClientController(context); Client client = clientController.DeleteClient(2).Result.Value; Assert.Null(client); } }
public void GetbyId() { InitializeDataBase(); // Use a clean instance of the context to run the test using (var context = new TravelContext(options)) { int clientId = 2; ClientController clientController = new ClientController(context); Client client = clientController.GetClient(clientId).Result.Value; Assert.Equal(2, client.Id); } }
public void GetAll() { InitializeDataBase(); // Use a clean instance of the context to run the test using (var context = new TravelContext(options)) { ClientController clientController = new ClientController(context); IEnumerable <Client> clients = clientController.GetClient().Result.Value; Assert.Equal(3, clients.Count()); } }
public static async Task <HttpResponseMessage> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequestMessage req, TraceWriter log) { string id = req.GetQueryNameValuePairs().FirstOrDefault(q => string.Compare(q.Key, "id", true) == 0).Value; int argumentId = 0; Int32.TryParse(id, out argumentId); AssemblyVersionResolver.RedirectAssembly(); TravelContext dbContext = new TravelContext(); //1 - Generates only dummy data //2 - Calculates the delta population for the dummy data imported via data factory job. //3 - Predicts the population for next 3 years from the current month - calls the ML Service //23 - Does 2 and 3 together switch (argumentId) { case 1: DummyDataSimulator.GenerateDummyTravelData(dbContext); break; case 2: DeltaCalculator.CalculateDeltaPopulationFromDummyData(dbContext); break; case 3: DeltaPredictor.PredictMigrationPopulation(dbContext).Wait(); break; case 23: DeltaCalculator.CalculateDeltaPopulationFromDummyData(dbContext); DeltaPredictor.PredictMigrationPopulation(dbContext).Wait(); break; default: break; } await Task.Delay(1); return(id == null ? new HttpResponseMessage(HttpStatusCode.BadRequest) { Content = new StringContent(JsonConvert.SerializeObject("Please pass a name on the query string or in the request body"), Encoding.UTF8, "application/json") } : new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(JsonConvert.SerializeObject(new { result = "Hello " + id }), Encoding.UTF8, "application/json") }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); TravelContext travelContext = new TravelContext(); services.AddDbContext <TravelContext>(ServiceLifetime.Singleton); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); }
public void Update() { InitializeDataBase(); Client client = new Client() { Id = 3, Name = "José Silva", Telephone = "16 98888 7777", NumberOfChildren = 2, BirthdayDate = DateTime.Now }; // Use a clean instance of the context to run the test using (var context = new TravelContext(options)) { ClientController clientController = new ClientController(context); Client cli = clientController.PutClient(3, client).Result.Value; Assert.Equal("José Silva", cli.Name); } }
private void InitializeDataBase() { // Create a Temporary Database options = new DbContextOptionsBuilder <TravelContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) .Options; // Insert data into the database using one instance of the context using (var context = new TravelContext(options)) { context.Client.Add(new Client { Id = 1, Name = "Name 1", NumberOfChildren = 1, Telephone = "16 99999 8888", BirthdayDate = DateTime.Now }); context.Client.Add(new Client { Id = 2, Name = "Name 1", NumberOfChildren = 2, Telephone = "16 99999 6666", BirthdayDate = DateTime.Now }); context.Client.Add(new Client { Id = 3, Name = "Name 1", NumberOfChildren = 3, Telephone = "16 99999 8877", BirthdayDate = DateTime.Now }); context.SaveChanges(); } }
public static List <IdTitle> PlaceIdTitles() { var idTitle = new List <IdTitle>() { new IdTitle() { Id = 0, Title = "قاره" } }; using (TravelContext db = new TravelContext()) { idTitle.AddRange(db.Places.Select(u => new IdTitle() { Title = u.Title, Id = u.Id })); } return(idTitle); }
public UserRepository(UserManager <User> userManager, TravelContext travelContext = null) { _context = travelContext ?? new TravelContext(); _userManager = userManager; }
public TaskService(TravelContext db) : base(db) { }
public StopController(ITravelRepository repository, ILogger <StopController> logger, TravelContext context) { _context = context; _repository = repository; _logger = logger; }
public RefuelQueries(TravelContext context, IMapperService mapper) { _context = context; _mapper = mapper; }
//Constructor public HomeController(TravelContext context) { _dbcontext = context; }
public EmployeesController(TravelContext context) { _context = context; }
public RouteController(TravelContext context) { this.travelDb = context; }
public LogsOfRegionsRepository(TravelContext context) : base(context) { }
public CounterRepository(TravelContext travelEntities) { _travelContext = travelEntities; }
public TaskController(TravelContext context) { this.travelDb = context; }
public DestinationsController(TravelContext db) { _db = db; }
// private IUserService _userService; public ReviewsController(TravelContext db, IUserService userService) { _db = db; // _userService = userService; }
public TripsController(TravelContext context) { _context = context; }
public ActionResult Index() { TravelContext _context = new TravelContext(); return(View()); }
public GenericRepository(TravelContext context) { this.context = context; dbSet = context.Set <TEntity>(); }
public EntityService(TravelContext db) { this.db = db; dbset = db.Set <T>(); }
/// <summary> /// /// </summary> /// <param name="logger"> /// /// </param> /// <param name="travelContext"> /// /// </param> /// <remarks> /// Last modification: /// Add logger. /// </remarks> public TravelRepository(ILogger <TravelRepository> logger, TravelContext travelContext) { Logger = logger; TravelContext = travelContext; }
public LoginController(TravelContext context) { _context = context; }
public ReviewsController(TravelContext db) { _db = db; }