public ActionResult Approve(int id) { VacationDbContext context = new VacationDbContext(); BaseTimeOff timeOff = context.PaidTimeOffs.Find(id); timeOff.IsApproved = true; context.SaveChanges(); context.Dispose(); return(RedirectToAction("../TimeOffs/Index")); }
public async Task SaveVacationPlanInDb() { DbContextOptions <VacationDbContext> options = new DbContextOptionsBuilder <VacationDbContext>() .UseInMemoryDatabase("SavingPlanInDb") .Options; City testCity = new City(); testCity.ID = 1; testCity.Name = "Seattle"; testCity.Description = "Test"; testCity.ImageURL = "test.url"; testCity.Hot = 0; testCity.InUSA = 1; testCity.Price = 3; Hotel testHotel = new Hotel(); testHotel.ID = 1; testHotel.CityID = 1; testHotel.Name = "Seattle Hotel"; testHotel.Price = 3; Activity testActivity = new Activity(); testActivity.ID = 1; testActivity.Name = "Seattle Strolling"; testActivity.Outdoors = 1; testActivity.FamilyFriendly = 0; using (VacationDbContext context = new VacationDbContext(options)) { Plan testPlan = new Plan(); testPlan.City = testCity; testPlan.Hotel = testHotel; testPlan.Activity = testActivity; // Convert RecommendationCode to a string type testPlan.RecommendationCode = testCity.ID + testHotel.ID + testActivity.ID; context.SavedVacation.Add(testPlan); await context.SaveChangesAsync(); Plan result = await context.SavedVacation.FirstOrDefaultAsync(x => x.City == testPlan.City); Assert.Equal("Seattle", result.City.Name); Assert.Equal("Seattle Hotel", result.Hotel.Name); Assert.Equal("Seattle Strolling", result.Activity.Name); Assert.Equal(3, result.RecommendationCode); } }
public async Task CanGetPlan() { DbContextOptions <VacationDbContext> options = new DbContextOptionsBuilder <VacationDbContext>() .UseInMemoryDatabase("CanGetActivityInCity") .Options; using (VacationDbContext context = new VacationDbContext(options)) { PlanService service = new PlanService(context); City testCity = new City(); testCity.ID = 1; testCity.Name = "Seattle"; testCity.Description = "Test"; testCity.ImageURL = "test.url"; testCity.Hot = 0; testCity.InUSA = 1; testCity.Price = 3; context.City.Add(testCity); await context.SaveChangesAsync(); Hotel testHotel = new Hotel(); testHotel.CityID = 1; testHotel.Name = "Seattle Hotel"; testHotel.Price = 3; context.Hotel.Add(testHotel); await context.SaveChangesAsync(); Activity testActivity = new Activity(); testActivity.CityID = 1; testActivity.Name = "Seattle Strolling"; testActivity.Outdoors = 1; testActivity.FamilyFriendly = 0; context.Activity.Add(testActivity); await context.SaveChangesAsync(); Plan result = await service.GetPlan("1,0,3,0,1"); Assert.Equal("Seattle", result.City.Name); Assert.Equal("Seattle Hotel", result.Hotel.Name); Assert.Equal("Seattle Strolling", result.Activity.Name); } }
public async Task CanGetHotelsInCity() { DbContextOptions <VacationDbContext> options = new DbContextOptionsBuilder <VacationDbContext>() .UseInMemoryDatabase("CanGetHotelsInCity") .Options; using (VacationDbContext context = new VacationDbContext(options)) { PlanService service = new PlanService(context); Hotel testHotel = new Hotel(); testHotel.CityID = 1; testHotel.Name = "Seattle Hotel"; testHotel.Price = 3; context.Hotel.Add(testHotel); await context.SaveChangesAsync(); Hotel result = await service.GetHotelInCity(1); Assert.Equal("Seattle Hotel", result.Name); } }
public async Task CanGetActivityInCity() { DbContextOptions <VacationDbContext> options = new DbContextOptionsBuilder <VacationDbContext>() .UseInMemoryDatabase("CanGetActivityInCity") .Options; using (VacationDbContext context = new VacationDbContext(options)) { PlanService service = new PlanService(context); Activity testActivity = new Activity(); testActivity.CityID = 3; testActivity.Name = "Seattle Strolling"; testActivity.Outdoors = 1; testActivity.FamilyFriendly = 0; context.Activity.Add(testActivity); await context.SaveChangesAsync(); Activity result = await service.GetActivityInCity(3); Assert.Equal("Seattle Strolling", result.Name); } }
public CityService(VacationDbContext context) { _context = context; }
public PopularService(VacationDbContext context) { _context = context; }
public SickTimeOffController(VacationDbContext context) : base(context, context.PaidTimeOffs) { }
public TeamsController(VacationDbContext context) { _context = context; }
public PlanService(VacationDbContext context) { _context = context; }
public ProjectsController(VacationDbContext context) { _context = context; }
public UnpaidTimeOffController(VacationDbContext context) : base(context, context.UnpaidTimeOffs) { }
public TimeOffController(VacationDbContext context, DbSet <T> items) { _context = context; _items = items; }