Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
tannercroom authored May 24, 2022
1 parent 94c6c78 commit 2ff77c3
Show file tree
Hide file tree
Showing 78 changed files with 41,687 additions and 0 deletions.
77 changes: 77 additions & 0 deletions Controllers/CustomerController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Diagnostics;
using Team4_Project.Models;

namespace Team4_Project.Controllers
{
public class CustomerController : Controller
{
private ATMContext context { get; set; }
public CustomerController(ATMContext ctx)
{
context = ctx;
}

[HttpGet]
public IActionResult Add()
{
ViewBag.Action = "Add";
return View("Edit", new Customer());
}

[HttpGet]
public IActionResult Edit(int id)
{
ViewBag.Action = "Edit";
var customer = context.Customer.Find(id);
return View(customer);
}

[HttpPost]
public IActionResult Edit(Customer customer)
{
if (ModelState.IsValid)
{
if (customer.CustomerID == 0)
{
context.Customer.Add(customer);
}
else
{
context.Customer.Update(customer);
}
context.SaveChanges();
return RedirectToAction("CustomerList", "Customer");
}
else
{
ViewBag.Action = (customer.CustomerID == 0) ? "Add" : "Edit";
return View(customer);
}
}

[HttpGet]
public IActionResult Delete(int id)
{
var customer = context.Customer.Find(id);
return View(customer);
}

[HttpPost]
public IActionResult Delete(Customer customer)
{
context.Customer.Remove(customer);
context.SaveChanges();
return RedirectToAction("CustomerList", "Customer");
}
public IActionResult CustomerList()
{
var customers = context.Customer.OrderBy(m => m.CustomerID).ToList();
return View(customers);
}
}
}
77 changes: 77 additions & 0 deletions Controllers/EmployeeController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Diagnostics;
using Team4_Project.Models;

namespace Team4_Project.Controllers
{
public class EmployeeController : Controller
{
private ATMContext context { get; set; }
public EmployeeController(ATMContext ctx)
{
context = ctx;
}

[HttpGet]
public IActionResult Add()
{
ViewBag.Action = "Add";
return View("Edit", new Employee());
}

[HttpGet]
public IActionResult Edit(int id)
{
ViewBag.Action = "Edit";
var customer = context.Employee.Find(id);
return View(customer);
}

[HttpPost]
public IActionResult Edit(Employee employee)
{
if (ModelState.IsValid)
{
if (employee.EmployeeID == 0)
{
context.Employee.Add(employee);
}
else
{
context.Employee.Update(employee);
}
context.SaveChanges();
return RedirectToAction("EmployeeList", "Employee");
}
else
{
ViewBag.Action = (employee.EmployeeID == 0) ? "Add" : "Edit";
return View(employee);
}
}

[HttpGet]
public IActionResult Delete(int id)
{
var employee = context.Employee.Find(id);
return View(employee);
}

[HttpPost]
public IActionResult Delete(Employee employee)
{
context.Employee.Remove(employee);
context.SaveChanges();
return RedirectToAction("EmployeeList", "Employee");
}
public IActionResult EmployeeList()
{
var employees = context.Employee.OrderBy(m => m.EmployeeID).ToList();
return View(employees);
}
}
}
37 changes: 37 additions & 0 deletions Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Team4_Project.Models;

namespace Team4_Project.Controllers
{
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;

public HomeController(ILogger<HomeController> logger)
{
_logger = logger;
}

public IActionResult Index()
{
return View();
}

public IActionResult Privacy()
{
return View();
}

[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}
77 changes: 77 additions & 0 deletions Controllers/InventoryController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Team4_Project.Models;

namespace Team4_Project.Controllers
{
public class InventoryController : Controller
{
private ATMContext context { get; set; }
public InventoryController(ATMContext ctx)
{
context = ctx;
}

public IActionResult Inventory()
{
var inventory = context.Inventory.OrderBy(m => m.ItemID).ToList();
return View(inventory);
}

[HttpGet]
public IActionResult Add()
{
ViewBag.Action = "Add";
return View("Edit", new Inventory());
}

[HttpGet]
public IActionResult Edit(int id)
{
ViewBag.Action = "Edit";
var item = context.Inventory.Find(id);
return View(item);
}

[HttpPost]
public IActionResult Edit(Inventory item)
{
if (ModelState.IsValid)
{
if (item.ItemID == 0)
{
context.Inventory.Add(item);
}
else
{
context.Inventory.Update(item);
}
context.SaveChanges();
return RedirectToAction("Inventory", "Inventory");
}
else
{
ViewBag.Action = (item.ItemID == 0) ? "Add" : "Edit";
return View(item);
}
}

[HttpGet]
public IActionResult Delete(int id)
{
var item = context.Inventory.Find(id);
return View(item);
}

[HttpPost]
public IActionResult Delete(Inventory item)
{
context.Inventory.Remove(item);
context.SaveChanges();
return RedirectToAction("Inventory", "Inventory");
}
}
}
Loading

0 comments on commit 2ff77c3

Please sign in to comment.