public async Task <IActionResult> PostPurchaseStock([FromBody] PurchaseStock purchaseStock)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.PurchaseStock.Add(purchaseStock);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (ProjectExists(purchaseStock.ProjectId))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetPurchaseStock", new { id = purchaseStock.ProjectId }, purchaseStock));
        }
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.White;
            Console.BackgroundColor = ConsoleColor.DarkMagenta;

            Farm Trestlebridge = new Farm();

            while (true)
            {
                // Main menu displayed
                DisplayBanner();
                Console.WriteLine("1. Create Facility");
                Console.WriteLine("2. Purchase Animals");
                Console.WriteLine("3. Purchase Seeds");
                Console.WriteLine("4. Display Farm Status");
                Console.WriteLine("5. Exit");
                Console.WriteLine();

                Console.WriteLine("Choose a FARMS option");
                Console.Write("> ");
                string option = Console.ReadLine();

                // Collecting user input from menu
                if (option == "1")
                {
                    DisplayBanner();
                    CreateFacility.CollectInput(Trestlebridge);
                }
                else if (option == "2")
                {
                    DisplayBanner();
                    PurchaseStock.CollectInput(Trestlebridge);
                }
                else if (option == "3")
                {
                    DisplayBanner();
                    PurchaseSeeds.CollectInput(Trestlebridge);
                }
                else if (option == "4")
                {
                    DisplayBanner();
                    Console.WriteLine(Trestlebridge);
                    Console.WriteLine("\n\n\n");
                    Console.WriteLine("Press return key to go back to main menu.");
                    Console.ReadLine();
                }
                else if (option == "5")
                {
                    Console.WriteLine("Today is a great day for farming");
                    break;
                }
                else
                {
                    Console.WriteLine($"Invalid option: {option}");
                }
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.White;
            Console.BackgroundColor = ConsoleColor.DarkMagenta;
            // makes a new instance of the Farm class called Trestlebridge
            Farm
                Trestlebridge = new Farm();

            while (true)
            {
                DisplayBanner();
                Console.WriteLine("1. Create Facility");
                Console.WriteLine("2. Purchase Animals");
                Console.WriteLine("3. Purchase Seeds");
                Console.WriteLine("4. Display Farm Status");
                Console.WriteLine("5. Exit");
                Console.WriteLine();

                Console.WriteLine("Choose a FARMS option");
                Console.Write("> ");
                string option = Console.ReadLine();

                if (option == "1")
                {
                    DisplayBanner();
                    CreateFacility.CollectInput(Trestlebridge);
                }
                else if (option == "2")
                {
                    DisplayBanner();
                    PurchaseStock.CollectInput(Trestlebridge);
                }
                else if (option == "3")
                {
                    DisplayBanner();
                    PurchaseSeed.CollectInput(Trestlebridge);
                }
                else if (option == "4")
                {
                    DisplayBanner();
                    Console.WriteLine(Trestlebridge);
                    //  calls the toString method on Trestlebridge

                    Console.WriteLine("Press return key to go back to main menu.");
                    Console.ReadLine();
                }
                else if (option == "5" || option.ToLower() == "exit")
                {
                    Console.WriteLine("Today is a great day for farming");
                    break;
                }
                else
                {
                    Console.WriteLine($"Invalid option: {option}");
                }
            }
        }
