Business Logic update
This commit is contained in:
@@ -14,7 +14,6 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Business\Sales\" />
|
||||
<Folder Include="Business\UserManagment\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user