Small changes

This commit is contained in:
Dimitar Byalkov
2021-03-20 17:11:27 +02:00
parent e3b1409b69
commit e404892b4a
5 changed files with 37 additions and 8 deletions

View File

@@ -180,7 +180,7 @@ namespace Business.Business.UserManagment
public User ValidatePassword(string password) public User ValidatePassword(string password)
{ {
var user = context.User.FirstOrDefault(); var user = context.User.FirstOrDefault(x => x.Password == password);
if (user == null) if (user == null)
{ {
throw new ArgumentException("Invalid User!"); throw new ArgumentException("Invalid User!");

View File

@@ -43,6 +43,7 @@ namespace Display
string userName, password; string userName, password;
InitialUserInput(out userName, out password); InitialUserInput(out userName, out password);
uc.RegisterItem(userName, password); uc.RegisterItem(userName, password);
Console.WriteLine("Registration succesful!");
} }
} }
catch (Exception e) catch (Exception e)

View File

@@ -57,6 +57,9 @@ namespace Display.Views
bool running = true; bool running = true;
while (running) while (running)
{ {
Console.WriteLine();
Console.WriteLine("=== ADMINISTRATION ===");
Console.WriteLine("0. Back");
Console.WriteLine(); Console.WriteLine();
Console.WriteLine("User Managment"); Console.WriteLine("User Managment");
Console.WriteLine("1. GetAll"); Console.WriteLine("1. GetAll");
@@ -70,8 +73,7 @@ namespace Display.Views
Console.WriteLine(); Console.WriteLine();
Console.WriteLine("Product Managment"); Console.WriteLine("Product Managment");
Console.WriteLine("9. AddItem"); Console.WriteLine("9. AddItem");
Console.WriteLine(); Console.WriteLine("10. GetAllItems");
Console.WriteLine("10. Back");
Console.Write("> "); Console.Write("> ");
try try
{ {
@@ -106,6 +108,9 @@ namespace Display.Views
AddItem(); AddItem();
break; break;
case 10: case 10:
GetAllItems();
break;
case 0:
running = false; running = false;
break; break;
default: default:
@@ -120,14 +125,33 @@ namespace Display.Views
} }
} }
private void GetAllItems()
{
try
{
Console.WriteLine("Getting all items...");
Console.WriteLine("ID - Name - Amount - Price");
foreach (var item in productctrl.GetAll())
{
Console.WriteLine($"{item.Id} - {item.Name} - {item.AmountInStock} - {item.Price} ");
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
public void GetAllUsers() public void GetAllUsers()
{ {
try try
{ {
Console.WriteLine("Getting all users..."); Console.WriteLine("Getting all users...");
Console.WriteLine("User ID - Username - Role");
foreach (var item in userctl.GetAll()) foreach (var item in userctl.GetAll())
{ {
Console.WriteLine($"{item.Id} {item.Name} {item.Role} "); Console.WriteLine($"{item.Id} - {item.Name} - {item.Role} ");
} }
} }
catch (Exception e) catch (Exception e)

View File

@@ -54,11 +54,13 @@ namespace Display.Views
bool running = true; bool running = true;
while (running) while (running)
{ {
Console.WriteLine();
Console.WriteLine("=== SALES ===");
Console.WriteLine("0. Back");
Console.WriteLine(); Console.WriteLine();
Console.WriteLine("Deal Managment"); Console.WriteLine("Deal Managment");
Console.WriteLine("1. Search"); Console.WriteLine("1. Search");
Console.WriteLine("2. Sale"); Console.WriteLine("2. Sale");
Console.WriteLine("3. Back");
Console.Write("> "); Console.Write("> ");
try try
{ {
@@ -71,7 +73,7 @@ namespace Display.Views
case 2: case 2:
SaleItem(); SaleItem();
break; break;
case 3: case 0:
running = false; running = false;
break; break;
default: default:

View File

@@ -54,6 +54,9 @@ namespace Display.Views
bool running = true; bool running = true;
while (running) while (running)
{ {
Console.WriteLine();
Console.WriteLine("=== STOCK ===");
Console.WriteLine("0. Back");
Console.WriteLine(); Console.WriteLine();
Console.WriteLine("Stock Managment"); Console.WriteLine("Stock Managment");
Console.WriteLine("1. GetAll"); Console.WriteLine("1. GetAll");
@@ -61,7 +64,6 @@ namespace Display.Views
Console.WriteLine("3. GetByTime"); Console.WriteLine("3. GetByTime");
Console.WriteLine("4. Add"); Console.WriteLine("4. Add");
Console.WriteLine("5. Delete"); Console.WriteLine("5. Delete");
Console.WriteLine("6. Back");
Console.Write("> "); Console.Write("> ");
try try
{ {
@@ -83,7 +85,7 @@ namespace Display.Views
case 5: case 5:
Delete(); Delete();
break; break;
case 6: case 0:
running = false; running = false;
break; break;
default: default: