Quellcode durchsuchen

Lieferanten fertiggestellt!

Arne Diekmann vor 5 Jahren
Ursprung
Commit
004935bb1b

+ 156 - 0
GreenTree.Strohrmann.ERP.Web/Controllers/SupplierController.cs

@@ -0,0 +1,156 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.Http;
+using System.Threading.Tasks;
+using GreenTree.Strohrmann.ERP.Core.Domain.Business;
+using GreenTree.Strohrmann.ERP.Core.Helper;
+using GreenTree.Strohrmann.ERP.Domain.Model;
+using GreenTree.Strohrmann.ERP.Services.Geolocator;
+using GreenTree.Strohrmann.ERP.Web.Models.Business;
+using GreenTree.Strohrmann.ERP.Web.Models.Rights.User;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+
+namespace GreenTree.Strohrmann.ERP.Web.Controllers
+{
+    public class SupplierController : Controller
+    {
+        #region DI fields
+
+        // The global DbContext
+        private readonly ERPDbContext _eRPDbContext;
+
+        #endregion
+
+        #region Ctor
+
+        /// <summary>
+        /// Initializes a new instance of the SupplierController class
+        /// </summary>
+        /// <param name="eRPDbContext">Global DbContext.</param>
+        public SupplierController(ERPDbContext eRPDbContext)
+        {
+            _eRPDbContext = eRPDbContext;
+        }
+
+        #endregion
+
+        #region Actions
+
+        // GET: SupplierController
+        public ActionResult Index()
+        {
+            var suppliers = _eRPDbContext.Suppliers
+                .ToList()
+                .Select(c => new SupplierModel(c));
+
+            return View(suppliers);
+        }
+
+        // GET: SupplierController/Details/5
+        public ActionResult Details(int id)
+        {
+            var supplier = _eRPDbContext.Suppliers
+                .FirstOrDefault(c => c.Id == id);
+
+            var supplierModel = new SupplierModel(supplier);
+
+            return View(supplierModel);
+        }
+
+        // GET: SupplierController/Create
+        public ActionResult Create()
+        {
+            return View();
+        }
+
+        // POST: SupplierController/Create
+        [HttpPost]
+        [ValidateAntiForgeryToken]
+        public ActionResult Create(SupplierModel model)
+        {
+            if (!ModelState.IsValid)
+                return View(model);
+
+            var supplier = new Supplier
+            {
+                Name = model.Name,
+                Description = model.Description,
+                Address = model.Address,
+                Town = model.Town,
+                ZipCode = model.ZipCode,
+                Country = model.Country,
+                PhoneFirst = model.PhoneFirst,
+                PhoneSecond = model.PhoneSecond,
+                MailFirst = model.MailFirst,
+                MailSecond = model.MailSecond,
+                Comment = model.Comment,
+                CreatedBy = User.Identity.Name,
+                CreatedOn = DateTime.Now
+            };
+
+            _eRPDbContext.Suppliers.Add(supplier);
+            _eRPDbContext.SaveChanges();
+
+            return RedirectToAction(nameof(Index));
+        }
+
+        // GET: SupplierController/Edit/5
+        public ActionResult Edit(int id)
+        {
+            var supplier = _eRPDbContext.Suppliers
+                .FirstOrDefault(c => c.Id == id);
+
+            var supplierModel = new SupplierModel(supplier);
+
+            return View(supplierModel);
+        }
+
+        // POST: SupplierController/Edit/5
+        [HttpPost]
+        [ValidateAntiForgeryToken]
+        public ActionResult Edit(int id, SupplierModel model)
+        {
+            if (!ModelState.IsValid)
+                return View(model);
+
+            var supplier = _eRPDbContext.Suppliers
+                .FirstOrDefault(u => u.Id == id);
+
+            supplier.Name = model.Name;
+            supplier.Description = model.Description;
+            supplier.Address = model.Address;
+            supplier.Town = model.Town;
+            supplier.ZipCode = model.ZipCode;
+            supplier.Country = model.Country;
+            supplier.PhoneFirst = model.PhoneFirst;
+            supplier.PhoneSecond = model.PhoneSecond;
+            supplier.MailFirst = model.MailFirst;
+            supplier.MailSecond = model.MailSecond;
+            supplier.Comment = model.Comment;
+            supplier.ChangedBy = User.Identity.Name;
+            supplier.ChangedOn = DateTime.Now;
+
+            _eRPDbContext.SaveChanges();
+
+            return RedirectToAction(nameof(Index));
+        }
+
+        // POST: SupplierController/Delete/5
+        [HttpPost]
+        [ValidateAntiForgeryToken]
+        public ActionResult Delete(int id, IFormCollection collection)
+        {
+            var supplier = _eRPDbContext.Suppliers
+                .FirstOrDefault(c => c.Id == id);
+
+            _eRPDbContext.Suppliers.Remove(supplier);
+            _eRPDbContext.SaveChanges();
+
+            return RedirectToAction(nameof(Index));
+        }
+
+        #endregion
+    }
+}