Example #4
0
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.White;
            Console.BackgroundColor = ConsoleColor.DarkCyan;

            Farm Trestlebridge = new Farm();

            while (true)
            {
                DisplayBanner();
                //options for user to select action from
                Console.WriteLine("1. Create Facility");
                Console.WriteLine("2. Purchase Animals");
                Console.WriteLine("3. Purchase Seeds");
                Console.WriteLine("4. Display Farm Status");
                Console.WriteLine("5. Exit");
                Console.WriteLine();

                Console.WriteLine("Choose a FARMS option");
                Console.Write("> ");
                //this is reading whatever the user selected and then is used below in the conditionals
                string option = Console.ReadLine();

                if (option == "1")
                {
                    DisplayBanner();
                    CreateFacility.CollectInput(Trestlebridge);
                }
                else if (option == "2")
                {
                    DisplayBanner();
                    PurchaseStock.CollectInput(Trestlebridge);
                }
                else if (option == "4")
                {
                    DisplayBanner();
                    Console.WriteLine(Trestlebridge);
                    Console.WriteLine("\n\n\n");
                    Console.WriteLine("Press return key to go back to main menu.");
                    Console.ReadLine();
                }
                else if (option == "5")
                {
                    Console.WriteLine("Today is a great day for farming");
                    // the break exits out of console app
                    break;
                }
                //if user doesn't select any correct options, app alerts them it was incorrect
                else
                {
                    Console.WriteLine($"Invalid option: {option}");
                }
            }
        }
        public async Task <IActionResult> Create([Bind("ProjectId,OrderId,ProductId,Dimension,Description,Pattern,Colour,Quantity,Uom,UnitPrice,Amount,ReceivedBy,CreatedTime,UpdatedBy,UpdatedTime")] PurchaseStock purchaseStock)
        {
            if (ModelState.IsValid)
            {
                _context.Add(purchaseStock);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProjectId"]  = new SelectList(_context.PurchaseOrderdetail, "ProjectId", "ProductId", purchaseStock.ProjectId);
            ViewData["OrderId"]    = new SelectList(_context.PurchaseOrderdetail, "OrderId", "OrderId", purchaseStock.OrderId);
            ViewData["ProductId"]  = new SelectList(_context.PurchaseOrderdetail, "ProductId", "ProductId", purchaseStock.ProductId);
            ViewData["ReceivedBy"] = new SelectList(_context.Employee, "UserId", "FirstName", purchaseStock.ReceivedBy);
            ViewData["UpdatedBy"]  = new SelectList(_context.Employee, "UserId", "FirstName", purchaseStock.UpdatedBy);
            return(View(purchaseStock));
        }
        public async Task <PurchaseStockResponse> PurchaseStock(PurchaseStock purchase)
        {
            try
            {
                var userid  = long.Parse(Thread.CurrentPrincipal.Identity.Name);
                var company = await _unitofwork.StockCompanies.GetByIdAsync(purchase.CompanyId);

                // Check User wallet balance from AuthMocroservice here
                var buy = new TblPurchase {
                    CompanyId = company.CompanyId, StockPrice = company.StockPrice, StockQuantity = (decimal)purchase.StockQuantity, UserId = userid, Cost = (decimal)purchase.StockQuantity * company.StockPrice
                };
                await _unitofwork.Purchase.AddAsync(buy);

                var IhaveStock = await _unitofwork.Stocks.FirstOrDefaultAsync(o => o.UserId == userid && o.CompanyId == company.CompanyId);

                if (IhaveStock != null)
                {
                    IhaveStock.Value += (decimal)purchase.StockQuantity * company.StockPrice;
                    _unitofwork.Stocks.Update(IhaveStock);
                }
                else
                {
                    var stock = new TblStocks {
                        CompanyId = company.CompanyId, UserId = userid, Value = (decimal)purchase.StockQuantity * company.StockPrice
                    };
                    await _unitofwork.Stocks.AddAsync(stock);
                }
                await _unitofwork.CommitChangesAsync();

                //Update User Wallet balance in Auth Microservice here//
                return(new PurchaseStockResponse {
                    ResponseCode = "99", ResponseMessage = "StockPurchased Successfully"
                });
            }
            catch (Exception ex)
            {
                _logWriter.LogWrite("Message: " + ex.Message + Environment.NewLine + "InnerException: " + ex.InnerException + Environment.NewLine + "StackTrace: " + ex.StackTrace);
                return(new PurchaseStockResponse {
                    ResponseCode = "99", ResponseMessage = ex.Message
                });
            }
        }
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.White;
            Console.BackgroundColor = ConsoleColor.DarkMagenta;

            Farm Trestlebridge = new Farm();


            bool flag = true;

            while (flag)
            {
                DisplayBanner();
                Console.WriteLine("1. Create Facility");
                Console.WriteLine("2. Purchase Animals");
                Console.WriteLine("3. Purchase Seeds");
                Console.WriteLine("4. Processing");
                Console.WriteLine("5. Display Farm Status");
                Console.WriteLine("6. Exit");
                Console.WriteLine();

                Console.WriteLine("Choose a FARMS option");
                Console.Write("> ");
                string option = Console.ReadLine();

                switch (option)
                {
                case "1":
                    DisplayBanner();
                    CreateFacility.CollectInput(Trestlebridge);
                    break;

                case "2":
                    DisplayBanner();
                    PurchaseStock.CollectInput(Trestlebridge);
                    break;

                case "3":
                    DisplayBanner();
                    PurchaseSeeds.CollectInput(Trestlebridge);
                    break;

                case "4":
                    DisplayBanner();
                    ProcessingOptions.CollectInput(Trestlebridge);
                    break;

                case "5":
                    DisplayBanner();
                    Console.WriteLine(Trestlebridge);
                    Console.WriteLine("\n\n\n\n");
                    Console.WriteLine("Press return key to go back to main menu.");
                    Console.ReadLine();
                    break;

                case "6":
                    Console.WriteLine("Today is a great day for farming");
                    flag = false;
                    break;

                default:
                    Console.WriteLine($"{option} Is not a valid input");
                    break;
                }
            }
        }
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.White;
            Console.BackgroundColor = ConsoleColor.DarkBlue;

            Farm Trestlebridge = new Farm();

            while (true)
            {
                DisplayBanner();
                Console.WriteLine("1. Create Facility");
                Console.WriteLine("2. Purchase Animals");
                Console.WriteLine("3. Purchase Seeds");
                Console.WriteLine("4. Process Resource");
                Console.WriteLine("5. Display Farm Status");
                Console.WriteLine("6. Exit");
                Console.WriteLine();

                Console.WriteLine("Choose a FARMS option");
                Console.Write("> ");
                string option = Console.ReadLine();

                if (option == "1")
                {
                    DisplayBanner();
                    CreateFacility.CollectInput(Trestlebridge);
                }
                else if (option == "2")
                {
                    DisplayBanner();
                    PurchaseStock.CollectInput(Trestlebridge);
                }
                else if (option == "3")
                {
                    DisplayBanner();
                    PurchasePlants.CollectInput(Trestlebridge);
                }
                else if (option == "4")
                {
                    DisplayBanner();
                    ProcessResource.CollectInput(Trestlebridge);
                }
                else if (option == "5")
                {
                    DisplayBanner();
                    Console.WriteLine(Trestlebridge);
                    Console.WriteLine("\n\n\n");
                }
                else if (option == "6")
                {
                    Console.WriteLine("Today is a great day for farming");
                    break;
                }
                else
                {
                    Console.WriteLine($"Invalid option: {option}");
                }
                Console.WriteLine();
                Console.Write("Press Enter To Return To Main Menu");
                Console.ReadLine();
            }
        }
