Views, Add Time in Deal & Stock
This commit is contained in:
Binary file not shown.
@@ -9,8 +9,8 @@ namespace Business.Business.Sales
|
|||||||
ICollection<T> GetAll();
|
ICollection<T> GetAll();
|
||||||
T Get(int id);
|
T Get(int id);
|
||||||
ICollection<T> GetByTime(DateTime startTime, DateTime endTime);
|
ICollection<T> GetByTime(DateTime startTime, DateTime endTime);
|
||||||
void Add(int productId, double Amount);
|
void Add(int productId, double Amount, DateTime time);
|
||||||
void Add(string productName, double Amount);
|
void Add(string productName, double Amount, DateTime time);
|
||||||
void Delete(int id);
|
void Delete(int id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,11 +16,11 @@ namespace Business.Business.Sales
|
|||||||
{
|
{
|
||||||
this.currentUser = currentUser;
|
this.currentUser = currentUser;
|
||||||
}
|
}
|
||||||
public void Add(int productId, double Amount)
|
public void Add(int productId, double Amount, DateTime time)
|
||||||
{
|
{
|
||||||
if (Amount > 0)
|
if (Amount > 0)
|
||||||
{
|
{
|
||||||
var deal = new Deal(currentUser.Id, productId, Amount);
|
var deal = new Deal(currentUser.Id, productId, Amount, time);
|
||||||
context.Deal.Add(deal);
|
context.Deal.Add(deal);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
}
|
}
|
||||||
@@ -30,17 +30,16 @@ namespace Business.Business.Sales
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Add(string productName, double Amount)
|
public void Add(string productName, double Amount, DateTime time)
|
||||||
{
|
{
|
||||||
if (Amount > 0)
|
if (Amount > 0)
|
||||||
{
|
{
|
||||||
productCtrl = new ProductController(currentUser);
|
productCtrl = new ProductController(currentUser);
|
||||||
var productId = productCtrl.Get(productName).Id;
|
var productId = productCtrl.Get(productName).Id;
|
||||||
var deal = new Deal(currentUser.Id, productId, Amount);
|
var deal = new Deal(currentUser.Id, productId, Amount, time);
|
||||||
context.Deal.Add(deal);
|
context.Deal.Add(deal);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new ArgumentException("Amount cannot be negative");
|
throw new ArgumentException("Amount cannot be negative");
|
||||||
|
@@ -56,13 +56,15 @@ namespace Business.Business.Sales
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Add(int productId, double Amount)
|
public void Add(int productId, double Amount, DateTime time)
|
||||||
{
|
{
|
||||||
if (currentUser.RoleId > 1)
|
if (currentUser.RoleId > 1)
|
||||||
{
|
{
|
||||||
if (Amount > 0)
|
if (Amount > 0)
|
||||||
{
|
{
|
||||||
var stock = new Stock(currentUser.Id, productId, Amount);
|
var stock = new Stock(currentUser.Id, productId, Amount, time);
|
||||||
|
productCtrl = new ProductController(currentUser);
|
||||||
|
productCtrl.Get(productId).AmountInStock += Amount;
|
||||||
context.Stock.Add(stock);
|
context.Stock.Add(stock);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
}
|
}
|
||||||
@@ -78,7 +80,7 @@ namespace Business.Business.Sales
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Add(string productName, double Amount)
|
public void Add(string productName, double Amount, DateTime time)
|
||||||
{
|
{
|
||||||
if (currentUser.RoleId > 1)
|
if (currentUser.RoleId > 1)
|
||||||
{
|
{
|
||||||
@@ -86,7 +88,8 @@ namespace Business.Business.Sales
|
|||||||
{
|
{
|
||||||
productCtrl = new ProductController(currentUser);
|
productCtrl = new ProductController(currentUser);
|
||||||
var productId = productCtrl.Get(productName).Id;
|
var productId = productCtrl.Get(productName).Id;
|
||||||
var stock = new Stock(currentUser.Id, productId, Amount);
|
var stock = new Stock(currentUser.Id, productId, Amount, time);
|
||||||
|
productCtrl.Get(productId).AmountInStock += Amount;
|
||||||
context.Stock.Add(stock);
|
context.Stock.Add(stock);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
@@ -17,9 +17,4 @@
|
|||||||
<ProjectReference Include="..\Models\Data.csproj" />
|
<ProjectReference Include="..\Models\Data.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Sales\" />
|
|
||||||
<Folder Include="UserManagment\" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
using Business.Business.UserManagment;
|
using Business.Business.UserManagment;
|
||||||
|
using Business.Business.UserManagment.Controllers;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Display.InitialSetup
|
namespace Display
|
||||||
{
|
{
|
||||||
public class InitialSetup
|
public class InitialSetup
|
||||||
{
|
{
|
||||||
@@ -11,9 +12,8 @@ namespace Display.InitialSetup
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
public string[] InitialUserInput()
|
public static void InitialUserInput(out string userName, out string password)
|
||||||
{
|
{
|
||||||
string userName = "", password = "";
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Console.Write("Enter username: ");
|
Console.Write("Enter username: ");
|
||||||
@@ -23,13 +23,13 @@ namespace Display.InitialSetup
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
userName = string.Empty;
|
||||||
|
password = string.Empty;
|
||||||
Console.WriteLine(e.Message);
|
Console.WriteLine(e.Message);
|
||||||
}
|
}
|
||||||
return new string[] { userName, password };
|
|
||||||
}
|
}
|
||||||
public void InitialRegistration()
|
public static void InitialRegistration(UserController uc)
|
||||||
{
|
{
|
||||||
var uc = new UserController();
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (uc.CheckIfUserEverCreated())
|
if (uc.CheckIfUserEverCreated())
|
||||||
@@ -38,7 +38,11 @@ namespace Display.InitialSetup
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uc.RegisterItem(InitialUserInput()[0], InitialUserInput()[1]);
|
RoleController rc = new RoleController();
|
||||||
|
rc.CreateInitialRoles();
|
||||||
|
string userName, password;
|
||||||
|
InitialUserInput(out userName, out password);
|
||||||
|
uc.RegisterItem(userName, password);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
@@ -15,6 +15,7 @@ namespace Display
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var uc = new UserController();
|
var uc = new UserController();
|
||||||
|
InitialSetup.InitialRegistration(uc);
|
||||||
Console.Write("Enter password: ");
|
Console.Write("Enter password: ");
|
||||||
User currentUser = uc.ValidatePassword(Console.ReadLine());
|
User currentUser = uc.ValidatePassword(Console.ReadLine());
|
||||||
uc = new UserController(currentUser);
|
uc = new UserController(currentUser);
|
||||||
@@ -33,6 +34,7 @@ namespace Display
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Console.WriteLine("Luminous Sales v0.1");
|
||||||
view.ActionHandle();
|
view.ActionHandle();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@@ -17,32 +17,35 @@ namespace Display.Views
|
|||||||
public override void ShowAvaliableCommands()
|
public override void ShowAvaliableCommands()
|
||||||
{
|
{
|
||||||
base.ShowAvaliableCommands();
|
base.ShowAvaliableCommands();
|
||||||
Console.WriteLine("4. User Managment");
|
Console.WriteLine("3. Administration");
|
||||||
}
|
}
|
||||||
public override void ActionHandle()
|
public override void ActionHandle()
|
||||||
{
|
{
|
||||||
ShowAvaliableCommands();
|
|
||||||
Console.Write("> ");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int input = int.Parse(Console.ReadLine());
|
while (true)
|
||||||
if (input == 0)
|
|
||||||
{
|
{
|
||||||
Environment.Exit(0);
|
ShowAvaliableCommands();
|
||||||
|
Console.Write("> ");
|
||||||
|
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");
|
||||||
}
|
}
|
||||||
else if (input == 1)
|
|
||||||
{
|
|
||||||
SaleHandle();
|
|
||||||
}
|
|
||||||
else if (input == 2)
|
|
||||||
{
|
|
||||||
ManageHandle();
|
|
||||||
}
|
|
||||||
else if (input == 3)
|
|
||||||
{
|
|
||||||
AdminHandle();
|
|
||||||
}
|
|
||||||
else Console.WriteLine("Invalid operation");
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -54,16 +57,22 @@ namespace Display.Views
|
|||||||
bool running = true;
|
bool running = true;
|
||||||
while (running)
|
while (running)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine("User Managment");
|
||||||
Console.WriteLine("1. GetAll");
|
Console.WriteLine("1. GetAll");
|
||||||
Console.WriteLine("2. Get");
|
Console.WriteLine("2. Get");
|
||||||
Console.WriteLine("3. GetByApproximateName");
|
Console.WriteLine("3. GetByApproximateName");
|
||||||
Console.WriteLine("4. RegisterItem");
|
Console.WriteLine("4. Register user");
|
||||||
Console.WriteLine("5. UpdateRole");
|
Console.WriteLine("5. Update Role");
|
||||||
Console.WriteLine("6. UpdateName");
|
Console.WriteLine("6. Update username");
|
||||||
Console.WriteLine("7. UpdatePassword");
|
Console.WriteLine("7. UpdatePassword");
|
||||||
Console.WriteLine("8. Delete");
|
Console.WriteLine("8. Delete User");
|
||||||
Console.WriteLine("9. Exit");
|
Console.WriteLine();
|
||||||
Console.Write("Your choice: ");
|
Console.WriteLine("Product Managment");
|
||||||
|
Console.WriteLine("9. AddItem");
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine("10. Back");
|
||||||
|
Console.Write("> ");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int choice = int.Parse(Console.ReadLine());
|
int choice = int.Parse(Console.ReadLine());
|
||||||
@@ -94,6 +103,9 @@ namespace Display.Views
|
|||||||
Delete();
|
Delete();
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 9:
|
||||||
|
AddItem();
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
running = false;
|
running = false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -286,5 +298,21 @@ namespace Display.Views
|
|||||||
Console.WriteLine(e.Message);
|
Console.WriteLine(e.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void AddItem()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Console.WriteLine("Adding item to database...");
|
||||||
|
Console.Write("Enter product name: ");
|
||||||
|
string product = Console.ReadLine();
|
||||||
|
Console.Write("Enter price: ");
|
||||||
|
double price = double.Parse(Console.ReadLine());
|
||||||
|
productctrl.AddItem(product, price);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,7 @@ namespace Display.Views
|
|||||||
{
|
{
|
||||||
public class BaseView
|
public class BaseView
|
||||||
{
|
{
|
||||||
ProductController productctrl;
|
internal ProductController productctrl;
|
||||||
DealController dealctrl;
|
DealController dealctrl;
|
||||||
public BaseView(User currentUser)
|
public BaseView(User currentUser)
|
||||||
{
|
{
|
||||||
@@ -18,25 +18,30 @@ namespace Display.Views
|
|||||||
}
|
}
|
||||||
public virtual void ShowAvaliableCommands()
|
public virtual void ShowAvaliableCommands()
|
||||||
{
|
{
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine("=== MAIN MENU ===");
|
||||||
Console.WriteLine("0. Exit");
|
Console.WriteLine("0. Exit");
|
||||||
Console.WriteLine("1. Sales");
|
Console.WriteLine("1. Sales");
|
||||||
}
|
}
|
||||||
public virtual void ActionHandle()
|
public virtual void ActionHandle()
|
||||||
{
|
{
|
||||||
ShowAvaliableCommands();
|
|
||||||
Console.Write("> ");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int input = int.Parse(Console.ReadLine());
|
while (true)
|
||||||
if (input == 0)
|
|
||||||
{
|
{
|
||||||
Environment.Exit(0);
|
ShowAvaliableCommands();
|
||||||
|
Console.Write("> ");
|
||||||
|
int input = int.Parse(Console.ReadLine());
|
||||||
|
if (input == 0)
|
||||||
|
{
|
||||||
|
Environment.Exit(0);
|
||||||
|
}
|
||||||
|
else if (input == 1)
|
||||||
|
{
|
||||||
|
SaleHandle();
|
||||||
|
}
|
||||||
|
else Console.WriteLine("Invalid operation");
|
||||||
}
|
}
|
||||||
else if (input == 1)
|
|
||||||
{
|
|
||||||
SaleHandle();
|
|
||||||
}
|
|
||||||
else Console.WriteLine("Invalid operation");
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -48,10 +53,12 @@ namespace Display.Views
|
|||||||
bool running = true;
|
bool running = true;
|
||||||
while (running)
|
while (running)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine("Deal Managment");
|
||||||
Console.WriteLine("1. Search");
|
Console.WriteLine("1. Search");
|
||||||
Console.WriteLine("2. Sale");
|
Console.WriteLine("2. Sale");
|
||||||
Console.WriteLine("3. Exit");
|
Console.WriteLine("3. Back");
|
||||||
Console.Write("Your choice: ");
|
Console.Write("> ");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int choice = int.Parse(Console.ReadLine());
|
int choice = int.Parse(Console.ReadLine());
|
||||||
@@ -83,12 +90,12 @@ namespace Display.Views
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Console.Write("Search item: ");
|
Console.Write("Search item: ");
|
||||||
string search = Console.ReadLine();
|
string search = Console.ReadLine();
|
||||||
ICollection<Product> productsFound = productctrl.GetByApproximateName(search).ToArray();
|
ICollection<Product> productsFound = productctrl.GetByApproximateName(search).ToArray();
|
||||||
foreach (var item in productsFound)
|
foreach (var item in productsFound)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"{item.Id} {item.Name} {item.Price} {item.AmountInStock}");
|
Console.WriteLine($"{item.Id} {item.Name} {item.Price} {item.AmountInStock}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -103,19 +110,19 @@ namespace Display.Views
|
|||||||
Console.Write("Type in item id or name: ");
|
Console.Write("Type in item id or name: ");
|
||||||
string itemInput = Console.ReadLine();
|
string itemInput = Console.ReadLine();
|
||||||
int itemId;
|
int itemId;
|
||||||
if (Int32.TryParse(itemInput, out itemId))
|
if (int.TryParse(itemInput, out itemId))
|
||||||
{
|
{
|
||||||
var productToAdd = productctrl.Get(itemId);
|
var productToAdd = productctrl.Get(itemId);
|
||||||
Console.Write("Amount: ");
|
Console.Write("Amount: ");
|
||||||
double amount = double.Parse(Console.ReadLine());
|
double amount = double.Parse(Console.ReadLine());
|
||||||
dealctrl.Add(itemId, amount);
|
dealctrl.Add(itemId, amount, DateTime.Now);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var productToAdd = productctrl.Get(itemInput);
|
var productToAdd = productctrl.Get(itemInput);
|
||||||
Console.Write("Amount: ");
|
Console.Write("Amount: ");
|
||||||
double amount = double.Parse(Console.ReadLine());
|
double amount = double.Parse(Console.ReadLine());
|
||||||
dealctrl.Add(itemInput, amount);
|
dealctrl.Add(itemInput, amount, DateTime.Now);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@@ -22,24 +22,27 @@ namespace Display.Views
|
|||||||
}
|
}
|
||||||
public override void ActionHandle()
|
public override void ActionHandle()
|
||||||
{
|
{
|
||||||
ShowAvaliableCommands();
|
|
||||||
Console.Write("> ");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int input = int.Parse(Console.ReadLine());
|
while (true)
|
||||||
if (input == 0)
|
|
||||||
{
|
{
|
||||||
Environment.Exit(0);
|
ShowAvaliableCommands();
|
||||||
|
Console.Write("> ");
|
||||||
|
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");
|
||||||
}
|
}
|
||||||
else if (input == 1)
|
|
||||||
{
|
|
||||||
SaleHandle();
|
|
||||||
}
|
|
||||||
else if (input == 2)
|
|
||||||
{
|
|
||||||
ManageHandle();
|
|
||||||
}
|
|
||||||
else Console.WriteLine("Invalid operation");
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -51,13 +54,15 @@ namespace Display.Views
|
|||||||
bool running = true;
|
bool running = true;
|
||||||
while (running)
|
while (running)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine("Stock Managment");
|
||||||
Console.WriteLine("1. GetAll");
|
Console.WriteLine("1. GetAll");
|
||||||
Console.WriteLine("2. Get");
|
Console.WriteLine("2. Get");
|
||||||
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. Exit");
|
Console.WriteLine("6. Back");
|
||||||
Console.Write("Your choice: ");
|
Console.Write("> ");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int choice = int.Parse(Console.ReadLine());
|
int choice = int.Parse(Console.ReadLine());
|
||||||
@@ -97,11 +102,11 @@ namespace Display.Views
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Console.Write("Getting all stock...");
|
Console.WriteLine("Getting all stock...");
|
||||||
|
Console.WriteLine("ID - Product ID - Amount - Time");
|
||||||
foreach (var item in stockctrl.GetAll())
|
foreach (var item in stockctrl.GetAll())
|
||||||
{
|
{
|
||||||
Console.WriteLine($"{item.Id} {item.ProductId} {item.Amount} ");
|
Console.WriteLine($"{item.Id} - {item.ProductId} - {item.Amount} - {item.Time}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -119,7 +124,9 @@ namespace Display.Views
|
|||||||
{
|
{
|
||||||
Console.Write("Enter stock id: ");
|
Console.Write("Enter stock id: ");
|
||||||
int id = int.Parse(Console.ReadLine());
|
int id = int.Parse(Console.ReadLine());
|
||||||
stockctrl.Get(id);
|
var result = stockctrl.Get(id);
|
||||||
|
Console.WriteLine("ID - Product ID - Amount - Time");
|
||||||
|
Console.WriteLine($"{result.Id} - {result.ProductId} - {result.Amount} - {result.Time}");
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -135,11 +142,16 @@ namespace Display.Views
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Console.WriteLine("Getting stock by time...");
|
Console.WriteLine("Getting stock by time...");
|
||||||
Console.WriteLine("Enter start time: ");
|
Console.Write("Enter start time: ");
|
||||||
DateTime startTime = DateTime.Parse(Console.ReadLine());
|
DateTime startTime = DateTime.Parse(Console.ReadLine());
|
||||||
Console.WriteLine("Enter end time: ");
|
Console.Write("Enter end time: ");
|
||||||
DateTime endTime = DateTime.Parse(Console.ReadLine());
|
DateTime endTime = DateTime.Parse(Console.ReadLine());
|
||||||
stockctrl.GetByTime(startTime, endTime);
|
Console.WriteLine("ID - Product ID - Amount - Time");
|
||||||
|
foreach (var item in stockctrl.GetByTime(startTime, endTime))
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{item.Id} - {item.ProductId} - {item.Amount} - {item.Time}");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -151,19 +163,19 @@ namespace Display.Views
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Console.WriteLine("Adding stock by product id...");
|
Console.WriteLine("Adding stock by product id or name...");
|
||||||
Console.Write("Enter product ID or name: ");
|
Console.Write("Enter product ID or name: ");
|
||||||
string product = Console.ReadLine();
|
string product = Console.ReadLine();
|
||||||
Console.Write("Enter stock amount:");
|
Console.Write("Enter stock amount: ");
|
||||||
double amount = double.Parse(Console.ReadLine());
|
double amount = double.Parse(Console.ReadLine());
|
||||||
bool result = int.TryParse(product, out int productId);
|
bool result = int.TryParse(product, out int productId);
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
stockctrl.Add(productId, amount);
|
stockctrl.Add(productId, amount, DateTime.Now);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
stockctrl.Add(product, amount);
|
stockctrl.Add(product, amount, DateTime.Now);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -178,9 +190,9 @@ namespace Display.Views
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Console.WriteLine("Deleting stock...");
|
Console.WriteLine("Deleting stock...");
|
||||||
Console.Write("Enter deal id: ");
|
Console.Write("Enter stock id: ");
|
||||||
int id = int.Parse(Console.ReadLine());
|
int id = int.Parse(Console.ReadLine());
|
||||||
dealctrl.Delete(id);
|
stockctrl.Delete(id);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@@ -13,11 +13,12 @@ namespace Data.Base
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
protected BaseSales(int UserId, int ProductId, double Amount)
|
protected BaseSales(int UserId, int ProductId, double Amount, DateTime Time)
|
||||||
{
|
{
|
||||||
this.UserId = UserId;
|
this.UserId = UserId;
|
||||||
this.ProductId = ProductId;
|
this.ProductId = ProductId;
|
||||||
this.Amount = Amount;
|
this.Amount = Amount;
|
||||||
|
this.Time = Time;
|
||||||
}
|
}
|
||||||
[Key]
|
[Key]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
using Data.Base;
|
using Data.Base;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Models.Models
|
namespace Models.Models
|
||||||
@@ -6,6 +7,6 @@ namespace Models.Models
|
|||||||
public class Deal : BaseSales
|
public class Deal : BaseSales
|
||||||
{
|
{
|
||||||
public Deal() : base(){}
|
public Deal() : base(){}
|
||||||
public Deal(int UserId, int ProductId, double Amount) : base(UserId, ProductId, Amount) { }
|
public Deal(int UserId, int ProductId, double Amount, DateTime Time) : base(UserId, ProductId, Amount, Time) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -9,6 +9,6 @@ namespace Models.Models
|
|||||||
public class Stock : BaseSales
|
public class Stock : BaseSales
|
||||||
{
|
{
|
||||||
public Stock() : base(){}
|
public Stock() : base(){}
|
||||||
public Stock(int UserId, int ProductId, double Amount) : base(UserId, ProductId, Amount){}
|
public Stock(int UserId, int ProductId, double Amount, DateTime Time) : base(UserId, ProductId, Amount, Time){}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user