+ 12 - 0
GreenTree.Strohrmann.ERP.Web/Models/Business/MaterialModel.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace GreenTree.Strohrmann.ERP.Web.Models.Business
+{
+    public class MaterialModel
+    {
+
+    }
+}

+ 120 - 0
GreenTree.Strohrmann.ERP.Web/Models/Business/SupplierModel.cs

@@ -0,0 +1,120 @@
+using GreenTree.Strohrmann.ERP.Core.Domain.Business;
+using GreenTree.Strohrmann.ERP.Web.Models.Shared;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace GreenTree.Strohrmann.ERP.Web.Models.Business
+{
+    public class SupplierModel : TrackingModel
+    {
+        #region Properties
+
+        /// <summary>
+        /// Supplier Id
+        /// </summary>
+        [Display(Name = "ID")]
+        public int Id { get; set; }
+
+        /// <summary>
+        /// Supplier name
+        /// </summary>
+        [Display(Name = "Name")]
+        public string Name { get; set; }
+
+        /// <summary>
+        /// Supplier description
+        /// </summary>
+        [Display(Name = "Beschreibung")]
+        public string Description { get; set; }
+
+        /// <summary>
+        /// Supplier address
+        /// </summary>
+        [Display(Name = "Adresse")]
+        public string Address { get; set; }
+
+        /// <summary>
+        /// Supplier town
+        /// </summary>
+        [Display(Name = "Stadt")]
+        public string Town { get; set; }
+
+        /// <summary>
+        /// Supplier zip code
+        /// </summary>
+        [Display(Name = "Postleitzahl")]
+        public string ZipCode { get; set; }
+
+        /// <summary>
+        /// Supplier country
+        /// </summary>
+        [Display(Name = "Land")]
+        public string Country { get; set; }
+
+        /// <summary>
+        /// Supplier contact phone 1
+        /// </summary>
+        [Display(Name = "Telefon 1")]
+        public string PhoneFirst { get; set; }
+
+        /// <summary>
+        /// Supplier contact phone 2
+        /// </summary>
+        [Display(Name = "Telefon 2")]
+        public string PhoneSecond { get; set; }
+
+        /// <summary>
+        /// Supplier contact mail 1
+        /// </summary>
+        [Display(Name = "Mail-Adresse 1")]
+        public string MailFirst { get; set; }
+
+        /// <summary>
+        /// Supplier contact mail 2
+        /// </summary>
+        [Display(Name = "Mail-Adresse 2")]
+        public string MailSecond { get; set; }
+
+        /// <summary>
+        /// Supplier custom comment
+        /// </summary>
+        [Display(Name = "Kommentar")]
+        public string Comment { get; set; }
+
+        #endregion
+
+        #region Ctor
+
+        /// <summary>
+        /// Initializes a new instance of the SupplierModel class
+        /// </summary>
+        public SupplierModel() {  }
+
+        /// <summary>
+        /// Initializes a new instance of the SupplierModel class
+        /// </summary>
+        public SupplierModel(Supplier supplier)
+            : base(supplier)
+        {
+            if (supplier == null) return;
+
+            Id = supplier.Id;
+            Name = supplier.Name;
+            Description = supplier.Description;
+            Address = supplier.Address;
+            Town = supplier.Town;
+            ZipCode = supplier.ZipCode;
+            Country = supplier.Country;
+            PhoneFirst = supplier.PhoneFirst;
+            PhoneSecond = supplier.PhoneSecond;
+            MailFirst = supplier.MailFirst;
+            MailSecond = supplier.MailSecond;
+            Comment = supplier.Comment;
+        }
+
+        #endregion
+    }
+}

