Added constructors and base classses to Models

This commit is contained in:
batgo6o
2021-03-14 10:17:13 +02:00
parent b45909ab63
commit 8578b62989
16 changed files with 376 additions and 236 deletions

View File

@@ -1,14 +1,17 @@
using Models;
using Models.Models;
using System.Linq;
namespace LuminousSales.Business
{
public class UsersController
{
private LuminousContext userContext;
private LuminousContext contex;
public UsersController()
{
this.userContext = new LuminousContext();
this.contex = new LuminousContext();
}
}
}

View File

@@ -1,4 +1,5 @@
using System;
using LuminousSales.Business;
using System;
namespace Display
{
@@ -6,7 +7,6 @@ namespace Display
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}

View File

@@ -32,7 +32,18 @@ namespace Models
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<User>()
.HasIndex(user => new { user.Name, user.Password })
.IsUnique(true);
modelBuilder.Entity<Role>()
.HasIndex(role => new { role.Name })
.IsUnique(true);
modelBuilder.Entity<Permission>()
.HasIndex(permission => new { permission.Name })
.IsUnique(true);
modelBuilder.Entity<Product>()
.HasIndex(product => new { product.Name })
.IsUnique(true);
}
}
}

View File

@@ -10,7 +10,7 @@ using Models;
namespace Data.Migrations
{
[DbContext(typeof(LuminousContext))]
[Migration("20210310234527_IntialMigration")]
[Migration("20210314081427_IntialMigration")]
partial class IntialMigration
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -28,19 +28,17 @@ namespace Data.Migrations
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<double>("Amount")
.HasColumnType("float");
b.Property<byte[]>("Time")
.IsConcurrencyToken()
.IsRequired()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("rowversion");
b.Property<int?>("ProductId")
.HasColumnType("int");
b.Property<int?>("UserId")
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ProductId");
b.HasIndex("UserId");
b.ToTable("Deal");
@@ -54,10 +52,19 @@ namespace Data.Migrations
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int?>("RoleId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("Name")
.IsUnique();
b.HasIndex("RoleId");
b.ToTable("Permission");
});
@@ -71,14 +78,28 @@ namespace Data.Migrations
b.Property<double>("AmountInStock")
.HasColumnType("float");
b.Property<int?>("DealId")
.HasColumnType("int");
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<double>("Price")
.HasColumnType("float");
b.Property<int?>("StockId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("DealId");
b.HasIndex("Name")
.IsUnique();
b.HasIndex("StockId");
b.ToTable("Product");
});
@@ -90,14 +111,13 @@ namespace Data.Migrations
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.Property<int?>("PermissionId")
.HasColumnType("int");
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("PermissionId");
b.HasIndex("Name")
.IsUnique();
b.ToTable("Role");
});
@@ -109,19 +129,17 @@ namespace Data.Migrations
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<double>("Amount")
.HasColumnType("float");
b.Property<byte[]>("Time")
.IsConcurrencyToken()
.IsRequired()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("rowversion");
b.Property<int?>("ProductId")
.HasColumnType("int");
b.Property<int?>("UserId")
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ProductId");
b.HasIndex("UserId");
b.ToTable("Stock");
@@ -135,55 +153,69 @@ namespace Data.Migrations
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("Passcode")
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int?>("UsersRolesId")
b.Property<int>("RoleId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UsersRolesId");
b.HasIndex("RoleId");
b.HasIndex("Name", "Password")
.IsUnique();
b.ToTable("User");
});
modelBuilder.Entity("Models.Models.Deal", b =>
{
b.HasOne("Models.Models.Product", null)
.WithMany("Deals")
.HasForeignKey("ProductId");
b.HasOne("Models.Models.User", "User")
.WithMany()
.HasForeignKey("UserId");
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Models.Models.Role", b =>
modelBuilder.Entity("Models.Models.Permission", b =>
{
b.HasOne("Models.Models.Permission", null)
.WithMany("Role")
.HasForeignKey("PermissionId");
b.HasOne("Models.Models.Role", null)
.WithMany("Permissions")
.HasForeignKey("RoleId");
});
modelBuilder.Entity("Models.Models.Product", b =>
{
b.HasOne("Models.Models.Deal", null)
.WithMany("Products")
.HasForeignKey("DealId");
b.HasOne("Models.Models.Stock", null)
.WithMany("Products")
.HasForeignKey("StockId");
});
modelBuilder.Entity("Models.Models.Stock", b =>
{
b.HasOne("Models.Models.Product", null)
.WithMany("Stocks")
.HasForeignKey("ProductId");
b.HasOne("Models.Models.User", "User")
.WithMany()
.HasForeignKey("UserId");
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Models.Models.User", b =>
{
b.HasOne("Models.Models.Role", "UsersRoles")
b.HasOne("Models.Models.Role", "Role")
.WithMany()
.HasForeignKey("UsersRolesId");
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}

View File

@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore.Migrations;
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Data.Migrations
{
@@ -6,50 +7,35 @@ namespace Data.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Permission",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Permission", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Product",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(nullable: true),
Price = table.Column<double>(nullable: false),
AmountInStock = table.Column<double>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Product", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Role",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(nullable: true),
PermissionId = table.Column<int>(nullable: true)
Name = table.Column<string>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Role", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Permission",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(nullable: false),
RoleId = table.Column<int>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Permission", x => x.Id);
table.ForeignKey(
name: "FK_Role_Permission_PermissionId",
column: x => x.PermissionId,
principalTable: "Permission",
name: "FK_Permission_Role_RoleId",
column: x => x.RoleId,
principalTable: "Role",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
@@ -60,19 +46,19 @@ namespace Data.Migrations
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(nullable: true),
Passcode = table.Column<string>(nullable: true),
UsersRolesId = table.Column<int>(nullable: true)
Name = table.Column<string>(nullable: false),
Password = table.Column<string>(nullable: false),
RoleId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_User", x => x.Id);
table.ForeignKey(
name: "FK_User_Role_UsersRolesId",
column: x => x.UsersRolesId,
name: "FK_User_Role_RoleId",
column: x => x.RoleId,
principalTable: "Role",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
@@ -81,25 +67,18 @@ namespace Data.Migrations
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UserId = table.Column<int>(nullable: true),
Amount = table.Column<double>(nullable: false),
ProductId = table.Column<int>(nullable: true)
UserId = table.Column<int>(nullable: false),
Time = table.Column<byte[]>(rowVersion: true, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Deal", x => x.Id);
table.ForeignKey(
name: "FK_Deal_Product_ProductId",
column: x => x.ProductId,
principalTable: "Product",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Deal_User_UserId",
column: x => x.UserId,
principalTable: "User",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
@@ -108,31 +87,48 @@ namespace Data.Migrations
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UserId = table.Column<int>(nullable: true),
Amount = table.Column<double>(nullable: false),
ProductId = table.Column<int>(nullable: true)
UserId = table.Column<int>(nullable: false),
Time = table.Column<byte[]>(rowVersion: true, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Stock", x => x.Id);
table.ForeignKey(
name: "FK_Stock_Product_ProductId",
column: x => x.ProductId,
principalTable: "Product",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Stock_User_UserId",
column: x => x.UserId,
principalTable: "User",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Deal_ProductId",
table: "Deal",
column: "ProductId");
migrationBuilder.CreateTable(
name: "Product",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(nullable: false),
Price = table.Column<double>(nullable: false),
AmountInStock = table.Column<double>(nullable: false),
DealId = table.Column<int>(nullable: true),
StockId = table.Column<int>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Product", x => x.Id);
table.ForeignKey(
name: "FK_Product_Deal_DealId",
column: x => x.DealId,
principalTable: "Deal",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Product_Stock_StockId",
column: x => x.StockId,
principalTable: "Stock",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_Deal_UserId",
@@ -140,14 +136,37 @@ namespace Data.Migrations
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Role_PermissionId",
table: "Role",
column: "PermissionId");
name: "IX_Permission_Name",
table: "Permission",
column: "Name",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Stock_ProductId",
table: "Stock",
column: "ProductId");
name: "IX_Permission_RoleId",
table: "Permission",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "IX_Product_DealId",
table: "Product",
column: "DealId");
migrationBuilder.CreateIndex(
name: "IX_Product_Name",
table: "Product",
column: "Name",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Product_StockId",
table: "Product",
column: "StockId");
migrationBuilder.CreateIndex(
name: "IX_Role_Name",
table: "Role",
column: "Name",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Stock_UserId",
@@ -155,30 +174,36 @@ namespace Data.Migrations
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_User_UsersRolesId",
name: "IX_User_RoleId",
table: "User",
column: "UsersRolesId");
column: "RoleId");
migrationBuilder.CreateIndex(
name: "IX_User_Name_Password",
table: "User",
columns: new[] { "Name", "Password" },
unique: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Permission");
migrationBuilder.DropTable(
name: "Product");
migrationBuilder.DropTable(
name: "Deal");
migrationBuilder.DropTable(
name: "Stock");
migrationBuilder.DropTable(
name: "Product");
migrationBuilder.DropTable(
name: "User");
migrationBuilder.DropTable(
name: "Role");
migrationBuilder.DropTable(
name: "Permission");
}
}
}

View File

@@ -26,19 +26,17 @@ namespace Data.Migrations
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<double>("Amount")
.HasColumnType("float");
b.Property<byte[]>("Time")
.IsConcurrencyToken()
.IsRequired()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("rowversion");
b.Property<int?>("ProductId")
.HasColumnType("int");
b.Property<int?>("UserId")
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ProductId");
b.HasIndex("UserId");
b.ToTable("Deal");
@@ -52,10 +50,19 @@ namespace Data.Migrations
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int?>("RoleId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("Name")
.IsUnique();
b.HasIndex("RoleId");
b.ToTable("Permission");
});
@@ -69,14 +76,28 @@ namespace Data.Migrations
b.Property<double>("AmountInStock")
.HasColumnType("float");
b.Property<int?>("DealId")
.HasColumnType("int");
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<double>("Price")
.HasColumnType("float");
b.Property<int?>("StockId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("DealId");
b.HasIndex("Name")
.IsUnique();
b.HasIndex("StockId");
b.ToTable("Product");
});
@@ -88,14 +109,13 @@ namespace Data.Migrations
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.Property<int?>("PermissionId")
.HasColumnType("int");
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("PermissionId");
b.HasIndex("Name")
.IsUnique();
b.ToTable("Role");
});
@@ -107,19 +127,17 @@ namespace Data.Migrations
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<double>("Amount")
.HasColumnType("float");
b.Property<byte[]>("Time")
.IsConcurrencyToken()
.IsRequired()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("rowversion");
b.Property<int?>("ProductId")
.HasColumnType("int");
b.Property<int?>("UserId")
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ProductId");
b.HasIndex("UserId");
b.ToTable("Stock");
@@ -133,55 +151,69 @@ namespace Data.Migrations
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("Passcode")
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int?>("UsersRolesId")
b.Property<int>("RoleId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UsersRolesId");
b.HasIndex("RoleId");
b.HasIndex("Name", "Password")
.IsUnique();
b.ToTable("User");
});
modelBuilder.Entity("Models.Models.Deal", b =>
{
b.HasOne("Models.Models.Product", null)
.WithMany("Deals")
.HasForeignKey("ProductId");
b.HasOne("Models.Models.User", "User")
.WithMany()
.HasForeignKey("UserId");
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Models.Models.Role", b =>
modelBuilder.Entity("Models.Models.Permission", b =>
{
b.HasOne("Models.Models.Permission", null)
.WithMany("Role")
.HasForeignKey("PermissionId");
b.HasOne("Models.Models.Role", null)
.WithMany("Permissions")
.HasForeignKey("RoleId");
});
modelBuilder.Entity("Models.Models.Product", b =>
{
b.HasOne("Models.Models.Deal", null)
.WithMany("Products")
.HasForeignKey("DealId");
b.HasOne("Models.Models.Stock", null)
.WithMany("Products")
.HasForeignKey("StockId");
});
modelBuilder.Entity("Models.Models.Stock", b =>
{
b.HasOne("Models.Models.Product", null)
.WithMany("Stocks")
.HasForeignKey("ProductId");
b.HasOne("Models.Models.User", "User")
.WithMany()
.HasForeignKey("UserId");
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Models.Models.User", b =>
{
b.HasOne("Models.Models.Role", "UsersRoles")
b.HasOne("Models.Models.Role", "Role")
.WithMany()
.HasForeignKey("UsersRolesId");
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}

View File

@@ -0,0 +1,30 @@
using Models.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;
namespace Data.Base
{
public abstract class BaseSales
{
protected BaseSales()
{
}
protected BaseSales(User User, ICollection<Product> Products)
{
this.User = User;
this.Products = Products;
}
[Key]
public int Id { get; set; }
[Required]
public virtual User User { get; set; }
[Required]
public virtual ICollection<Product> Products { get; set; }
[Timestamp]
[Required]
public byte[] Time { get; set; }
}
}

View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;
namespace Data.Base
{
public abstract class BaseUserManagmentEntity
{
public BaseUserManagmentEntity(){}
protected BaseUserManagmentEntity(string Name)
{
this.Name = Name;
}
[Key]
public int Id { get; set; }
[Required]
public string Name { get; set; }
}
}

View File

@@ -1,17 +1,13 @@
using Models.Models.Interfaces;
using Data.Base;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Models.Models
{
public class Deal : IBaseSalesProperties
public class Deal : BaseSales
{
[Key]
public int Id { get; set; }
public User User { get; set; }
public double Amount { get; set; }
[Timestamp]
public byte[] time;
public Deal() : base(){}
public Deal(User User, ICollection<Product> Products) : base(User, Products){}
}
}

View File

@@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Models.Models.Interfaces
{
public interface IBaseProperties
{
int Id { get; set; }
string Name { get; set; }
}
}

View File

@@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;
namespace Models.Models.Interfaces
{
interface IBaseSalesProperties
{
User User { get; set; }
double Amount { get; set; }
}
}

View File

@@ -1,14 +1,12 @@
using Models.Models.Interfaces;
using Data.Base;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Models.Models
{
public class Permission : IBaseProperties
public class Permission : BaseUserManagmentEntity
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
public virtual ICollection<Role> Role { get; set; }
public Permission() : base(){}
public Permission(string Name) : base(Name){}
}
}

View File

@@ -1,17 +1,30 @@
using Models.Models.Interfaces;
using System.Collections.Generic;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Models.Models
{
public class Product : IBaseProperties
public class Product
{
public Product(){}
public Product(string Name, double Price)
{
this.Name = Name;
this.Price = Price;
this.AmountInStock = 0;
}
public Product(string Name, double Price, double AmountInStock)
{
this.Name = Name;
this.Price = Price;
this.AmountInStock = AmountInStock;
}
[Key]
public int Id { get; set; }
[Required]
public string Name { get; set; }
[Required]
public double Price { get; set; }
[Required]
public double AmountInStock { get; set; }
public virtual ICollection<Deal> Deals { get; set; }
public virtual ICollection<Stock> Stocks { get; set; }
}
}

View File

@@ -1,13 +1,17 @@
using Models.Models.Interfaces;
using Data.Base;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Models.Models
{
public class Role : IBaseProperties
public class Role : BaseUserManagmentEntity
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
public Role() : base(){}
public Role(string Name, ICollection<Permission> Permissions) : base(Name)
{
this.Permissions = Permissions;
}
[Required]
public virtual ICollection<Permission> Permissions { get; set; }
}
}

View File

@@ -1,4 +1,4 @@
using Models.Models.Interfaces;
using Data.Base;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
@@ -6,13 +6,9 @@ using System.Text;
namespace Models.Models
{
public class Stock : IBaseSalesProperties
public class Stock : BaseSales
{
[Key]
public int Id { get; set; }
public User User { get; set; }
public double Amount { get; set; }
[Timestamp]
public byte[] time;
public Stock() : base(){}
public Stock(User User, ICollection<Product> Products) : base(User, Products){}
}
}

View File

@@ -1,4 +1,4 @@
using Models.Models.Interfaces;
using Data.Base;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
@@ -6,12 +6,17 @@ using System.Text;
namespace Models.Models
{
public class User : IBaseProperties
public class User : BaseUserManagmentEntity
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
public string Passcode { get; set; }
public virtual Role UsersRoles { get; set; }
public User() : base() { }
public User(string Name, string Password, Role Role) : base(Name)
{
this.Password = Password;
this.Role = Role;
}
[Required]
public string Password { get; set; }
[Required]
public virtual Role Role { get; set; }
}
}