CustomerController.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using GreenTree.Strohrmann.ERP.Core.Domain.Business;
  6. using GreenTree.Strohrmann.ERP.Core.Helper;
  7. using GreenTree.Strohrmann.ERP.Domain.Model;
  8. using GreenTree.Strohrmann.ERP.Web.Models.Business;
  9. using GreenTree.Strohrmann.ERP.Web.Models.Rights.User;
  10. using Microsoft.AspNetCore.Http;
  11. using Microsoft.AspNetCore.Mvc;
  12. namespace GreenTree.Strohrmann.ERP.Web.Controllers
  13. {
  14. public class CustomerController : Controller
  15. {
  16. #region DI fields
  17. // The global DbContext
  18. private readonly ERPDbContext _eRPDbContext;
  19. // The global user helper
  20. private readonly IUserHelper _userHelper;
  21. #endregion
  22. #region Ctor
  23. /// <summary>
  24. /// Initializes a new instance of the CustomerController class
  25. /// </summary>
  26. /// <param name="eRPDbContext">Global DbContext.</param>
  27. /// <param name="userHelper">Global user helper.</param>
  28. public CustomerController(
  29. ERPDbContext eRPDbContext,
  30. IUserHelper userHelper)
  31. {
  32. _eRPDbContext = eRPDbContext;
  33. _userHelper = userHelper;
  34. }
  35. #endregion
  36. #region Actions
  37. // GET: CustomerController
  38. public ActionResult Index()
  39. {
  40. var customers = _eRPDbContext.Customers
  41. .ToList()
  42. .Select(c => new CustomerModel(c));
  43. return View(customers);
  44. }
  45. // GET: CustomerController/Details/5
  46. public ActionResult Details(int id)
  47. {
  48. return View();
  49. }
  50. // GET: CustomerController/Create
  51. public ActionResult Create()
  52. {
  53. return View();
  54. }
  55. // POST: CustomerController/Create
  56. [HttpPost]
  57. [ValidateAntiForgeryToken]
  58. public ActionResult Create(IFormCollection collection)
  59. {
  60. try
  61. {
  62. return RedirectToAction(nameof(Index));
  63. }
  64. catch
  65. {
  66. return View();
  67. }
  68. }
  69. // GET: CustomerController/Edit/5
  70. public ActionResult Edit(int id)
  71. {
  72. return View();
  73. }
  74. // POST: CustomerController/Edit/5
  75. [HttpPost]
  76. [ValidateAntiForgeryToken]
  77. public ActionResult Edit(int id, IFormCollection collection)
  78. {
  79. try
  80. {
  81. return RedirectToAction(nameof(Index));
  82. }
  83. catch
  84. {
  85. return View();
  86. }
  87. }
  88. // GET: CustomerController/Delete/5
  89. public ActionResult Delete(int id)
  90. {
  91. return View();
  92. }
  93. // POST: CustomerController/Delete/5
  94. [HttpPost]
  95. [ValidateAntiForgeryToken]
  96. public ActionResult Delete(int id, IFormCollection collection)
  97. {
  98. try
  99. {
  100. return RedirectToAction(nameof(Index));
  101. }
  102. catch
  103. {
  104. return View();
  105. }
  106. }
  107. #endregion
  108. }
  109. }