+ 1 - 0
GreenTree.Strohrmann.ERP.Web/Validators/CustomerValidator.cs

@@ -28,6 +28,7 @@ namespace GreenTree.Strohrmann.ERP.Web.Validators
 		/// Initializes a new instance of the CustomerValidator class
 		/// </summary>
 		/// <param name="eRPDbContext">Global DbContext.</param>
+		/// <param name="geocodingService">Global geocoding service.</param>
 		public CustomerValidator(
 			ERPDbContext eRPDbContext,
 			IGeocodingService geocodingService)

+ 77 - 0
GreenTree.Strohrmann.ERP.Web/Validators/SupplierValidator.cs

@@ -0,0 +1,77 @@
+using FluentValidation;
+using GreenTree.Strohrmann.ERP.Services.Geolocator;
+using GreenTree.Strohrmann.ERP.Web.Models.Business;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace GreenTree.Strohrmann.ERP.Web.Validators
+{
+    public class SupplierValidator : AbstractValidator<SupplierModel>
+    {
+        #region DI fields
+
+        // The global geocoding service
+        private readonly IGeocodingService _geocodingService;
+
+        #endregion
+
+        #region Ctor
+
+        /// <summary>
+        /// Initializes a new instance of the SupplierValidator class
+        /// </summary>
+        /// <param name="geocodingService">Global geocoding service.</param>
+        public SupplierValidator(IGeocodingService geocodingService)
+        {
+            _geocodingService = geocodingService;
+
+            RuleFor(m => m.Name)
+                .NotEmpty();
+
+            RuleFor(m => m.Address)
+                .NotEmpty();
+
+            RuleFor(m => m.ZipCode)
+                .NotEmpty();
+
+            RuleFor(m => m.Town)
+                .NotEmpty();
+
+            RuleFor(m => m.Country)
+                .NotEmpty();
+
+            RuleFor(m => m.Address)
+                .Custom((a, context) =>
+                {
+                    var model = context.InstanceToValidate as SupplierModel;
+
+                    if (model == null)
+                    {
+                        context.AddFailure("Unbekannter Fehler.");
+                        return;
+                    }
+
+                    var addressValid = _geocodingService.IsValidAddress(
+                        String.Format("{0} {1} {2}", model.Address, model.ZipCode, model.Town));
+
+                    if (!addressValid)
+                    {
+                        context.AddFailure("Adresse kann nicht gefunden werden. Bitte überprüfen Sie die Adresseingaben.");
+                        return;
+                    }
+                });
+
+            RuleFor(x => x.PhoneFirst)
+                .NotNull()
+                .DependentRules(() => 
+                {
+                    RuleFor(x => x.MailFirst)
+                        .NotNull();
+                });
+        }
+
+        #endregion
+    }
+}

+ 101 - 0
GreenTree.Strohrmann.ERP.Web/Views/Supplier/Create.cshtml

@@ -0,0 +1,101 @@
+@model GreenTree.Strohrmann.ERP.Web.Models.Business.SupplierModel
+
+@{
+    ViewData["Title"] = "Neuer Lieferant";
+}
+
+<h1>Lieferant erstellen</h1>
+
+<h4>Neuer Lieferant</h4>
+<hr />
+
+<form asp-action="Create">
+    <div asp-validation-summary="ModelOnly" class="text-danger"></div>
+    <div class="card-deck">
+        <div class="card card-maxw bg-light">
+            <div class="card-header pb-1">
+                <h6>Allgemeine</h6>
+            </div>
+            <div class="card-body">
+                <div class="form-group">
+                    <label asp-for="Name" class="control-label"></label>
+                    <input asp-for="Name" class="form-control" />
+                    <span asp-validation-for="Name" class="text-danger"></span>
+                </div>
+                <div class="form-group">
+                    <label asp-for="Description" class="control-label"></label>
+                    <input asp-for="Description" class="form-control" />
+                    <span asp-validation-for="Description" class="text-danger"></span>
+                </div>
+                <div class="form-group">
+                    <label asp-for="Comment" class="control-label"></label>
+                    <textarea asp-for="Comment" rows="5" class="form-control"></textarea>
+                    <span asp-validation-for="Comment" class="text-danger"></span>
+                </div>
+            </div>
+        </div>
+        <div class="card card-maxw bg-light">
+            <div class="card-header pb-1">
+                <h6>Adressdaten</h6>
+            </div>
+            <div class="card-body">
+                <div class="form-group">
+                    <label asp-for="Address" class="control-label"></label>
+                    <input asp-for="Address" class="form-control" />
+                    <span asp-validation-for="Address" class="text-danger"></span>
+                </div>
+                <div class="form-group">
+                    <label asp-for="ZipCode" class="control-label"></label>
+                    <input asp-for="ZipCode" class="form-control" />
+                    <span asp-validation-for="ZipCode" class="text-danger"></span>
+                </div>
+                <div class="form-group">
+                    <label asp-for="Town" class="control-label"></label>
+                    <input asp-for="Town" class="form-control" />
+                    <span asp-validation-for="Town" class="text-danger"></span>
+                </div>
+                <div class="form-group">
+                    <label asp-for="Country" class="control-label"></label>
+                    @Html.CountrySelectionFor(m => m.Country, new { @class = "form-control" })
+                    <span asp-validation-for="Country" class="text-danger"></span>
+                </div>
+            </div>
+        </div>
+        <div class="card card-maxw bg-light">
+            <div class="card-header pb-1">
+                <h6>Kontaktdaten</h6>
+            </div>
+            <div class="card-body">
+                <div class="form-group">
+                    <label asp-for="PhoneFirst" class="control-label"></label>
+                    <input asp-for="PhoneFirst" class="form-control" />
+                    <span asp-validation-for="PhoneFirst" class="text-danger"></span>
+                </div>
+                <div class="form-group">
+                    <label asp-for="PhoneSecond" class="control-label"></label>
+                    <input asp-for="PhoneSecond" class="form-control" />
+                    <span asp-validation-for="PhoneSecond" class="text-danger"></span>
+                </div>
+                <div class="form-group">
+                    <label asp-for="MailFirst" class="control-label"></label>
+                    <input asp-for="MailFirst" class="form-control" />
+                    <span asp-validation-for="MailFirst" class="text-danger"></span>
+                </div>
+                <div class="form-group">
+                    <label asp-for="MailSecond" class="control-label"></label>
+                    <input asp-for="MailSecond" class="form-control" />
+                    <span asp-validation-for="MailSecond" class="text-danger"></span>
+                </div>
+            </div>
+        </div>
+    </div>
+
+    <hr />
+
+    <div class="form-group d-flex mt-3">
+        <input type="submit" value="Erstellen" class="btn btn-primary" />
+        <div class="align-self-center ml-3">
+            <a asp-action="Index">Zurück zur Liste</a>
+        </div>
+    </div>
+</form>

+ 171 - 0
GreenTree.Strohrmann.ERP.Web/Views/Supplier/Details.cshtml

@@ -0,0 +1,171 @@
+@model GreenTree.Strohrmann.ERP.Web.Models.Business.SupplierModel
+
+@{
+    ViewData["Title"] = "Lieferantendetails";
+}
+
+<h1>Lieferantendetails</h1>
+
+<h4>@Model.Name</h4>
+
+<hr />
+
+<div class="card-deck">
+    <div class="card">
+        <div class="card-header pb-1">
+            <h6>Allgemein</h6>
+        </div>
+        <div class="card-body">
+            <dl class="row">
+                <dt class = "col-sm-6">
+                    @Html.DisplayNameFor(model => model.Id)
+                </dt>
+                <dd class = "col-sm-6">
+                    @Html.DisplayFor(model => model.Id)
+                </dd>
+                <dt class = "col-sm-6">
+                    @Html.DisplayNameFor(model => model.Name)
+                </dt>
+                <dd class = "col-sm-6">
+                    @Html.DisplayFor(model => model.Name)
+                </dd>
+                <dt class = "col-sm-6">
+                    @Html.DisplayNameFor(model => model.Description)
+                </dt>
+                <dd class = "col-sm-6">
+                    @Html.DisplayFor(model => model.Description)
+                </dd>
+                <dt class = "col-sm-6">
+                    @Html.DisplayNameFor(model => model.Comment)
+                </dt>
+                <dd class = "col-sm-6">
+                    @Html.DisplayFor(model => model.Comment)
+                </dd>
+            </dl>
+        </div>
+    </div>
+    <div class="card">
+        <div class="card-header pb-1">
+            <h6>Adressdaten</h6>
+        </div>
+        <div class="card-body">
+            <dl class="row">
+                <dt class = "col-sm-6">
+                    @Html.DisplayNameFor(model => model.Address)
+                </dt>
+                <dd class = "col-sm-6">
+                    @Html.DisplayFor(model => model.Address)
+                </dd>
+                <dt class = "col-sm-6">
+                    @Html.DisplayNameFor(model => model.ZipCode)
+                </dt>
+                <dd class = "col-sm-6">
+                    @Html.DisplayFor(model => model.ZipCode)
+                </dd>
+                <dt class = "col-sm-6">
+                    @Html.DisplayNameFor(model => model.Town)
+                </dt>
+                <dd class = "col-sm-6">
+                    @Html.DisplayFor(model => model.Town)
+                </dd>
+                <dt class = "col-sm-6">
+                    @Html.DisplayNameFor(model => model.Country)
+                </dt>
+                <dd class = "col-sm-6">
+                    @Html.DisplayFor(model => model.Country)
+                </dd>
+            </dl>
+        </div>
+    </div>
+    <div class="card">
+        <div class="card-header pb-1">
+            <h6>Kontaktdaten</h6>
+        </div>
+        <div class="card-body">
+            <dl class="row">
+                <dt class = "col-sm-6">
+                    @Html.DisplayNameFor(model => model.PhoneFirst)
+                </dt>
+                <dd class = "col-sm-6">
+                    @Html.DisplayFor(model => model.PhoneFirst)
+                </dd>
+                <dt class = "col-sm-6">
+                    @Html.DisplayNameFor(model => model.PhoneSecond)
+                </dt>
+                <dd class = "col-sm-6">
+                    @Html.DisplayFor(model => model.PhoneSecond)
+                </dd>
+                <dt class = "col-sm-6">
+                    @Html.DisplayNameFor(model => model.MailFirst)
+                </dt>
+                <dd class = "col-sm-6">
+                    @Html.DisplayFor(model => model.MailFirst)
+                </dd>
+                <dt class = "col-sm-6">
+                    @Html.DisplayNameFor(model => model.MailSecond)
+                </dt>
+                <dd class = "col-sm-6">
+                    @Html.DisplayFor(model => model.MailSecond)
+                </dd>
+            </dl>
+        </div>
+    </div>
+</div>
+
+<hr />
+
+<div class="d-flex">
+    @Html.ActionLink("Bearbeiten", "Edit", new { id = Model.Id })
+    <div class="align-self-center ml-3">
+        <a asp-action="Index">Zurück zur Liste</a>
+    </div>
+    <div class="align-self-center ml-auto">
+        <a href="#" data-toggle="modal" data-target="#trackingModal">Änderungsinfo</a>
+    </div>
+</div>
+
+<div id="trackingModal" class="modal fade" tabindex="-1" role="dialog">
+    <div class="modal-dialog" role="document">
+        <div class="modal-content modal-content-header-custom">
+            <div class="modal-header modal-header-info text-white">
+                <h5 class="modal-title">Änderungsinfo - @Model.Name</h5>
+                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                    <span aria-hidden="true">&times;</span>
+                </button>
+            </div>
+            <div class="modal-body">
+                <dl class="row">
+                    <dt class = "col-sm-4">
+                        @Html.DisplayNameFor(model => model.CreatedBy)
+                    </dt>
+                    <dd class = "col-sm-6">
+                        @Html.DisplayFor(model => model.CreatedBy)
+                    </dd>
+                    <dt class = "col-sm-4">
+                        @Html.DisplayNameFor(model => model.CreatedOn)
+                    </dt>
+                    <dd class = "col-sm-6">
+                        @Html.DisplayFor(model => model.CreatedOn)
+                    </dd>
+                </dl>
+                <dl class="row">
+                    <dt class = "col-sm-4">
+                        @Html.DisplayNameFor(model => model.ChangedBy)
+                    </dt>
+                    <dd class = "col-sm-6">
+                        @Html.DisplayFor(model => model.ChangedBy)
+                    </dd>
+                    <dt class = "col-sm-4">
+                        @Html.DisplayNameFor(model => model.ChangedOn)
+                    </dt>
+                    <dd class = "col-sm-6">
+                        @Html.DisplayFor(model => model.ChangedOn)
+                    </dd>
+                </dl>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-secondary" data-dismiss="modal">Schließen</button>
+            </div>
+        </div>
+    </div>
+</div>

