Presentaion, Views, CLI
This commit is contained in:
@@ -1,45 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Display
|
||||
{
|
||||
class InputHandler
|
||||
{
|
||||
public void CommandLineInterface()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
Console.WriteLine("Select action");
|
||||
string input = "";
|
||||
try
|
||||
{
|
||||
Console.Write("> ");
|
||||
input = Console.ReadLine();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
}
|
||||
switch (input)
|
||||
{
|
||||
case "sales": break;
|
||||
case "usermanagment": break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Sales()
|
||||
{
|
||||
try
|
||||
{
|
||||
Console.Write("> ");
|
||||
string input = Console.ReadLine();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -15,10 +15,25 @@ namespace Display
|
||||
try
|
||||
{
|
||||
var uc = new UserController();
|
||||
User currentUser = uc.ValidatePassword("admin123");
|
||||
Console.Write("Enter password: ");
|
||||
User currentUser = uc.ValidatePassword(Console.ReadLine());
|
||||
uc = new UserController(currentUser);
|
||||
var cv = new CashierView(currentUser);
|
||||
cv.SaleHandle();
|
||||
var view = new BaseView(currentUser);
|
||||
switch (currentUser.RoleId)
|
||||
{
|
||||
case 1:
|
||||
view = new CashierView(currentUser);
|
||||
break;
|
||||
case 2:
|
||||
view = new ManagerView(currentUser);
|
||||
break;
|
||||
case 3:
|
||||
view = new AdminView(currentUser);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
view.ActionHandle();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@@ -1,10 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Display.Sales
|
||||
{
|
||||
class Deal
|
||||
{
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Display.Sales
|
||||
{
|
||||
class Stock
|
||||
{
|
||||
//public void
|
||||
}
|
||||
}
|
@@ -17,7 +17,96 @@ namespace Display.Views
|
||||
public override void ShowAvaliableCommands()
|
||||
{
|
||||
base.ShowAvaliableCommands();
|
||||
Console.WriteLine("3. User Managment");
|
||||
Console.WriteLine("4. User Managment");
|
||||
}
|
||||
public override void ActionHandle()
|
||||
{
|
||||
ShowAvaliableCommands();
|
||||
Console.Write("> ");
|
||||
try
|
||||
{
|
||||
int input = int.Parse(Console.ReadLine());
|
||||
if (input == 0)
|
||||
{
|
||||
Environment.Exit(0);
|
||||
}
|
||||
else if (input == 1)
|
||||
{
|
||||
SaleHandle();
|
||||
}
|
||||
else if (input == 2)
|
||||
{
|
||||
ManageHandle();
|
||||
}
|
||||
else if (input == 3)
|
||||
{
|
||||
AdminHandle();
|
||||
}
|
||||
else Console.WriteLine("Invalid operation");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
}
|
||||
}
|
||||
public void AdminHandle()
|
||||
{
|
||||
bool running = true;
|
||||
while (running)
|
||||
{
|
||||
Console.WriteLine("1. GetAll");
|
||||
Console.WriteLine("2. Get");
|
||||
Console.WriteLine("3. GetByApproximateName");
|
||||
Console.WriteLine("4. RegisterItem");
|
||||
Console.WriteLine("5. UpdateRole");
|
||||
Console.WriteLine("6. UpdateName");
|
||||
Console.WriteLine("7. UpdatePassword");
|
||||
Console.WriteLine("8. Delete");
|
||||
Console.WriteLine("9. Exit");
|
||||
Console.Write("Your choice: ");
|
||||
try
|
||||
{
|
||||
int choice = int.Parse(Console.ReadLine());
|
||||
switch (choice)
|
||||
{
|
||||
case 1:
|
||||
GetAllUsers();
|
||||
break;
|
||||
case 2:
|
||||
Get();
|
||||
break;
|
||||
case 3:
|
||||
GetByApproximateName();
|
||||
break;
|
||||
case 4:
|
||||
RegisterItem();
|
||||
break;
|
||||
case 5:
|
||||
UpdateRole();
|
||||
break;
|
||||
case 6:
|
||||
UpdateName();
|
||||
break;
|
||||
case 7:
|
||||
UpdatePassword();
|
||||
break;
|
||||
case 8:
|
||||
Delete();
|
||||
break;
|
||||
case 9:
|
||||
running = false;
|
||||
break;
|
||||
default:
|
||||
Console.WriteLine("Invalid Option!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public void GetAllUsers()
|
||||
{
|
||||
|
@@ -18,18 +18,40 @@ namespace Display.Views
|
||||
}
|
||||
public virtual void ShowAvaliableCommands()
|
||||
{
|
||||
Console.WriteLine("0. Exit");
|
||||
Console.WriteLine("1. Sales");
|
||||
}
|
||||
public virtual void ActionHandle()
|
||||
{
|
||||
ShowAvaliableCommands();
|
||||
Console.Write("> ");
|
||||
try
|
||||
{
|
||||
int input = int.Parse(Console.ReadLine());
|
||||
if (input == 0)
|
||||
{
|
||||
Environment.Exit(0);
|
||||
}
|
||||
else if (input == 1)
|
||||
{
|
||||
SaleHandle();
|
||||
}
|
||||
else Console.WriteLine("Invalid operation");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
}
|
||||
}
|
||||
public void SaleHandle()
|
||||
{
|
||||
Deal deal = new Deal();
|
||||
Product product = new Product();
|
||||
while (true)
|
||||
bool running = true;
|
||||
while (running)
|
||||
{
|
||||
Console.WriteLine("1. Search");
|
||||
Console.WriteLine("2. Sale");
|
||||
Console.WriteLine("3. Exit");
|
||||
Console.Write("Your Choice: ");
|
||||
Console.Write("Your choice: ");
|
||||
try
|
||||
{
|
||||
int choice = int.Parse(Console.ReadLine());
|
||||
@@ -42,7 +64,7 @@ namespace Display.Views
|
||||
SaleItem();
|
||||
break;
|
||||
case 3:
|
||||
Environment.Exit(0);
|
||||
running = false;
|
||||
break;
|
||||
default:
|
||||
Console.WriteLine("Invalid Option!");
|
||||
|
@@ -20,6 +20,79 @@ namespace Display.Views
|
||||
base.ShowAvaliableCommands();
|
||||
Console.WriteLine("2. Stock");
|
||||
}
|
||||
public override void ActionHandle()
|
||||
{
|
||||
ShowAvaliableCommands();
|
||||
Console.Write("> ");
|
||||
try
|
||||
{
|
||||
int input = int.Parse(Console.ReadLine());
|
||||
if (input == 0)
|
||||
{
|
||||
Environment.Exit(0);
|
||||
}
|
||||
else if (input == 1)
|
||||
{
|
||||
SaleHandle();
|
||||
}
|
||||
else if (input == 2)
|
||||
{
|
||||
ManageHandle();
|
||||
}
|
||||
else Console.WriteLine("Invalid operation");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
}
|
||||
}
|
||||
public void ManageHandle()
|
||||
{
|
||||
bool running = true;
|
||||
while (running)
|
||||
{
|
||||
Console.WriteLine("1. GetAll");
|
||||
Console.WriteLine("2. Get");
|
||||
Console.WriteLine("3. GetByTime");
|
||||
Console.WriteLine("4. Add");
|
||||
Console.WriteLine("5. Delete");
|
||||
Console.WriteLine("6. Exit");
|
||||
Console.Write("Your choice: ");
|
||||
try
|
||||
{
|
||||
int choice = int.Parse(Console.ReadLine());
|
||||
switch (choice)
|
||||
{
|
||||
case 1:
|
||||
GetAll();
|
||||
break;
|
||||
case 2:
|
||||
Get();
|
||||
break;
|
||||
case 3:
|
||||
GetByTime();
|
||||
break;
|
||||
case 4:
|
||||
Add();
|
||||
break;
|
||||
case 5:
|
||||
Delete();
|
||||
break;
|
||||
case 6:
|
||||
running = false;
|
||||
break;
|
||||
default:
|
||||
Console.WriteLine("Invalid Option!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public void GetAll()
|
||||
{
|
||||
try
|
||||
@@ -39,13 +112,13 @@ namespace Display.Views
|
||||
|
||||
}
|
||||
|
||||
public void Get(int id)
|
||||
public void Get()
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
Console.WriteLine("Enter stock id...");
|
||||
id = int.Parse(Console.ReadLine());
|
||||
Console.Write("Enter stock id: ");
|
||||
int id = int.Parse(Console.ReadLine());
|
||||
stockctrl.Get(id);
|
||||
|
||||
}
|
||||
@@ -74,16 +147,24 @@ namespace Display.Views
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(int productId, double amount)
|
||||
public void Add()
|
||||
{
|
||||
try
|
||||
{
|
||||
Console.WriteLine("Adding stock by product id...");
|
||||
Console.WriteLine("Enter product id: ");
|
||||
productId = int.Parse(Console.ReadLine());
|
||||
Console.WriteLine("Enter stock amount:");
|
||||
amount = double.Parse(Console.ReadLine());
|
||||
stockctrl.Add(productId, amount);
|
||||
Console.Write("Enter product ID or name: ");
|
||||
string product = Console.ReadLine();
|
||||
Console.Write("Enter stock amount:");
|
||||
double amount = double.Parse(Console.ReadLine());
|
||||
bool result = int.TryParse(product, out int productId);
|
||||
if (result)
|
||||
{
|
||||
stockctrl.Add(productId, amount);
|
||||
}
|
||||
else
|
||||
{
|
||||
stockctrl.Add(product, amount);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -92,30 +173,13 @@ namespace Display.Views
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(string productName, double amount)
|
||||
public void Delete()
|
||||
{
|
||||
try
|
||||
{
|
||||
Console.WriteLine("Adding stock by product name...");
|
||||
Console.WriteLine("Enter product name: ");
|
||||
productName = Console.ReadLine();
|
||||
amount = double.Parse(Console.ReadLine());
|
||||
stockctrl.Add(productName, amount);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
Console.WriteLine(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void Delete(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
Console.WriteLine("Deleting stock");
|
||||
Console.WriteLine("Enter deal id: ");
|
||||
id = int.Parse(Console.ReadLine());
|
||||
Console.WriteLine("Deleting stock...");
|
||||
Console.Write("Enter deal id: ");
|
||||
int id = int.Parse(Console.ReadLine());
|
||||
dealctrl.Delete(id);
|
||||
}
|
||||
catch (Exception e)
|
||||
|
Reference in New Issue
Block a user