Example #9
0
        static void Main(string[] args)
        {
            //color of the application
            //such an eyesore
            //who the hell though this was a good idea???
            Console.ForegroundColor = ConsoleColor.White;
            Console.BackgroundColor = ConsoleColor.DarkMagenta;


            //instance of a new farm type
            Farm Trestlebridge = new Farm();

            //main menu
            while (true)
            {
                DisplayBanner();

                //list of options
                //added the option for processing options menu on option 5
                //changed exit to option 6
                Console.WriteLine("1. Create Facility");
                Console.WriteLine("2. Purchase Animals");
                Console.WriteLine("3. Purchase Seeds");
                Console.WriteLine("4. Display Farm Status");
                Console.WriteLine("5. Processing Options");
                Console.WriteLine("6. Exit");

                Console.WriteLine("Choose a FARMS option");
                Console.Write("> ");
                string option = Console.ReadLine();

                if (option == "1")
                {
                    DisplayBanner();
                    CreateFacility.CollectInput(Trestlebridge);
                }
                else if (option == "2")
                {
                    DisplayBanner();
                    PurchaseStock.CollectInput(Trestlebridge);
                }
                else if (option == "3")
                {
                    DisplayBanner();
                    PurchaseSeed.CollectInput(Trestlebridge);
                }
                else if (option == "4")
                {
                    DisplayBanner();
                    //Calls the ToString() function in Farm.cs. This sets off a cascade of calling multiple ToString() functions
                    Console.WriteLine(Trestlebridge);
                    Console.WriteLine("\n\n\n");
                    Console.WriteLine("Press return key to go back to main menu.");
                    Console.ReadLine();
                }
                //this will bring you to the processing options menu
                else if (option == "5")
                {
                    //calls the display banner method
                    DisplayBanner();
                    //calls the collect input method from ProcessingOptions.cs
                    ProcessingOptions.CollectInput();
                }
                else if (option == "6")
                {
                    Console.WriteLine("Today is a great day for farming");
                    break;
                }
                else
                {
                    //this will tell you that whatever key you hit was invalid
                    Console.WriteLine($"Invalid option: {option}");
                    //this pauses the error message
                    Thread.Sleep(2000);
                }
            }
        }
 public async Task <PurchaseStockResponse> BuyStcok(PurchaseStock stock)
 {
     return(await _stocksService.PurchaseStock(stock));
 }
