diff options
author | Sergey Chebotar <s.chebotar@gmail.com> | 2023-06-03 07:41:46 +0300 |
---|---|---|
committer | Sergey Chebotar <s.chebotar@gmail.com> | 2023-06-03 07:41:46 +0300 |
commit | 3bade8859bcd938b85c39ab16eaa0dcf8e01535f (patch) | |
tree | 9157e3f27d8007206c12d5ec0cf5f2936295c0e7 /Models | |
parent | 81c1fc0c14253457c3c4fc24735e787ace1db70b (diff) |
Mass refactoring
Diffstat (limited to 'Models')
-rw-r--r-- | Models/DataContext.cs | 8 | ||||
-rw-r--r-- | Models/Figure.cs | 19 | ||||
-rw-r--r-- | Models/LoginModel.cs | 2 | ||||
-rw-r--r-- | Models/Product.cs | 15 | ||||
-rw-r--r-- | Models/UnderwearBundle.cs | 11 |
5 files changed, 30 insertions, 25 deletions
diff --git a/Models/DataContext.cs b/Models/DataContext.cs index 23e80ab..9fd10e0 100644 --- a/Models/DataContext.cs +++ b/Models/DataContext.cs @@ -14,13 +14,7 @@ namespace MyDarling.Models { opts.UseSqlite(configuration.GetConnectionString("MyDarlingDb")); } - - // protected override void OnModelCreating(ModelBuilder builder) - // { - // builder.Entity<UnderwearBundle>().HasMany(b => b.Figures).WithOne(); - // } - - public DbSet<UnderwearBundle> UnderwearBundles => Set<UnderwearBundle>(); + public DbSet<Product> Products => Set<Product>(); public DbSet<Figure> Figures => Set<Figure>(); } }
\ No newline at end of file diff --git a/Models/Figure.cs b/Models/Figure.cs index f63d842..8bbc591 100644 --- a/Models/Figure.cs +++ b/Models/Figure.cs @@ -1,9 +1,16 @@ namespace MyDarling.Models { - public class Figure - { - public int Id { get; set; } - public string Description { get; set; } = string.Empty; - public string FilePath { get; set; } = string.Empty; - } + public class Figure + { + public string Id { get; set; } + public string Description { get; set; } = string.Empty; + public string ProductId { get; set; } + + public Figure(string description, string productId) + { + Id = Guid.NewGuid().ToString(); + Description = description; + ProductId = productId; + } + } }
\ No newline at end of file diff --git a/Models/LoginModel.cs b/Models/LoginModel.cs index 93485c8..6592135 100644 --- a/Models/LoginModel.cs +++ b/Models/LoginModel.cs @@ -9,5 +9,5 @@ public class LoginModel [Required] public string? Password { get; set; } - public string ReturnUrl { get; set; } = "/Bundle"; + public string ReturnUrl { get; set; } = "/Products"; }
\ No newline at end of file diff --git a/Models/Product.cs b/Models/Product.cs new file mode 100644 index 0000000..efb691c --- /dev/null +++ b/Models/Product.cs @@ -0,0 +1,15 @@ +namespace MyDarling.Models +{ + public class Product + { + public string Id { get; set; } + public string Name { get; set; } = string.Empty; + public List<Figure> Figures { get; set; } = new List<Figure>(); + public string Description { get; set; } = string.Empty; + public decimal Price { get; set; } = 1000M; + public Product() + { + Id = Guid.NewGuid().ToString(); + } + } +}
\ No newline at end of file diff --git a/Models/UnderwearBundle.cs b/Models/UnderwearBundle.cs deleted file mode 100644 index 1f451e6..0000000 --- a/Models/UnderwearBundle.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace MyDarling.Models -{ - public class UnderwearBundle - { - public int Id { get; set; } - public string Name { get; set; } = "My Darling Bundle"; - public List<Figure> Figures { get; set; } = new List<Figure>(); - public string Description { get; set; } = string.Empty; - public decimal Price { get; set; } - } -}
\ No newline at end of file |