+ 103 - 0
GreenTree.Strohrmann.ERP.Web/Views/Supplier/Edit.cshtml

@@ -0,0 +1,103 @@
+@model GreenTree.Strohrmann.ERP.Web.Models.Business.SupplierModel
+
+@{
+    ViewData["Title"] = "Lieferant bearbeiten";
+}
+
+<h1>Lieferant bearbeiten</h1>
+
+<h4>@Model.Name</h4>
+
+<hr />
+
+<form asp-action="Edit">
+    <div asp-validation-summary="ModelOnly" class="text-danger"></div>
+    <input asp-for="Id" type="hidden" class="form-control" />
+    <div class="card-deck">
+        <div class="card card-maxw bg-light">
+            <div class="card-header pb-1">
+                <h6>Allgemeine</h6>
+            </div>
+            <div class="card-body">
+                <div class="form-group">
+                    <label asp-for="Name" class="control-label"></label>
+                    <input asp-for="Name" class="form-control" />
+                    <span asp-validation-for="Name" class="text-danger"></span>
+                </div>
+                <div class="form-group">
+                    <label asp-for="Description" class="control-label"></label>
+                    <input asp-for="Description" class="form-control" />
+                    <span asp-validation-for="Description" class="text-danger"></span>
+                </div>
+                <div class="form-group">
+                    <label asp-for="Comment" class="control-label"></label>
+                    <textarea asp-for="Comment" rows="5" class="form-control"  />
+                    <span asp-validation-for="Comment" class="text-danger"></span>
+                </div>
+            </div>
+        </div>
+        <div class="card card-maxw bg-light">
+            <div class="card-header pb-1">
+                <h6>Adressdaten</h6>
+            </div>
+            <div class="card-body">
+                <div class="form-group">
+                    <label asp-for="Address" class="control-label"></label>
+                    <input asp-for="Address" class="form-control" />
+                    <span asp-validation-for="Address" class="text-danger"></span>
+                </div>
+                <div class="form-group">
+                    <label asp-for="ZipCode" class="control-label"></label>
+                    <input asp-for="ZipCode" class="form-control" />
+                    <span asp-validation-for="ZipCode" class="text-danger"></span>
+                </div>
+                <div class="form-group">
+                    <label asp-for="Town" class="control-label"></label>
+                    <input asp-for="Town" class="form-control" />
+                    <span asp-validation-for="Town" class="text-danger"></span>
+                </div>
+                <div class="form-group">
+                    <label asp-for="Country" class="control-label"></label>
+                    @Html.CountrySelectionFor(m => m.Country, new { @class = "form-control" })
+                    <span asp-validation-for="Country" class="text-danger"></span>
+                </div>
+            </div>
+        </div>
+        <div class="card card-maxw bg-light">
+            <div class="card-header pb-1">
+                <h6>Kontaktdaten</h6>
+            </div>
+            <div class="card-body">
+                <div class="form-group">
+                    <label asp-for="PhoneFirst" class="control-label"></label>
+                    <input asp-for="PhoneFirst" class="form-control" />
+                    <span asp-validation-for="PhoneFirst" class="text-danger"></span>
+                </div>
+                <div class="form-group">
+                    <label asp-for="PhoneSecond" class="control-label"></label>
+                    <input asp-for="PhoneSecond" class="form-control" />
+                    <span asp-validation-for="PhoneSecond" class="text-danger"></span>
+                </div>
+                <div class="form-group">
+                    <label asp-for="MailFirst" class="control-label"></label>
+                    <input asp-for="MailFirst" class="form-control" />
+                    <span asp-validation-for="MailFirst" class="text-danger"></span>
+                </div>
+                <div class="form-group">
+                    <label asp-for="MailSecond" class="control-label"></label>
+                    <input asp-for="MailSecond" class="form-control" />
+                    <span asp-validation-for="MailSecond" class="text-danger"></span>
+                </div>
+            </div>
+        </div>
+    </div>
+
+    <hr />
+
+    <div class="form-group d-flex mt-3">
+        <input type="submit" value="Speichern" class="btn btn-primary" />
+        <div class="align-self-center ml-3">
+            <a asp-action="Index">Zurück zur Liste</a>
+        </div>
+    </div>
+</form>