Example #11
0
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.White;
            Console.BackgroundColor = ConsoleColor.DarkCyan;

            Farm Trestlebridge = new Farm();

            while (true)
            {
                DisplayBanner();
                Console.WriteLine("1. Create Facility");
                Console.WriteLine("2. Purchase Animals");
                Console.WriteLine("3. Purchase Seeds");
                Console.WriteLine("4. Display Farm Status");
                Console.WriteLine("5. Exit");
                Console.WriteLine();

                Console.WriteLine("Choose a FARMS option");
                Console.Write("> ");
                string option = Console.ReadLine();

                if (option == "1")
                {
                    DisplayBanner();
                    CreateFacility.CollectInput(Trestlebridge);
                }
                else if (option == "2")
                {
                    DisplayBanner();
                    PurchaseStock.CollectInput(Trestlebridge);
                }
                else if (option == "3")
                {
                    DisplayBanner();
                    PurchaseSeed.CollectInput(Trestlebridge);
                }
                else if (option == "4")
                {
                    DisplayBanner();
                    Console.WriteLine(Trestlebridge);
                    Console.WriteLine("\n\n\n");
                    Console.WriteLine("Press return key to go back to main menu.");
                    Console.ReadLine();
                }
                else if (option == "5")
                {
                    Console.Clear();
                    Console.WriteLine("\n\n\n");
                    Console.WriteLine("Today is a great day for farming. May you drown in the great Kraken's infinite love.");
                    Console.WriteLine(@"              
                 7... 7                 
              77.......7                
             7...........               
             .............7             
           I...............:7           
           .................            
  777       ...............7       7    
 7.I~.7      7...........7      7.~7.7  
 77  .,       ...........       ,.      
     .7       ...........       7.7     
    ..7       ...........        ..     
   7.7        ...........        7.     
  7=.         ...........        7..    
   ..  7      7:........         7..    
   I...~..7    .,......,    7..:...,    
  7...77 7.    +.......,    .   7...7   
  :. ...77  7 I.........I7  777...7.,   
  .. 7~.........................~7 ..   
  7.77 777++7......7......7?=77   7.7   
   7..7   7........7........    7..+    
     ?......7+..7..7..7..+7......?      
           7+.., .. ..77..+7            
          7=... 7.. .. 7....            
          ..+..  ..7..7 ,.+..7          
        7..I~.7 7..7..7 7.~7..7         
      7...  ..7 +.? ?.= 7..  ...7       
    I..+    ,.7 ..   .. 7.,7  77..I     
   ..77     I.7 ..   .. 7.I      7..7   
  ,.7       7.: ..  7..7:.        7..   
 7.=7 7.7~.77....     .... 7.:7.   7.7  
 7.       .?  ...     ...7 7.7     7.7  
 7.77    7.7  ..7      .. 77.      7.7  
  ..7  77..   ..7     7..7  ..7   7..   
   :.....77  ~.?.     .7.:   7......7   
             ..77    777..              
             :.7       7.:              
             7.7       7.7              
              .:       7.7              
              ..       ..7              
              7.7      .7               
               .7    77.7               
                .    7.7                
               7,7   7.7                
                 .7  .                   
                         GlassGiant.com
                    ");
                    break;
                }
                else
                {
                    Console.Clear();
                    Console.WriteLine("\n\n\n");
                    Console.WriteLine("Welcome to timeout.");
                    Console.WriteLine("Your mom and I are very disappointed.");
                    Console.WriteLine();
                    Console.WriteLine($"Invalid option: {option}");
                    Console.ReadLine();
                }
            }
        }
