manager view
This commit is contained in:
@@ -27,7 +27,7 @@ namespace Business.Business.Sales
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("Cannot return all stocks!");
|
throw new ArgumentException("Cannot return all stocks!");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -40,7 +40,7 @@ namespace Business.Business.Sales
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("Cannot get stock!");
|
throw new ArgumentException("Cannot get stock!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ namespace Business.Business.Sales
|
|||||||
|
|
||||||
public void Delete(int id)
|
public void Delete(int id)
|
||||||
{
|
{
|
||||||
if (currentUser.RoleId > 1)
|
if (currentUser.RoleId == 3 )
|
||||||
{
|
{
|
||||||
var user = Get(id);
|
var user = Get(id);
|
||||||
if (user != null)
|
if (user != null)
|
||||||
|
@@ -8,7 +8,7 @@ using System.Text;
|
|||||||
|
|
||||||
namespace Business.Business.UserManagment.Controllers
|
namespace Business.Business.UserManagment.Controllers
|
||||||
{
|
{
|
||||||
class RoleController : IReadOnlyController<Role>
|
public class RoleController : IReadOnlyController<Role>
|
||||||
{
|
{
|
||||||
private LuminousContext context;
|
private LuminousContext context;
|
||||||
private User currentUser;
|
private User currentUser;
|
||||||
|
@@ -7,7 +7,7 @@ using System.Text;
|
|||||||
|
|
||||||
namespace Display.Views
|
namespace Display.Views
|
||||||
{
|
{
|
||||||
class BaseView
|
public class BaseView
|
||||||
{
|
{
|
||||||
ProductController productctrl;
|
ProductController productctrl;
|
||||||
DealController dealctrl;
|
DealController dealctrl;
|
||||||
|
@@ -1,10 +1,122 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using Business.Business.Sales;
|
||||||
|
using Models.Models;
|
||||||
|
|
||||||
namespace Display.Views
|
namespace Display.Views
|
||||||
{
|
{
|
||||||
class ManagerView
|
public class ManagerView : BaseView
|
||||||
{
|
{
|
||||||
|
StockController stockctrl;
|
||||||
|
DealController dealctrl;
|
||||||
|
public ManagerView(User currentUser):base(currentUser)
|
||||||
|
{
|
||||||
|
stockctrl = new StockController(currentUser);
|
||||||
|
dealctrl = new DealController(currentUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GetAll()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Console.Write("Getting all stock...");
|
||||||
|
|
||||||
|
foreach (var item in stockctrl.GetAll())
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{item.Id} {item.ProductId} {item.Amount} ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
|
||||||
|
Console.WriteLine(e.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Get(int id)
|
||||||
|
{
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Console.WriteLine("Getting stock id...");
|
||||||
|
id = int.Parse(Console.ReadLine());
|
||||||
|
stockctrl.Get(id);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
|
||||||
|
Console.WriteLine(e.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GetByTime(DateTime startTime, DateTime endTime)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Console.WriteLine("Getting stock by time...");
|
||||||
|
|
||||||
|
startTime = new DateTime();
|
||||||
|
endTime = new DateTime();
|
||||||
|
stockctrl.GetByTime(startTime, endTime);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
|
||||||
|
Console.WriteLine(e.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Add(int productId, double amount)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Console.WriteLine("Adding stock by product id...");
|
||||||
|
productId = int.Parse(Console.ReadLine());
|
||||||
|
amount = double.Parse(Console.ReadLine());
|
||||||
|
stockctrl.Add(productId, amount);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
|
||||||
|
Console.WriteLine(e.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Add(string productName, double amount)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Console.WriteLine("Adding stock by 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");
|
||||||
|
id = int.Parse(Console.ReadLine());
|
||||||
|
dealctrl.Delete(id);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
|
||||||
|
Console.WriteLine(e.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user