+ 183 - 0
GreenTree.Strohrmann.ERP.Web/Views/Supplier/Index.cshtml

@@ -0,0 +1,183 @@
+@model IEnumerable<GreenTree.Strohrmann.ERP.Web.Models.Business.SupplierModel>
+
+@{
+    ViewData["Title"] = "Lieferantenliste";
+}
+
+<!-- Custom JavaScript -->
+<script>
+
+    $(document).ready(function () {
+        $("#suppliersTable").DataTable({
+            autoWidth: false,
+            paging: true,
+            pageLength: 50,
+            "bInfo": false,
+            columns: [
+                {
+                    data: "@Html.DisplayNameFor(model => model.Id)",
+                    orderable: true
+                },
+                {
+                    data: "@Html.DisplayNameFor(model => model.Name)",
+                    orderable: true
+                },
+                {
+                    data: "@Html.DisplayNameFor(model => model.Description)",
+                    orderable: true
+                },
+                {
+                    data: "@Html.DisplayNameFor(model => model.Address)",
+                    orderable: true
+                },
+                {
+                    data: "@Html.DisplayNameFor(model => model.Town)",
+                    orderable: true
+                },
+                {
+                    data: "@Html.DisplayNameFor(model => model.ZipCode)",
+                    orderable: true
+                },
+                {
+                    data: "@Html.DisplayNameFor(model => model.Country)",
+                    orderable: true
+                },
+                {
+                    data: "@Html.DisplayNameFor(model => model.PhoneFirst)",
+                    orderable: true
+                },
+                {
+                    data: "@Html.DisplayNameFor(model => model.PhoneSecond)",
+                    orderable: true
+                },
+                {
+                    data: "Aktionen",
+                    orderable: false
+				}
+            ],
+            language: {
+                zeroRecords: "Keine Einträge gefunden",
+                search: "Suchen:",
+                info: "Zeige _START_ bis _END_ von _TOTAL_ Einträgen",
+                lengthMenu: "Zeige _MENU_ Einträge",
+                paginate: {
+                    first: "Erste",
+                    last: "Letzte",
+                    next: "Nächste",
+                    previous: "Vorige"
+				}
+			}
+        });
+    });
+
+    function showDeleteModal(id) {
+        if (!id) return;
+        $('#deleteModal').modal("show");
+        $("[name='id'").val(id);
+    }
+
+</script>
+
+<h1>Lieferantenliste</h1>
+
+<p>
+    <a asp-action="Create">Neuen Lieferanten erstellen</a>
+</p>
+
+<table id="suppliersTable" class="table table-striped responsive">
+    <thead>
+        <tr>
+            <th data-priority="1">
+                @Html.DisplayNameFor(model => model.Id)
+            </th>
+            <th data-priority="2">
+                @Html.DisplayNameFor(model => model.Name)
+            </th>
+            <th data-priority="3">
+                @Html.DisplayNameFor(model => model.Description)
+            </th>
+            <th>
+                @Html.DisplayNameFor(model => model.Address)
+            </th>
+            <th>
+                @Html.DisplayNameFor(model => model.Town)
+            </th>
+            <th>
+                @Html.DisplayNameFor(model => model.ZipCode)
+            </th>
+            <th>
+                @Html.DisplayNameFor(model => model.Country)
+            </th>
+            <th data-priority="4">
+                @Html.DisplayNameFor(model => model.PhoneFirst)
+            </th>
+            <th data-priority="5">
+                @Html.DisplayNameFor(model => model.MailFirst)
+            </th>
+            <th data-priority="1">
+                Aktionen
+            </th>
+        </tr>
+    </thead>
+    <tbody>
+@foreach (var item in Model) {
+        <tr>
+            <td>
+                @Html.DisplayFor(modelItem => item.Id)
+            </td>
+            <td>
+                @Html.DisplayFor(modelItem => item.Name)
+            </td>
+            <td>
+                @Html.DisplayFor(modelItem => item.Description)
+            </td>
+            <td>
+                @Html.DisplayFor(modelItem => item.Address)
+            </td>
+            <td>
+                @Html.DisplayFor(modelItem => item.Town)
+            </td>
+            <td>
+                @Html.DisplayFor(modelItem => item.ZipCode)
+            </td>
+            <td>
+                @Html.DisplayFor(modelItem => item.Country)
+            </td>
+            <td>
+                @Html.DisplayFor(modelItem => item.PhoneFirst)
+            </td>
+            <td>
+                @Html.DisplayFor(modelItem => item.MailFirst)
+            </td>
+            <td>
+                @Html.ActionLink("Bearbeiten", "Edit", new { id = item.Id }) |
+                @Html.ActionLink("Anzeigen", "Details", new { id = item.Id }) |
+                <a href="#" onclick="showDeleteModal(@item.Id)">Löschen</a>
+            </td>
+        </tr>
+}
+    </tbody>
+</table>
+
+<div id="deleteModal" class="modal fade" tabindex="-1" role="dialog">
+    <div class="modal-dialog" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title">Lieferant löschen</h5>
+                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                    <span aria-hidden="true">&times;</span>
+                </button>
+            </div>
+            <form asp-action="Delete">
+                <div class="modal-body">
+                    <p>Sind Sie sicher, dass Sie diesen Lieferanten löschen möchten?</p>
+                    <input name="id" type="hidden" />
+                </div>
+                <div class="modal-footer">
+                    <button type="submit" class="btn btn-primary">Ja</button>
+                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Nein</button>
+                </div>
+            </form>
+        </div>
+    </div>
+</div>