Example #12
0
        public async Task <IActionResult> Edit(int?projectId, int?orderId, string productId, [Bind("ProjectId,OrderId,ProductId,Dimension,Description,Pattern,Colour,Quantity,Uom,UnitPrice,Amount,ReceivedBy,CreatedTime,UpdatedBy,UpdatedTime")] PurchaseStock purchaseStock)
        {
            if (projectId != purchaseStock.ProjectId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(purchaseStock);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PurchaseStockExists(purchaseStock.ProjectId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProjectId"]  = new SelectList(_context.PurchaseOrderdetail, "ProjectId", "ProductId", purchaseStock.ProjectId);
            ViewData["OrderId"]    = new SelectList(_context.PurchaseOrderdetail, "OrderId", "OrderId", purchaseStock.OrderId);
            ViewData["ProductId"]  = new SelectList(_context.PurchaseOrderdetail, "ProductId", "ProductId", purchaseStock.ProductId);
            ViewData["ReceivedBy"] = new SelectList(_context.Employee, "UserId", "FirstName", purchaseStock.ReceivedBy);
            ViewData["UpdatedBy"]  = new SelectList(_context.Employee, "UserId", "FirstName", purchaseStock.UpdatedBy);
            return(View(purchaseStock));
        }
Example #13
0
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.DarkMagenta;
            Console.BackgroundColor = ConsoleColor.Gray;

            Farm Trestlebridge = new Farm();

            // Trestlebridge.ChickenHouses.Add(new ChickenHouse());

            // Trestlebridge.ChickenHouses[0].AddResource(new Chicken());
            // Trestlebridge.ChickenHouses[0].AddResource(new Chicken());
            // Trestlebridge.ChickenHouses[0].AddResource(new Chicken());
            // Trestlebridge.ChickenHouses[0].AddResource(new Chicken());
            // Trestlebridge.ChickenHouses[0].AddResource(new Chicken());
            // Trestlebridge.ChickenHouses[0].AddResource(new Chicken());
            // Trestlebridge.ChickenHouses[0].AddResource(new Chicken());
            // Trestlebridge.ChickenHouses[0].AddResource(new Chicken());

            while (true)
            {
                DisplayBanner();
                Console.WriteLine("1. Create Facility");
                Console.WriteLine("2. Purchase Animals");
                Console.WriteLine("3. Purchase Seeds");
                Console.WriteLine("4. Process Resources");
                Console.WriteLine("5. Display Farm Status");
                Console.WriteLine("6. Exit");
                Console.WriteLine();

                Console.WriteLine("Choose a FARMS option");
                Console.Write("> ");
                string option = Console.ReadLine();

                if (option == "1")
                {
                    DisplayBanner();
                    CreateFacility.CollectInput(Trestlebridge);
                }
                else if (option == "2")
                {
                    DisplayBanner();
                    PurchaseStock.CollectInput(Trestlebridge);
                }
                else if (option == "3")
                {
                    DisplayBanner();
                    PurchaseSeeds.CollectInput(Trestlebridge);
                }
                else if (option == "4")
                {
                    DisplayBanner();
                    ChooseMeatFacility.CollectInput(Trestlebridge, new MeatProcessor());
                }
                else if (option == "5")
                {
                    DisplayBanner();
                    Console.WriteLine(Trestlebridge);
                    Console.WriteLine("\n\n\n");
                    Console.WriteLine("Press return key to go back to main menu.");
                    Console.ReadLine();
                }
                else if (option == "6")
                {
                    Console.WriteLine("Today is a great day for farming");
                    break;
                }
                else
                {
                    Console.WriteLine($"Invalid option: {option}");
                }
            }
        }
Example #14
0
        // Main method to launch program. Also sets foreground color to white and background to dark blue, harkening a simpler more Commodore 64-esque era.
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.White;
            Console.BackgroundColor = ConsoleColor.DarkBlue;

            // Creates Trestlebridge object
            Farm Trestlebridge = new Farm();

            // While loop keeps user in FARMS program
            while (true)
            {
                // Displays banner and main menu options to user
                DisplayBanner();
                Console.WriteLine("1. Create Facility");
                Console.WriteLine("2. Purchase Animals");
                Console.WriteLine("3. Purchase Seeds");
                Console.WriteLine("4. Process Farm Products");
                Console.WriteLine("5. Display Farm Status");
                Console.WriteLine("6. Exit");
                Console.WriteLine();

                // Prompts user to select the number of the desired option
                Console.WriteLine("Choose a FARMS option");
                Console.Write("> ");
                string option = Console.ReadLine();

                // Reads user's input and presents the associated sub-menu for the chosen option
                if (option == "1")
                {
                    DisplayBanner();
                    CreateFacility.CollectInput(Trestlebridge);
                }
                else if (option == "2")
                {
                    DisplayBanner();
                    PurchaseStock.CollectInput(Trestlebridge);
                }
                else if (option == "3")
                {
                    DisplayBanner();
                    PurchaseSeed.CollectInput(Trestlebridge);
                }
                else if (option == "4")
                {
                    DisplayBanner();
                    ChooseProcessingOption.CollectInput(Trestlebridge);
                }

                else if (option == "5")
                {
                    DisplayBanner();
                    Console.WriteLine(Trestlebridge);
                    Console.WriteLine("\n\n\n");
                    Console.WriteLine("Press return key to go back to main menu.");
                    Console.ReadLine();
                }

                // Exits program and prints a warm departure message to the user
                else if (option == "6")
                {
                    Console.WriteLine("Rest well. Tomorrow brings another day of plowing fields and ethically raising happy animals for farm-to-table restaurants all over Nashville.");
                    break;
                }
                else
                {
                    Console.WriteLine($"Invalid option: {option}");
                }
            }
        }
