Code clean up
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using GazpromApp.Models;
|
||||
using GazpromApp.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace GazpromApp.Utils;
|
||||
|
||||
public class AppDbContext : DbContext
|
||||
{
|
||||
public DbSet<Models.Image> Image { get; set; }
|
||||
public DbSet<Image> Image { get; set; }
|
||||
public DbSet<Equipment> Equipment { get; set; }
|
||||
public DbSet<Models.Point> Point { get; set; }
|
||||
public DbSet<Point> Point { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
@@ -20,7 +20,7 @@ public class AppDbContext : DbContext
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
// Images
|
||||
modelBuilder.Entity<Models.Point>()
|
||||
modelBuilder.Entity<Point>()
|
||||
.HasMany(e => e.Images)
|
||||
.WithMany(e => e.Points);
|
||||
|
||||
@@ -30,7 +30,7 @@ public class AppDbContext : DbContext
|
||||
.HasForeignKey(e => e.ImageId);
|
||||
|
||||
// Properties
|
||||
modelBuilder.Entity<Models.Point>()
|
||||
modelBuilder.Entity<Point>()
|
||||
.HasMany(e => e.Properties)
|
||||
.WithMany(e => e.Points);
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using GazpromApp.Enums;
|
||||
using GazpromApp.Models;
|
||||
using GazpromApp.ViewModels;
|
||||
|
||||
namespace GazpromApp.Utils;
|
||||
@@ -19,11 +18,11 @@ public static class DateCalculator
|
||||
return [inspection.InspectionDate.DateTime, firstFutureDate];
|
||||
}
|
||||
|
||||
DateTime futureDate = Enumerable.Range(1, int.MaxValue)
|
||||
var futureDate = Enumerable.Range(1, int.MaxValue)
|
||||
.Select(i => AddPeriod(inspection.InspectionDate.DateTime, inspection.PeriodType, inspection.PeriodValue * i))
|
||||
.First(d => d > today);
|
||||
|
||||
DateTime pastDate = SubtractPeriod(futureDate, inspection.PeriodType, inspection.PeriodValue);
|
||||
var pastDate = SubtractPeriod(futureDate, inspection.PeriodType, inspection.PeriodValue);
|
||||
|
||||
return [pastDate, futureDate];
|
||||
}
|
||||
@@ -36,6 +35,7 @@ public static class DateCalculator
|
||||
PeriodType.Week => date.AddDays(value * 7),
|
||||
PeriodType.Month => date.AddDays(value * 30.436875), // Avg days/month
|
||||
PeriodType.Year => date.AddDays(value * 365.2425), // Avg days/year (incl. leap years)
|
||||
PeriodType.Unknown => throw new ArgumentException("Invalid period type"),
|
||||
_ => throw new ArgumentException("Invalid period type")
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user