Business Logic update

This commit is contained in:
batgo6o
2021-03-14 13:29:42 +02:00
parent 5924ee0dd9
commit 2af190c291
4 changed files with 61 additions and 15 deletions

View File

@@ -14,7 +14,6 @@
<ItemGroup>
<Folder Include="Business\Sales\" />
<Folder Include="Business\UserManagment\" />
</ItemGroup>
</Project>

View File

@@ -1,17 +1,7 @@
using Models;
using Models.Models;
using System.Linq;

namespace LuminousSales.Business
{
public class UsersController
public class MainBusiness
{
private LuminousContext contex;
public UsersController()
{
this.contex = new LuminousContext();
}
}
}

View File

@@ -0,0 +1,56 @@
using System;
using Models;
using System.Linq;
using Models.Models;
using System.Collections.Generic;
namespace Business.Business.UserManagment
{
public class CreateInitialUser
{
private LuminousContext context;
public void CreatePermissions()
{
using (context = new LuminousContext())
{
var admin = new Permission("Admin");
var roleChanger = new Permission("Role Changer");
var userCreation = new Permission("User Creation");
var report = new Permission("Report");
var stock = new Permission("Stock");
var sell = new Permission("Sell");
context.Permission.AddRange
(
admin,
roleChanger,
userCreation,
report,
stock,
sell
);
context.SaveChanges();
Console.WriteLine("Permissions were intialized");
}
}
public void CreateFirstRole(string Name, ICollection<Permission> Permissions)
{
using (context = new LuminousContext())
{
var firstRole = new Role(Name, Permissions);
context.Role.Add(firstRole);
context.SaveChanges();
}
}
public void CreateFirstUser(string Name, string Password, Role Role)
{
using (context = new LuminousContext())
{
var firstUser = new User(Name, Password, Role);
context.User.Add(firstUser);
context.SaveChanges();
}
}
}
}

View File

@@ -1,5 +1,5 @@
using LuminousSales.Business;
using System;
using System;
using Business.Business.UserManagment;
namespace Display
{
@@ -7,6 +7,7 @@ namespace Display
{
static void Main(string[] args)
{
var InitialCreation = new CreateInitialUser();
}
}
}