Example #15
0
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.White;
            Console.BackgroundColor = ConsoleColor.DarkMagenta;

            Farm Trestlebridge = new Farm();

            while (true)
            {
                DisplayBanner();
                Console.WriteLine("1. Create Facility");
                Console.WriteLine("2. Purchase Animals");
                Console.WriteLine("3. Purchase Seeds");
                Console.WriteLine("4. Display Farm Status");
                Console.WriteLine("5. Exit");
                Console.WriteLine();

                if (InputWasInvalid)
                {
                    Console.WriteLine("Input was invalid, please try again.");
                }
                Console.WriteLine("Choose a FARMS option");
                Console.Write("> ");
                string option = Console.ReadLine();

                if (option == "1")
                {
                    DisplayBanner();
                    InputWasInvalid = false;
                    CreateFacility.CollectInput(Trestlebridge);
                }
                else if (option == "2")
                {
                    DisplayBanner();
                    InputWasInvalid = false;
                    PurchaseStock.CollectInput(Trestlebridge);
                }
                else if (option == "3")
                {
                    DisplayBanner();
                    PurchaseSeed.CollectInput(Trestlebridge);
                }
                else if (option == "4")
                {
                    DisplayBanner();
                    InputWasInvalid = false;
                    Console.WriteLine(Trestlebridge);
                    Console.WriteLine("\n\n\n");
                    Console.WriteLine("Press return key to go back to main menu.");
                    Console.ReadLine();
                }
                else if (option == "5")
                {
                    Console.WriteLine("Today is a great day for farming");
                    break;
                }
                else
                {
                    InputWasInvalid = true;
                }
            }
        }
Example #16
0
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.White;
            Console.BackgroundColor = ConsoleColor.DarkMagenta;

            Farm Trestlebridge = new Farm();

            while (true)
            {
                DisplayBanner();
                Console.WriteLine(@"1. Create Facility");
                Console.WriteLine(@"2. Purchase Animals");
                Console.WriteLine(@"3. Purchase Seeds");
                Console.WriteLine(@"4. Processing Options");
                Console.WriteLine(@"5. Display Farm Status");
                Console.WriteLine(@"6. Exit");
                Console.WriteLine();

                Console.WriteLine("Choose a FARMS option");
                Console.Write("> ");

                int option = 0;

                while (option == 0)
                {
                    try
                    {
                        option = Int32.Parse(Console.ReadLine());
                        switch (option)
                        {
                        case 1:
                            DisplayBanner();
                            CreateFacility.CollectInput(Trestlebridge);
                            break;

                        case 2:
                            DisplayBanner();
                            PurchaseStock.CollectInput(Trestlebridge);
                            break;

                        case 3:
                            DisplayBanner();
                            PurchaseSeed.CollectInput(Trestlebridge);
                            break;

                        case 4:
                            DisplayBanner();
                            Console.WriteLine("You've hit processing! There's nothing to do here yet... hit enter to return to the main menu.");
                            Console.Read();
                            break;

                        case 5:
                            DisplayBanner();
                            Console.WriteLine(Trestlebridge);
                            Console.WriteLine("\n\n\n");
                            Console.WriteLine("Press return key to go back to main menu.");
                            Console.ReadLine();
                            break;

                        case 6:
                            Console.WriteLine("Today is a great day for farming!");
                            System.Environment.Exit(0);
                            break;

                        default:
                            Console.WriteLine($"Invalid option: {option}. Press enter to return to the main menu.");
                            Console.Read();
                            break;
                        }
                    }
                    catch (FormatException)
                    {
                        Console.WriteLine("Please input a number!");
                    }
                }
            }
        }
Example #17
0
        public async Task <IActionResult> PutPurchaseStock([FromRoute] int projectId, int orderId, string productId, [FromBody] PurchaseStock purchaseStock)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (projectId != purchaseStock.ProjectId)
            {
                return(BadRequest());
            }

            _context.Entry(purchaseStock).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProjectExists(projectId) && !OrderExists(orderId) && !ProductExists(productId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }