Ejemplo n.º 1
0
        public async Task Test_DatabaseService_Add_And_Remove_BafuSurfspot()
        {
            // Arrange
            var bafuSurfSpot = new BafuSurfSpot()
            {
                Url = "Bafu Test Url", Name = "Bafu Test Name", Outflow = 250
            };
            var dbService = new DatabaseService();

            // Act
            await dbService.AddBafuSurfSpotAsync(bafuSurfSpot);

            var allBafuSurfSpots = await dbService.GetAllBafuSurfSpotsAsync();

            // Assert
            allBafuSurfSpots.Any(s => s.Url == bafuSurfSpot.Url).Should().BeTrue();

            // Act
            await dbService.RemoveBafuSurfSpotAsync(bafuSurfSpot);

            allBafuSurfSpots = await dbService.GetAllBafuSurfSpotsAsync();

            // Assert
            allBafuSurfSpots.Any(s => s.Url == bafuSurfSpot.Url).Should().BeFalse();
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (!id.HasValue)
            {
                return(NotFound());
            }

            BafuSurfSpot = await _dataBaseService.GetBafuSurfSpotAsync(id.Value);

            if (BafuSurfSpot == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (!id.HasValue)
            {
                return(NotFound());
            }

            BafuSurfSpot = await _dataBaseService.GetBafuSurfSpotAsync(id.Value);

            if (BafuSurfSpot != null)
            {
                await _dataBaseService.RemoveBafuSurfSpotAsync(BafuSurfSpot);
            }

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 4
0
 public bool IsFiring(BafuData bafuData, BafuSurfSpot bafuSurfSpot)
 {
     return(bafuData.OutflowCurrent > bafuSurfSpot.Outflow || bafuData.OutflowMax24hours > bafuSurfSpot.Outflow);
 }
Ejemplo n.º 5
0
 public Task RemoveBafuSurfSpotAsync(BafuSurfSpot bafuSurfSpot)
 {
     using var db = new SurfsUpDbContext();
     db.Remove(bafuSurfSpot);
     return(db.SaveChangesAsync());
 }
Ejemplo n.º 6
0
 public Task ChangeBafuSurfSpotAsync(BafuSurfSpot bafuSurfSpot)
 {
     using var db = new SurfsUpDbContext();
     db.Attach(bafuSurfSpot).State = EntityState.Modified;
     return(db.SaveChangesAsync());
 }