From fc9ff26137c197a88c6ec8574bdec23d65f6ad7e Mon Sep 17 00:00:00 2001 From: Aneliya Konarcheva <60808931+annie-prog@users.noreply.github.com> Date: Sat, 20 Mar 2021 19:16:50 +0200 Subject: [PATCH] comment about manager view --- LuminousSales/Display/Views/ManagerView.cs | 96 +++++++++++++++++++--- 1 file changed, 86 insertions(+), 10 deletions(-) diff --git a/LuminousSales/Display/Views/ManagerView.cs b/LuminousSales/Display/Views/ManagerView.cs index 0882b42..91a3dfd 100644 --- a/LuminousSales/Display/Views/ManagerView.cs +++ b/LuminousSales/Display/Views/ManagerView.cs @@ -10,22 +10,59 @@ namespace Display.Views { StockController stockctrl; DealController dealctrl; + + /// + /// Constructor that accepts a user object. + /// + /// + /// User object is used for stock and deal checking. + /// + /// + /// Initialises stock and deal controllers. + /// + public ManagerView(User currentUser):base(currentUser) { stockctrl = new StockController(currentUser); + dealctrl = new DealController(currentUser); } + + /// + /// Shows all available commands. + /// + /// + /// Inherits all available commands from the base view. + /// + /// + /// The main menu. + /// + + public override void ShowAvaliableCommands() { base.ShowAvaliableCommands(); Console.WriteLine("2. Stock"); } + + /// + /// Asks the user to choose which group of action to use. + /// + /// + /// If user inputs the digit 1, returns selling handles. + /// + /// + /// If user inputs the digit 2, returns managing handles. + /// + /// + /// If user inputs something else, the operation is invalid. + /// + public override void ActionHandle() { try { while (true) { - Console.Clear(); ShowAvaliableCommands(); Console.Write("> "); int input = int.Parse(Console.ReadLine()); @@ -49,6 +86,14 @@ namespace Display.Views Console.WriteLine(e.Message); } } + + /// + /// Selection menu with manager actions. + /// + /// + /// Requires role level 2 (Manager). + /// + public void ManageHandle() { bool running = true; @@ -59,11 +104,11 @@ namespace Display.Views Console.WriteLine("0. Back"); Console.WriteLine(); Console.WriteLine("Stock Managment"); - Console.WriteLine("1. List all stocks"); - Console.WriteLine("2. Get a stock"); - Console.WriteLine("3. List stocks by time"); - Console.WriteLine("4. Add stock"); - Console.WriteLine("5. Delete stock"); + Console.WriteLine("1. GetAll"); + Console.WriteLine("2. Get"); + Console.WriteLine("3. GetByTime"); + Console.WriteLine("4. Add"); + Console.WriteLine("5. Delete"); Console.Write("> "); try { @@ -100,6 +145,11 @@ namespace Display.Views } } + + /// + /// Lists all information about stock from the database. + /// + public void GetAll() { try @@ -119,6 +169,10 @@ namespace Display.Views } + /// + /// Lists all registered information about stocks from the database. + /// + public void Get() { @@ -138,7 +192,15 @@ namespace Display.Views } } - + /// + /// Gets stock by its start time and end time. + /// + /// + /// Inputs start time and end time. + /// + /// + /// Lists all information about stocks from the database in real time. + /// public void GetByTime() { try @@ -161,6 +223,19 @@ namespace Display.Views } } + /// + /// Adding a stock using the product id or name. + /// + /// + /// Entering product name and amount. + /// + /// + /// If the result is true, returns a stock with product id, amount and a real time. + /// + /// + /// Else returns a stock with product name, amount and a real time. + /// + public void Add() { try @@ -174,12 +249,10 @@ namespace Display.Views if (result) { stockctrl.Add(productId, amount, DateTime.Now); - Console.WriteLine("Added stock successfully"); } else { stockctrl.Add(product, amount, DateTime.Now); - Console.WriteLine("Added stock successfully"); } } catch (Exception e) @@ -189,6 +262,10 @@ namespace Display.Views } } + /// + /// Deletes a stock from the database. + /// + public void Delete() { try @@ -197,7 +274,6 @@ namespace Display.Views Console.Write("Enter stock id: "); int id = int.Parse(Console.ReadLine()); stockctrl.Delete(id); - Console.WriteLine($"Deleted stock {id} successfully"); } catch (Exception e) {