From d376ee222ceeb5acddb176dbe5a21f7b6b79dd4d Mon Sep 17 00:00:00 2001 From: "Md. Aftab Uddin Kajal" Date: Mon, 23 Apr 2018 21:21:27 +0600 Subject: [PATCH 01/17] Supplier controller adding & index view page adding --- src/AssetManager.Core/Entities/Supplier.cs | 6 +- .../Data/AssetManagerContext.cs | 1 + .../Controllers/CompaniesController.cs | 4 +- .../Controllers/SupplierController.cs | 113 +++++++++++++++ .../Views/Shared/_Layout.cshtml | 2 +- .../Views/Supplier/Index.cshtml | 137 ++++++++++++++++++ .../Views/_ViewImports.cshtml | 4 +- 7 files changed, 258 insertions(+), 9 deletions(-) create mode 100644 src/AssetManager.Web/Controllers/SupplierController.cs create mode 100644 src/AssetManager.Web/Views/Supplier/Index.cshtml diff --git a/src/AssetManager.Core/Entities/Supplier.cs b/src/AssetManager.Core/Entities/Supplier.cs index 8e6bac3..82b1bb3 100644 --- a/src/AssetManager.Core/Entities/Supplier.cs +++ b/src/AssetManager.Core/Entities/Supplier.cs @@ -15,7 +15,7 @@ public class Supplier: Entity [Display(Name ="Name")] public string Name { get; set; } - [Display(Name = "Name")] + [Display(Name = "Address")] public string Address { get; set; } [Display(Name = " ")] @@ -42,11 +42,9 @@ public class Supplier: Entity [Display(Name = "Contact")] public string Contact { get; set; } - [Display(Name = "Note")] public string Notes { get; set; } - [Display(Name = "Zip")] public string Zip { get; set; } @@ -55,9 +53,9 @@ public class Supplier: Entity [Display(Name = "Image")] public string Image { get; set; } + public DateTime CreateAt { get; set; } public DateTime UpdatedAt { get; set; } - public int UserId { get; set; } public DateTime DeletedAt { get; set; } } diff --git a/src/AssetManager.Infrastructure/Data/AssetManagerContext.cs b/src/AssetManager.Infrastructure/Data/AssetManagerContext.cs index c4921cf..916f9e1 100644 --- a/src/AssetManager.Infrastructure/Data/AssetManagerContext.cs +++ b/src/AssetManager.Infrastructure/Data/AssetManagerContext.cs @@ -11,5 +11,6 @@ public class AssetManagerContext : DbContext public AssetManagerContext( DbContextOptions options) : base(options) { } DbSet Companies { get; set; } + DbSet Suppliers { get; set; } } } diff --git a/src/AssetManager.Web/Controllers/CompaniesController.cs b/src/AssetManager.Web/Controllers/CompaniesController.cs index 08337e1..9fdc4cc 100644 --- a/src/AssetManager.Web/Controllers/CompaniesController.cs +++ b/src/AssetManager.Web/Controllers/CompaniesController.cs @@ -20,6 +20,7 @@ public CompaniesController(IAsyncRepository repository) } // GET: Companies + [HttpGet] public async Task Index() { var companies = await _companyRepository.ListAllAsync(); @@ -33,7 +34,8 @@ public ActionResult Details(int id) } // GET: Companies/Create - public ActionResult Create() + + public IActionResult Create() { return View(); } diff --git a/src/AssetManager.Web/Controllers/SupplierController.cs b/src/AssetManager.Web/Controllers/SupplierController.cs new file mode 100644 index 0000000..1ba7806 --- /dev/null +++ b/src/AssetManager.Web/Controllers/SupplierController.cs @@ -0,0 +1,113 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using AssetManager.Core.Entities; +using AssetManager.Core.Interfaces; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace AssetManager.Web.Controllers +{ + public class SupplierController : Controller + { + private readonly IAsyncRepository _companyRepository; + public SupplierController(IAsyncRepository repository) + { + _companyRepository = repository; + } + + // GET: Supplier + [HttpGet] + public async Task Index() + { + var companies = await _companyRepository.ListAllAsync(); + return View(companies); + } + + // GET: Supplier/Details/5 + public IActionResult Details(int id) + { + return View(); + } + + // GET: Supplier/Create + public async Task Create(Supplier supplier) + { + try + { + await _companyRepository.AddAsync(supplier); + return RedirectToAction("index"); + } + catch + { + return View(); + } + + } + + // POST: Supplier/Create + [HttpPost] + [ValidateAntiForgeryToken] + public ActionResult Create(IFormCollection collection) + { + try + { + // TODO: Add insert logic here + + return RedirectToAction(nameof(Index)); + } + catch + { + return View(); + } + } + + // GET: Supplier/Edit/5 + [HttpGet] + public IActionResult Edit(int id) + { + return View(); + } + + // POST: Supplier/Edit/5 + [HttpPost] + [ValidateAntiForgeryToken] + public ActionResult Edit(int id, IFormCollection collection) + { + try + { + // TODO: Add update logic here + + return RedirectToAction(nameof(Index)); + } + catch + { + return View(); + } + } + + // GET: Supplier/Delete/5 + public ActionResult Delete(int id) + { + return View(); + } + + // POST: Supplier/Delete/5 + [HttpPost] + [ValidateAntiForgeryToken] + public ActionResult Delete(int id, IFormCollection collection) + { + try + { + // TODO: Add delete logic here + + return RedirectToAction(nameof(Index)); + } + catch + { + return View(); + } + } + } +} \ No newline at end of file diff --git a/src/AssetManager.Web/Views/Shared/_Layout.cshtml b/src/AssetManager.Web/Views/Shared/_Layout.cshtml index 0caa51f..ce91100 100644 --- a/src/AssetManager.Web/Views/Shared/_Layout.cshtml +++ b/src/AssetManager.Web/Views/Shared/_Layout.cshtml @@ -293,7 +293,7 @@ diff --git a/src/AssetManager.Web/Views/Supplier/Index.cshtml b/src/AssetManager.Web/Views/Supplier/Index.cshtml new file mode 100644 index 0000000..51088f5 --- /dev/null +++ b/src/AssetManager.Web/Views/Supplier/Index.cshtml @@ -0,0 +1,137 @@ +@model IEnumerable + +@{ + ViewData["Title"] = "Index"; +} + +

Index

+ +

+ Create New +

+ + + + + + + + + + + + + + + + + + + + + + + + + +@foreach (var item in Model) { + + + + + + + + + + + + + + + + + + + + + +} + +
+ @Html.DisplayNameFor(model => model.Name) + + @Html.DisplayNameFor(model => model.Address) + + @Html.DisplayNameFor(model => model.AddressTwo) + + @Html.DisplayNameFor(model => model.City) + + @Html.DisplayNameFor(model => model.State) + + @Html.DisplayNameFor(model => model.Country) + + @Html.DisplayNameFor(model => model.Phone) + + @Html.DisplayNameFor(model => model.Fax) + + @Html.DisplayNameFor(model => model.Email) + + @Html.DisplayNameFor(model => model.Contact) + + @Html.DisplayNameFor(model => model.Notes) + + @Html.DisplayNameFor(model => model.Zip) + + @Html.DisplayNameFor(model => model.Url) + + @Html.DisplayNameFor(model => model.Image) + + @Html.DisplayNameFor(model => model.CreateAt) + + @Html.DisplayNameFor(model => model.UpdatedAt) + + @Html.DisplayNameFor(model => model.DeletedAt) + + @Html.DisplayNameFor(model => model.Id) +
+ @Html.DisplayFor(modelItem => item.Name) + + @Html.DisplayFor(modelItem => item.Address) + + @Html.DisplayFor(modelItem => item.AddressTwo) + + @Html.DisplayFor(modelItem => item.City) + + @Html.DisplayFor(modelItem => item.State) + + @Html.DisplayFor(modelItem => item.Country) + + @Html.DisplayFor(modelItem => item.Phone) + + @Html.DisplayFor(modelItem => item.Fax) + + @Html.DisplayFor(modelItem => item.Email) + + @Html.DisplayFor(modelItem => item.Contact) + + @Html.DisplayFor(modelItem => item.Notes) + + @Html.DisplayFor(modelItem => item.Zip) + + @Html.DisplayFor(modelItem => item.Url) + + @Html.DisplayFor(modelItem => item.Image) + + @Html.DisplayFor(modelItem => item.CreateAt) + + @Html.DisplayFor(modelItem => item.UpdatedAt) + + @Html.DisplayFor(modelItem => item.DeletedAt) + + @Html.DisplayFor(modelItem => item.Id) + + @Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) | + @Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) | + @Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ }) +
diff --git a/src/AssetManager.Web/Views/_ViewImports.cshtml b/src/AssetManager.Web/Views/_ViewImports.cshtml index 9c976a0..5f28270 100644 --- a/src/AssetManager.Web/Views/_ViewImports.cshtml +++ b/src/AssetManager.Web/Views/_ViewImports.cshtml @@ -1,3 +1 @@ -@using AssetManager.Web -@using AssetManager.Web.Models -@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers + \ No newline at end of file From 20ad52f7968c482cb3ea2f26812618e780186dbd Mon Sep 17 00:00:00 2001 From: "Md. Aftab Uddin Kajal" Date: Tue, 24 Apr 2018 01:58:53 +0600 Subject: [PATCH 02/17] repository modified for update & getByID --- .../Data/EfRepository.cs | 10 ++++---- .../Controllers/SupplierController.cs | 23 +++++++++++++++---- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/AssetManager.Infrastructure/Data/EfRepository.cs b/src/AssetManager.Infrastructure/Data/EfRepository.cs index 898231f..1898bf7 100644 --- a/src/AssetManager.Infrastructure/Data/EfRepository.cs +++ b/src/AssetManager.Infrastructure/Data/EfRepository.cs @@ -30,9 +30,10 @@ public async Task DeleteAsync(T entity) await _dbContext.SaveChangesAsync(); } - public Task GetByIdAsync(int id) + public async Task GetByIdAsync(int id) { - throw new NotImplementedException(); + + return await _dbContext.Set().FindAsync(id); } public async Task> ListAllAsync() @@ -40,9 +41,10 @@ public async Task> ListAllAsync() return await _dbContext.Set().ToListAsync(); } - public Task UpdateAsync(T entity) + public async Task UpdateAsync(T entity) { - throw new NotImplementedException(); + _dbContext.Entry(entity).State = EntityState.Modified; + await _dbContext.SaveChangesAsync(); } } } diff --git a/src/AssetManager.Web/Controllers/SupplierController.cs b/src/AssetManager.Web/Controllers/SupplierController.cs index 1ba7806..cf3c28f 100644 --- a/src/AssetManager.Web/Controllers/SupplierController.cs +++ b/src/AssetManager.Web/Controllers/SupplierController.cs @@ -11,23 +11,29 @@ namespace AssetManager.Web.Controllers { public class SupplierController : Controller { - private readonly IAsyncRepository _companyRepository; + private readonly IAsyncRepository _supplierRepository; public SupplierController(IAsyncRepository repository) { - _companyRepository = repository; + _supplierRepository = repository; } // GET: Supplier [HttpGet] public async Task Index() { - var companies = await _companyRepository.ListAllAsync(); + var companies = await _supplierRepository.ListAllAsync(); return View(companies); } // GET: Supplier/Details/5 public IActionResult Details(int id) { + if(id == null) + { + return NotFound(); + } + + return View(); } @@ -36,7 +42,7 @@ public async Task Create(Supplier supplier) { try { - await _companyRepository.AddAsync(supplier); + await _supplierRepository.AddAsync(supplier); return RedirectToAction("index"); } catch @@ -65,8 +71,15 @@ public ActionResult Create(IFormCollection collection) // GET: Supplier/Edit/5 [HttpGet] - public IActionResult Edit(int id) + public async Task Edit(int? id) { + if (id == null) + { + return NotFound(); + } + + + return View(); } From b75fd884af69be6e63fd80302c132e05775e3787 Mon Sep 17 00:00:00 2001 From: "Md. Aftab Uddin Kajal" Date: Tue, 24 Apr 2018 03:24:50 +0600 Subject: [PATCH 03/17] Supplier Create Page added. --- .../Controllers/SupplierController.cs | 28 ++--- .../Views/Supplier/Create.cshtml | 118 ++++++++++++++++++ 2 files changed, 131 insertions(+), 15 deletions(-) create mode 100644 src/AssetManager.Web/Views/Supplier/Create.cshtml diff --git a/src/AssetManager.Web/Controllers/SupplierController.cs b/src/AssetManager.Web/Controllers/SupplierController.cs index cf3c28f..f7b3cb0 100644 --- a/src/AssetManager.Web/Controllers/SupplierController.cs +++ b/src/AssetManager.Web/Controllers/SupplierController.cs @@ -38,29 +38,24 @@ public IActionResult Details(int id) } // GET: Supplier/Create - public async Task Create(Supplier supplier) + [HttpGet] + public IActionResult Create() { - try - { - await _supplierRepository.AddAsync(supplier); - return RedirectToAction("index"); - } - catch - { - return View(); - } + return View(); } // POST: Supplier/Create [HttpPost] [ValidateAntiForgeryToken] - public ActionResult Create(IFormCollection collection) + public async Task Create(Supplier Supplier) { try { // TODO: Add insert logic here + await _supplierRepository.AddAsync(Supplier); + return RedirectToAction(nameof(Index)); } catch @@ -71,16 +66,19 @@ public ActionResult Create(IFormCollection collection) // GET: Supplier/Edit/5 [HttpGet] - public async Task Edit(int? id) + public async Task Edit(int id) { if (id == null) { return NotFound(); } - - - return View(); + var supplier = await _supplierRepository.GetByIdAsync(id); + if(supplier == null) + { + return NotFound(); + } + return View(supplier); } // POST: Supplier/Edit/5 diff --git a/src/AssetManager.Web/Views/Supplier/Create.cshtml b/src/AssetManager.Web/Views/Supplier/Create.cshtml new file mode 100644 index 0000000..25a34d5 --- /dev/null +++ b/src/AssetManager.Web/Views/Supplier/Create.cshtml @@ -0,0 +1,118 @@ +@model AssetManager.Core.Entities.Supplier + +@{ + ViewData["Title"] = "Create"; +} + +

Create

+ +

Supplier

+
+
+
+
+
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ +
+
+
+
+ + + +@section Scripts { + @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} +} From b450556526463e38e7f688c264c860431e0b3796 Mon Sep 17 00:00:00 2001 From: "Md. Aftab Uddin Kajal" Date: Tue, 24 Apr 2018 05:49:35 +0600 Subject: [PATCH 04/17] Supplier Create Page modified & solved render section issue --- .../Views/Companies/Create.cshtml | 3 +- .../Views/Companies/Index.cshtml | 1 + .../Views/Shared/_Layout.cshtml | 16 +- .../Views/Supplier/Create.cshtml | 250 ++++++++++-------- .../Views/Supplier/Index.cshtml | 245 +++++++++-------- 5 files changed, 275 insertions(+), 240 deletions(-) diff --git a/src/AssetManager.Web/Views/Companies/Create.cshtml b/src/AssetManager.Web/Views/Companies/Create.cshtml index 68435fa..489ee04 100644 --- a/src/AssetManager.Web/Views/Companies/Create.cshtml +++ b/src/AssetManager.Web/Views/Companies/Create.cshtml @@ -4,9 +4,8 @@ ViewData["Title"] = "Create"; } -

Create

+

Create Company

-

Company


diff --git a/src/AssetManager.Web/Views/Companies/Index.cshtml b/src/AssetManager.Web/Views/Companies/Index.cshtml index d740177..8a1768d 100644 --- a/src/AssetManager.Web/Views/Companies/Index.cshtml +++ b/src/AssetManager.Web/Views/Companies/Index.cshtml @@ -9,6 +9,7 @@

Create New

+ diff --git a/src/AssetManager.Web/Views/Shared/_Layout.cshtml b/src/AssetManager.Web/Views/Shared/_Layout.cshtml index ce91100..02f855b 100644 --- a/src/AssetManager.Web/Views/Shared/_Layout.cshtml +++ b/src/AssetManager.Web/Views/Shared/_Layout.cshtml @@ -10,6 +10,16 @@ + + + + + + + + +
-

- Page Header - Optional description -

+
- - - - - - - - - - - - - - - - - - - - - - - - -@foreach (var item in Model) { - - - - - - - - - - - - - - - - - - - - - -} - -
- @Html.DisplayNameFor(model => model.Name) - - @Html.DisplayNameFor(model => model.Address) - - @Html.DisplayNameFor(model => model.AddressTwo) - - @Html.DisplayNameFor(model => model.City) - - @Html.DisplayNameFor(model => model.State) - - @Html.DisplayNameFor(model => model.Country) - - @Html.DisplayNameFor(model => model.Phone) - - @Html.DisplayNameFor(model => model.Fax) - - @Html.DisplayNameFor(model => model.Email) - - @Html.DisplayNameFor(model => model.Contact) - - @Html.DisplayNameFor(model => model.Notes) - - @Html.DisplayNameFor(model => model.Zip) - - @Html.DisplayNameFor(model => model.Url) - - @Html.DisplayNameFor(model => model.Image) - - @Html.DisplayNameFor(model => model.CreateAt) - - @Html.DisplayNameFor(model => model.UpdatedAt) - - @Html.DisplayNameFor(model => model.DeletedAt) - - @Html.DisplayNameFor(model => model.Id) -
- @Html.DisplayFor(modelItem => item.Name) - - @Html.DisplayFor(modelItem => item.Address) - - @Html.DisplayFor(modelItem => item.AddressTwo) - - @Html.DisplayFor(modelItem => item.City) - - @Html.DisplayFor(modelItem => item.State) - - @Html.DisplayFor(modelItem => item.Country) - - @Html.DisplayFor(modelItem => item.Phone) - - @Html.DisplayFor(modelItem => item.Fax) - - @Html.DisplayFor(modelItem => item.Email) - - @Html.DisplayFor(modelItem => item.Contact) - - @Html.DisplayFor(modelItem => item.Notes) - - @Html.DisplayFor(modelItem => item.Zip) - - @Html.DisplayFor(modelItem => item.Url) - - @Html.DisplayFor(modelItem => item.Image) - - @Html.DisplayFor(modelItem => item.CreateAt) - - @Html.DisplayFor(modelItem => item.UpdatedAt) - - @Html.DisplayFor(modelItem => item.DeletedAt) - - @Html.DisplayFor(modelItem => item.Id) - - @Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) | - @Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) | - @Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ }) -
+ +
+
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + @foreach (var item in Model) + { + + + + + + + + + + + + + + + + + + + + } + +
+ @Html.DisplayNameFor(model => model.Name) + + @Html.DisplayNameFor(model => model.Address) + + @Html.DisplayNameFor(model => model.AddressTwo) + + @Html.DisplayNameFor(model => model.City) + + @Html.DisplayNameFor(model => model.State) + + @Html.DisplayNameFor(model => model.Country) + + @Html.DisplayNameFor(model => model.Phone) + + @Html.DisplayNameFor(model => model.Fax) + + @Html.DisplayNameFor(model => model.Email) + + @Html.DisplayNameFor(model => model.Contact) + + @Html.DisplayNameFor(model => model.Notes) + + @Html.DisplayNameFor(model => model.Zip) + + @Html.DisplayNameFor(model => model.Url) + + @Html.DisplayNameFor(model => model.Image) +
+ @Html.DisplayFor(modelItem => item.Name) + + @Html.DisplayFor(modelItem => item.Address) + + @Html.DisplayFor(modelItem => item.AddressTwo) + + @Html.DisplayFor(modelItem => item.City) + + @Html.DisplayFor(modelItem => item.State) + + @Html.DisplayFor(modelItem => item.Country) + + @Html.DisplayFor(modelItem => item.Phone) + + @Html.DisplayFor(modelItem => item.Fax) + + @Html.DisplayFor(modelItem => item.Email) + + @Html.DisplayFor(modelItem => item.Contact) + + @Html.DisplayFor(modelItem => item.Notes) + + @Html.DisplayFor(modelItem => item.Zip) + + @Html.DisplayFor(modelItem => item.Url) + + @Html.DisplayFor(modelItem => item.Image) + + @Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) | + @Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) | + @Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ }) +
+
+
From 4ff2746cafcf1131a0ea98daa78f8b3b96c93d74 Mon Sep 17 00:00:00 2001 From: "Md. Aftab Uddin Kajal" Date: Tue, 24 Apr 2018 06:30:00 +0600 Subject: [PATCH 05/17] Company Create Page modified & solved render section issue --- .../Views/Companies/Create.cshtml | 71 ++++++++++--------- .../Views/Supplier/Create.cshtml | 62 ++++++++-------- 2 files changed, 69 insertions(+), 64 deletions(-) diff --git a/src/AssetManager.Web/Views/Companies/Create.cshtml b/src/AssetManager.Web/Views/Companies/Create.cshtml index 489ee04..2477e92 100644 --- a/src/AssetManager.Web/Views/Companies/Create.cshtml +++ b/src/AssetManager.Web/Views/Companies/Create.cshtml @@ -5,48 +5,53 @@ }

Create Company

-
-
-
-
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- + +
+
+
+
- +
+
+ + +
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ + +
+
+
+ +
+
+
+
+
- + @section Scripts { @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} } diff --git a/src/AssetManager.Web/Views/Supplier/Create.cshtml b/src/AssetManager.Web/Views/Supplier/Create.cshtml index c13e6e2..6b5aeb6 100644 --- a/src/AssetManager.Web/Views/Supplier/Create.cshtml +++ b/src/AssetManager.Web/Views/Supplier/Create.cshtml @@ -9,7 +9,7 @@
-
+
@@ -21,8 +21,8 @@
- -
+ +
@@ -30,24 +30,24 @@
- -
+ +
- -
+ +
- -
+ +
@@ -55,55 +55,55 @@
- -
+ +
- -
+ +
- -
+ +
- -
+ +
- -
+ +
- -
+ +
- -
+ +
@@ -111,32 +111,32 @@
- -
+ +
- -
+ +

Please upload Image here.

- -
+ +
-
-
+
+
From 91ddb66f85c1ca2a3884690ed75da76514366912 Mon Sep 17 00:00:00 2001 From: "Md. Aftab Uddin Kajal" Date: Tue, 24 Apr 2018 22:59:31 +0600 Subject: [PATCH 06/17] action work --- src/AssetManager.Web/Controllers/CompaniesController.cs | 1 - src/AssetManager.Web/Views/Companies/Create.cshtml | 4 ++-- src/AssetManager.Web/Views/Supplier/Create.cshtml | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/AssetManager.Web/Controllers/CompaniesController.cs b/src/AssetManager.Web/Controllers/CompaniesController.cs index 9fdc4cc..0bfb597 100644 --- a/src/AssetManager.Web/Controllers/CompaniesController.cs +++ b/src/AssetManager.Web/Controllers/CompaniesController.cs @@ -42,7 +42,6 @@ public IActionResult Create() // POST: Companies/Create [HttpPost] - [ValidateAntiForgeryToken] public async Task Create(Company company) { try diff --git a/src/AssetManager.Web/Views/Companies/Create.cshtml b/src/AssetManager.Web/Views/Companies/Create.cshtml index 2477e92..db112d1 100644 --- a/src/AssetManager.Web/Views/Companies/Create.cshtml +++ b/src/AssetManager.Web/Views/Companies/Create.cshtml @@ -13,7 +13,7 @@
-
+
@@ -39,7 +39,7 @@
- +
diff --git a/src/AssetManager.Web/Views/Supplier/Create.cshtml b/src/AssetManager.Web/Views/Supplier/Create.cshtml index 6b5aeb6..a5bbd6e 100644 --- a/src/AssetManager.Web/Views/Supplier/Create.cshtml +++ b/src/AssetManager.Web/Views/Supplier/Create.cshtml @@ -14,7 +14,7 @@
- +
From e427f08358d57f97f46c8043fae15bf6a6c0ed72 Mon Sep 17 00:00:00 2001 From: "Md. Aftab Uddin Kajal" Date: Wed, 25 Apr 2018 22:34:13 +0600 Subject: [PATCH 07/17] view modified --- src/AssetManager.Web/Controllers/CompaniesController.cs | 6 +++--- src/AssetManager.Web/Views/Companies/Create.cshtml | 2 +- src/AssetManager.Web/Views/Companies/Index.cshtml | 2 +- src/AssetManager.Web/Views/Shared/_Layout.cshtml | 4 +++- src/AssetManager.Web/Views/Supplier/Create.cshtml | 8 ++++---- src/AssetManager.Web/Views/Supplier/Index.cshtml | 2 +- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/AssetManager.Web/Controllers/CompaniesController.cs b/src/AssetManager.Web/Controllers/CompaniesController.cs index 0bfb597..4017c75 100644 --- a/src/AssetManager.Web/Controllers/CompaniesController.cs +++ b/src/AssetManager.Web/Controllers/CompaniesController.cs @@ -17,6 +17,7 @@ public class CompaniesController : Controller public CompaniesController(IAsyncRepository repository) { this._companyRepository = repository; + } // GET: Companies @@ -46,8 +47,7 @@ public async Task Create(Company company) { try { - // TODO: Add insert logic here - + await _companyRepository.AddAsync(company); return RedirectToAction(nameof(Index)); @@ -59,7 +59,7 @@ public async Task Create(Company company) } // GET: Companies/Edit/5 - public ActionResult Edit(int id) + public IActionResult Edit(int id) { return View(); } diff --git a/src/AssetManager.Web/Views/Companies/Create.cshtml b/src/AssetManager.Web/Views/Companies/Create.cshtml index db112d1..4e70826 100644 --- a/src/AssetManager.Web/Views/Companies/Create.cshtml +++ b/src/AssetManager.Web/Views/Companies/Create.cshtml @@ -48,7 +48,7 @@
diff --git a/src/AssetManager.Web/Views/Companies/Index.cshtml b/src/AssetManager.Web/Views/Companies/Index.cshtml index 8a1768d..e60cf55 100644 --- a/src/AssetManager.Web/Views/Companies/Index.cshtml +++ b/src/AssetManager.Web/Views/Companies/Index.cshtml @@ -7,7 +7,7 @@

Index

- Create New + Create New

diff --git a/src/AssetManager.Web/Views/Shared/_Layout.cshtml b/src/AssetManager.Web/Views/Shared/_Layout.cshtml index 02f855b..4193637 100644 --- a/src/AssetManager.Web/Views/Shared/_Layout.cshtml +++ b/src/AssetManager.Web/Views/Shared/_Layout.cshtml @@ -205,7 +205,7 @@
- - - - - - - - - - - -@foreach (var item in Model) { - - - - - - - - -} - -
- @Html.DisplayNameFor(model => model.Name) - - @Html.DisplayNameFor(model => model.CreateDate) - - @Html.DisplayNameFor(model => model.UpdateDate) - - @Html.DisplayNameFor(model => model.ImageUrl) - - @Html.DisplayNameFor(model => model.Id) -
- @Html.DisplayFor(modelItem => item.Name) - - @Html.DisplayFor(modelItem => item.CreateDate) - - @Html.DisplayFor(modelItem => item.UpdateDate) - - @Html.DisplayFor(modelItem => item.ImageUrl) - - @Html.DisplayFor(modelItem => item.Id) - - @Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) | - @Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) | - @Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ }) -
+
+
+
+ + + + + + + + + + + @foreach (var item in Model) + { + + + + + + } + +
+ @Html.DisplayNameFor(model => model.Name) + + @Html.DisplayNameFor(model => model.ImageUrl) + Action
+ @Html.DisplayFor(modelItem => item.Name) + + @Html.DisplayFor(modelItem => item.ImageUrl) + + @Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) | + @Html.ActionLink("Details", "Details", new { id=item.Id }) | + @Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ }) +
+
+
From fb32ee5cd158c744aca64d5a233aadfb2dd38679 Mon Sep 17 00:00:00 2001 From: "Md. Aftab Uddin Kajal" Date: Fri, 27 Apr 2018 00:44:06 +0600 Subject: [PATCH 10/17] Company delete page added --- .../Controllers/CompaniesController.cs | 20 ++++++-- .../Views/Companies/Delete.cshtml | 50 +++++++++++++++++++ .../Views/Companies/Index.cshtml | 2 +- 3 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 src/AssetManager.Web/Views/Companies/Delete.cshtml diff --git a/src/AssetManager.Web/Controllers/CompaniesController.cs b/src/AssetManager.Web/Controllers/CompaniesController.cs index b84f65d..93f75d8 100644 --- a/src/AssetManager.Web/Controllers/CompaniesController.cs +++ b/src/AssetManager.Web/Controllers/CompaniesController.cs @@ -94,19 +94,33 @@ public async Task Details(int id) } // GET: Companies/Delete/5 - public ActionResult Delete(int id) + public async Task Delete(int id) { - return View(); + if (id == null) + { + return NotFound(); + } + var company = await _companyRepository.GetByIdAsync(id); + if (company == null) + { + return NotFound(); + } + return View(company); } // POST: Companies/Delete/5 [HttpPost] [ValidateAntiForgeryToken] - public ActionResult Delete(int id, IFormCollection collection) + public async Task Delete(int id, Company company) { + try { // TODO: Add delete logic here + if (id == company.Id) + { + await _companyRepository.DeleteAsync(company); + } return RedirectToAction(nameof(Index)); } diff --git a/src/AssetManager.Web/Views/Companies/Delete.cshtml b/src/AssetManager.Web/Views/Companies/Delete.cshtml new file mode 100644 index 0000000..a228c6d --- /dev/null +++ b/src/AssetManager.Web/Views/Companies/Delete.cshtml @@ -0,0 +1,50 @@ +@model AssetManager.Core.Entities.Company + +@{ + ViewData["Title"] = "Delete"; +} + +

Delete

+ +

Are you sure you want to delete this?

+
+

Company

+
+
+
+ @Html.DisplayNameFor(model => model.Name) +
+
+ @Html.DisplayFor(model => model.Name) +
+
+ @Html.DisplayNameFor(model => model.CreateDate) +
+
+ @Html.DisplayFor(model => model.CreateDate) +
+
+ @Html.DisplayNameFor(model => model.UpdateDate) +
+
+ @Html.DisplayFor(model => model.UpdateDate) +
+
+ @Html.DisplayNameFor(model => model.ImageUrl) +
+
+ @Html.DisplayFor(model => model.ImageUrl) +
+
+ @Html.DisplayNameFor(model => model.Id) +
+
+ @Html.DisplayFor(model => model.Id) +
+
+ +
+ | + Back to List +
+
diff --git a/src/AssetManager.Web/Views/Companies/Index.cshtml b/src/AssetManager.Web/Views/Companies/Index.cshtml index 4d289f4..3075bcf 100644 --- a/src/AssetManager.Web/Views/Companies/Index.cshtml +++ b/src/AssetManager.Web/Views/Companies/Index.cshtml @@ -42,7 +42,7 @@ @Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) | @Html.ActionLink("Details", "Details", new { id=item.Id }) | - @Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ }) + @Html.ActionLink("Delete", "Delete", new { id = item.Id }) } From 7ebc2c52b35ab66e79850ab5895b1ddefcfcbc79 Mon Sep 17 00:00:00 2001 From: "Md. Aftab Uddin Kajal" Date: Fri, 27 Apr 2018 01:12:11 +0600 Subject: [PATCH 11/17] Company Edit page added --- .../Controllers/CompaniesController.cs | 21 +++++-- .../Views/Companies/Details.cshtml | 2 +- .../Views/Companies/Edit.cshtml | 55 +++++++++++++++++++ .../Views/Companies/Index.cshtml | 2 +- 4 files changed, 74 insertions(+), 6 deletions(-) create mode 100644 src/AssetManager.Web/Views/Companies/Edit.cshtml diff --git a/src/AssetManager.Web/Controllers/CompaniesController.cs b/src/AssetManager.Web/Controllers/CompaniesController.cs index 93f75d8..82e855a 100644 --- a/src/AssetManager.Web/Controllers/CompaniesController.cs +++ b/src/AssetManager.Web/Controllers/CompaniesController.cs @@ -55,19 +55,32 @@ public async Task Create(Company company) } // GET: Companies/Edit/5 - public IActionResult Edit(int id) + public async Task Edit(int id) { - return View(); + if (id == null) + { + return NotFound(); + } + var company = await _companyRepository.GetByIdAsync(id); + if (company == null) + { + return NotFound(); + } + return View(company); } // POST: Companies/Edit/5 [HttpPost] [ValidateAntiForgeryToken] - public ActionResult Edit(int id, IFormCollection collection) + public async Task Edit(int id, Company company) { try { - // TODO: Add update logic here + if (id == company.Id) + { + company.UpdateDate = DateTime.Now; + await _companyRepository.UpdateAsync(company); + } return RedirectToAction(nameof(Index)); } diff --git a/src/AssetManager.Web/Views/Companies/Details.cshtml b/src/AssetManager.Web/Views/Companies/Details.cshtml index c047f93..d993a92 100644 --- a/src/AssetManager.Web/Views/Companies/Details.cshtml +++ b/src/AssetManager.Web/Views/Companies/Details.cshtml @@ -43,6 +43,6 @@
- @Html.ActionLink("Edit", "Edit", new { /* id = Model.PrimaryKey */ }) | + @Html.ActionLink("Edit", "Edit", new { id = Model.Id }) | Back to List
diff --git a/src/AssetManager.Web/Views/Companies/Edit.cshtml b/src/AssetManager.Web/Views/Companies/Edit.cshtml new file mode 100644 index 0000000..7e542b0 --- /dev/null +++ b/src/AssetManager.Web/Views/Companies/Edit.cshtml @@ -0,0 +1,55 @@ +@model AssetManager.Core.Entities.Company + +@{ + ViewData["Title"] = "Edit"; +} + +

Edit

+ +

Company

+
+
+ +
+
+
+ +
+
+
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ + +
+
+
+ +
+
+ +
+
+
+
+ + +@section Scripts { + @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} +} diff --git a/src/AssetManager.Web/Views/Companies/Index.cshtml b/src/AssetManager.Web/Views/Companies/Index.cshtml index 3075bcf..4453cfd 100644 --- a/src/AssetManager.Web/Views/Companies/Index.cshtml +++ b/src/AssetManager.Web/Views/Companies/Index.cshtml @@ -40,7 +40,7 @@ @Html.DisplayFor(modelItem => item.ImageUrl) - @Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) | + @Html.ActionLink("Edit", "Edit", new { id = item.Id }) | @Html.ActionLink("Details", "Details", new { id=item.Id }) | @Html.ActionLink("Delete", "Delete", new { id = item.Id }) From 62ec08c950e80613fd62e318aa08504acc31fb10 Mon Sep 17 00:00:00 2001 From: "Md. Aftab Uddin Kajal" Date: Fri, 27 Apr 2018 01:26:20 +0600 Subject: [PATCH 12/17] Supplier details page added --- .../Controllers/SupplierController.cs | 25 ++-- .../Views/Supplier/Details.cshtml | 126 ++++++++++++++++++ .../Views/Supplier/Index.cshtml | 8 +- 3 files changed, 145 insertions(+), 14 deletions(-) create mode 100644 src/AssetManager.Web/Views/Supplier/Details.cshtml diff --git a/src/AssetManager.Web/Controllers/SupplierController.cs b/src/AssetManager.Web/Controllers/SupplierController.cs index f7b3cb0..b5ca891 100644 --- a/src/AssetManager.Web/Controllers/SupplierController.cs +++ b/src/AssetManager.Web/Controllers/SupplierController.cs @@ -25,17 +25,7 @@ public async Task Index() return View(companies); } - // GET: Supplier/Details/5 - public IActionResult Details(int id) - { - if(id == null) - { - return NotFound(); - } - - return View(); - } // GET: Supplier/Create [HttpGet] @@ -98,6 +88,21 @@ public ActionResult Edit(int id, IFormCollection collection) } } + [HttpGet] + public async Task Details(int id) + { + if (id == null) + { + return NotFound(); + } + var supplier = await _supplierRepository.GetByIdAsync(id); + if (supplier == null) + { + return NotFound(); + } + return View(supplier); + } + // GET: Supplier/Delete/5 public ActionResult Delete(int id) { diff --git a/src/AssetManager.Web/Views/Supplier/Details.cshtml b/src/AssetManager.Web/Views/Supplier/Details.cshtml new file mode 100644 index 0000000..33c89ee --- /dev/null +++ b/src/AssetManager.Web/Views/Supplier/Details.cshtml @@ -0,0 +1,126 @@ +@model AssetManager.Core.Entities.Supplier + +@{ + ViewData["Title"] = "Details"; +} + +

Details

+ +
+

Supplier

+
+
+
+ @Html.DisplayNameFor(model => model.Name) +
+
+ @Html.DisplayFor(model => model.Name) +
+
+ @Html.DisplayNameFor(model => model.Address) +
+
+ @Html.DisplayFor(model => model.Address) +
+
+ @Html.DisplayNameFor(model => model.AddressTwo) +
+
+ @Html.DisplayFor(model => model.AddressTwo) +
+
+ @Html.DisplayNameFor(model => model.City) +
+
+ @Html.DisplayFor(model => model.City) +
+
+ @Html.DisplayNameFor(model => model.State) +
+
+ @Html.DisplayFor(model => model.State) +
+
+ @Html.DisplayNameFor(model => model.Country) +
+
+ @Html.DisplayFor(model => model.Country) +
+
+ @Html.DisplayNameFor(model => model.Phone) +
+
+ @Html.DisplayFor(model => model.Phone) +
+
+ @Html.DisplayNameFor(model => model.Fax) +
+
+ @Html.DisplayFor(model => model.Fax) +
+
+ @Html.DisplayNameFor(model => model.Email) +
+
+ @Html.DisplayFor(model => model.Email) +
+
+ @Html.DisplayNameFor(model => model.Contact) +
+
+ @Html.DisplayFor(model => model.Contact) +
+
+ @Html.DisplayNameFor(model => model.Notes) +
+
+ @Html.DisplayFor(model => model.Notes) +
+
+ @Html.DisplayNameFor(model => model.Zip) +
+
+ @Html.DisplayFor(model => model.Zip) +
+
+ @Html.DisplayNameFor(model => model.Url) +
+
+ @Html.DisplayFor(model => model.Url) +
+
+ @Html.DisplayNameFor(model => model.Image) +
+
+ @Html.DisplayFor(model => model.Image) +
+
+ @Html.DisplayNameFor(model => model.CreateAt) +
+
+ @Html.DisplayFor(model => model.CreateAt) +
+
+ @Html.DisplayNameFor(model => model.UpdatedAt) +
+
+ @Html.DisplayFor(model => model.UpdatedAt) +
+
+ @Html.DisplayNameFor(model => model.DeletedAt) +
+
+ @Html.DisplayFor(model => model.DeletedAt) +
+
+ @Html.DisplayNameFor(model => model.Id) +
+
+ @Html.DisplayFor(model => model.Id) +
+
+
+
+ @Html.ActionLink("Edit", "Edit", new { id = Model.Id }) | + Back to List +
diff --git a/src/AssetManager.Web/Views/Supplier/Index.cshtml b/src/AssetManager.Web/Views/Supplier/Index.cshtml index bf354cd..7babcf5 100644 --- a/src/AssetManager.Web/Views/Supplier/Index.cshtml +++ b/src/AssetManager.Web/Views/Supplier/Index.cshtml @@ -17,7 +17,7 @@
- +
@@ -116,9 +116,9 @@ } From 3adc80ec877026b12ee4dc43d4f07a90a62189c7 Mon Sep 17 00:00:00 2001 From: "Md. Aftab Uddin Kajal" Date: Fri, 27 Apr 2018 01:42:23 +0600 Subject: [PATCH 13/17] Supplier Edit page added --- .../Controllers/SupplierController.cs | 8 +- .../Views/Supplier/Create.cshtml | 3 +- .../Views/Supplier/Edit.cshtml | 157 ++++++++++++++++++ .../Views/Supplier/Index.cshtml | 11 +- 4 files changed, 169 insertions(+), 10 deletions(-) create mode 100644 src/AssetManager.Web/Views/Supplier/Edit.cshtml diff --git a/src/AssetManager.Web/Controllers/SupplierController.cs b/src/AssetManager.Web/Controllers/SupplierController.cs index b5ca891..4b09093 100644 --- a/src/AssetManager.Web/Controllers/SupplierController.cs +++ b/src/AssetManager.Web/Controllers/SupplierController.cs @@ -74,11 +74,15 @@ public async Task Edit(int id) // POST: Supplier/Edit/5 [HttpPost] [ValidateAntiForgeryToken] - public ActionResult Edit(int id, IFormCollection collection) + public async Task Edit(int id, Supplier supplier) { try { - // TODO: Add update logic here + if (id == supplier.Id) + { + supplier.UpdatedAt = DateTime.Now; + await _supplierRepository.UpdateAsync(supplier); + } return RedirectToAction(nameof(Index)); } diff --git a/src/AssetManager.Web/Views/Supplier/Create.cshtml b/src/AssetManager.Web/Views/Supplier/Create.cshtml index e67f906..a466ca7 100644 --- a/src/AssetManager.Web/Views/Supplier/Create.cshtml +++ b/src/AssetManager.Web/Views/Supplier/Create.cshtml @@ -14,7 +14,7 @@
-
+
@@ -140,6 +140,7 @@ + diff --git a/src/AssetManager.Web/Views/Supplier/Edit.cshtml b/src/AssetManager.Web/Views/Supplier/Edit.cshtml new file mode 100644 index 0000000..fd5bdaf --- /dev/null +++ b/src/AssetManager.Web/Views/Supplier/Edit.cshtml @@ -0,0 +1,157 @@ +@model AssetManager.Core.Entities.Supplier + +@{ + ViewData["Title"] = "Edit"; +} + +

Edit

+ +

Supplier

+
+
+ +
+
+
+ +
+
+
+ +
+ +
+ +
+ + +
+
+ + +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ +
+ +
+ + + +
+
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+
+ +
+ + +
+
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ + +
+ +
+ + +
+
+ +
+ +
+ +

Please upload Image here.

+ +
+
+
+ +
+ + +
+
+ +
+
+
+ +
+
+ +
+ + +
+
+
+ + + +@section Scripts { + @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} +} diff --git a/src/AssetManager.Web/Views/Supplier/Index.cshtml b/src/AssetManager.Web/Views/Supplier/Index.cshtml index 7babcf5..1443683 100644 --- a/src/AssetManager.Web/Views/Supplier/Index.cshtml +++ b/src/AssetManager.Web/Views/Supplier/Index.cshtml @@ -27,9 +27,7 @@
- + @@ -64,7 +62,7 @@ @Html.DisplayNameFor(model => model.Image) - + @@ -75,11 +73,10 @@ @Html.DisplayFor(modelItem => item.Name) - + From 8e8618a3dc63e4f7989d0b517410b1d87ac44bcb Mon Sep 17 00:00:00 2001 From: "Md. Aftab Uddin Kajal" Date: Fri, 27 Apr 2018 01:51:08 +0600 Subject: [PATCH 14/17] Supplier delete page added --- .../Controllers/SupplierController.cs | 20 ++- .../Views/Supplier/Delete.cshtml | 128 ++++++++++++++++++ 2 files changed, 144 insertions(+), 4 deletions(-) create mode 100644 src/AssetManager.Web/Views/Supplier/Delete.cshtml diff --git a/src/AssetManager.Web/Controllers/SupplierController.cs b/src/AssetManager.Web/Controllers/SupplierController.cs index 4b09093..23bc014 100644 --- a/src/AssetManager.Web/Controllers/SupplierController.cs +++ b/src/AssetManager.Web/Controllers/SupplierController.cs @@ -108,19 +108,31 @@ public async Task Details(int id) } // GET: Supplier/Delete/5 - public ActionResult Delete(int id) + public async Task Delete(int id) { - return View(); + if (id == null) + { + return NotFound(); + } + var supplier = await _supplierRepository.GetByIdAsync(id); + if (supplier == null) + { + return NotFound(); + } + return View(supplier); } // POST: Supplier/Delete/5 [HttpPost] [ValidateAntiForgeryToken] - public ActionResult Delete(int id, IFormCollection collection) + public async Task Delete(int id, Supplier supplier) { try { - // TODO: Add delete logic here + if (id == supplier.Id) + { + await _supplierRepository.DeleteAsync(supplier); + } return RedirectToAction(nameof(Index)); } diff --git a/src/AssetManager.Web/Views/Supplier/Delete.cshtml b/src/AssetManager.Web/Views/Supplier/Delete.cshtml new file mode 100644 index 0000000..84e1ba2 --- /dev/null +++ b/src/AssetManager.Web/Views/Supplier/Delete.cshtml @@ -0,0 +1,128 @@ +@model AssetManager.Core.Entities.Supplier + +@{ + ViewData["Title"] = "Delete"; +} + +

Delete

+ +

Are you sure you want to delete this?

+
+

Supplier

+
+
+
+ @Html.DisplayNameFor(model => model.Name) +
+
+ @Html.DisplayFor(model => model.Name) +
+
+ @Html.DisplayNameFor(model => model.Address) +
+
+ @Html.DisplayFor(model => model.Address) +
+
+ @Html.DisplayNameFor(model => model.AddressTwo) +
+
+ @Html.DisplayFor(model => model.AddressTwo) +
+
+ @Html.DisplayNameFor(model => model.City) +
+
+ @Html.DisplayFor(model => model.City) +
+
+ @Html.DisplayNameFor(model => model.State) +
+
+ @Html.DisplayFor(model => model.State) +
+
+ @Html.DisplayNameFor(model => model.Country) +
+
+ @Html.DisplayFor(model => model.Country) +
+
+ @Html.DisplayNameFor(model => model.Phone) +
+
+ @Html.DisplayFor(model => model.Phone) +
+
+ @Html.DisplayNameFor(model => model.Fax) +
+
+ @Html.DisplayFor(model => model.Fax) +
+
+ @Html.DisplayNameFor(model => model.Email) +
+
+ @Html.DisplayFor(model => model.Email) +
+
+ @Html.DisplayNameFor(model => model.Contact) +
+
+ @Html.DisplayFor(model => model.Contact) +
+
+ @Html.DisplayNameFor(model => model.Notes) +
+
+ @Html.DisplayFor(model => model.Notes) +
+
+ @Html.DisplayNameFor(model => model.Zip) +
+
+ @Html.DisplayFor(model => model.Zip) +
+
+ @Html.DisplayNameFor(model => model.Url) +
+
+ @Html.DisplayFor(model => model.Url) +
+
+ @Html.DisplayNameFor(model => model.Image) +
+
+ @Html.DisplayFor(model => model.Image) +
+
+ @Html.DisplayNameFor(model => model.CreateAt) +
+
+ @Html.DisplayFor(model => model.CreateAt) +
+
+ @Html.DisplayNameFor(model => model.UpdatedAt) +
+
+ @Html.DisplayFor(model => model.UpdatedAt) +
+
+ @Html.DisplayNameFor(model => model.DeletedAt) +
+
+ @Html.DisplayFor(model => model.DeletedAt) +
+
+ @Html.DisplayNameFor(model => model.Id) +
+
+ @Html.DisplayFor(model => model.Id) +
+
+ +
+ | + Back to List + +
From b56d74aadcebd04cea1e554fa5db3182f3949561 Mon Sep 17 00:00:00 2001 From: "Md. Aftab Uddin Kajal" Date: Fri, 27 Apr 2018 21:05:33 +0600 Subject: [PATCH 15/17] some page modified --- .../Controllers/CompaniesController.cs | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/AssetManager.Web/Controllers/CompaniesController.cs b/src/AssetManager.Web/Controllers/CompaniesController.cs index 82e855a..413c594 100644 --- a/src/AssetManager.Web/Controllers/CompaniesController.cs +++ b/src/AssetManager.Web/Controllers/CompaniesController.cs @@ -30,7 +30,7 @@ public async Task Index() // GET: Companies/Create - + [HttpGet] public IActionResult Create() { return View(); @@ -55,16 +55,14 @@ public async Task Create(Company company) } // GET: Companies/Edit/5 + [HttpGet] public async Task Edit(int id) { - if (id == null) - { - return NotFound(); - } + var company = await _companyRepository.GetByIdAsync(id); if (company == null) { - return NotFound(); + return RedirectToAction(nameof(Index)); } return View(company); } @@ -94,29 +92,24 @@ public async Task Edit(int id, Company company) [HttpGet] public async Task Details(int id) { - if (id == null) - { - return NotFound(); - } + var company = await _companyRepository.GetByIdAsync(id); if (company == null) { - return NotFound(); + return RedirectToAction(nameof(Index)); } return View(company); } // GET: Companies/Delete/5 + [HttpGet] public async Task Delete(int id) { - if (id == null) - { - return NotFound(); - } + var company = await _companyRepository.GetByIdAsync(id); if (company == null) { - return NotFound(); + return RedirectToAction(nameof(Index)); } return View(company); } From c66d6f5cf3d198c580a7fc44694aa39491d5bc9b Mon Sep 17 00:00:00 2001 From: "Md. Aftab Uddin Kajal" Date: Tue, 15 May 2018 16:53:03 +0600 Subject: [PATCH 16/17] Suplier controller modified --- .../Controllers/SupplierController.cs | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/AssetManager.Web/Controllers/SupplierController.cs b/src/AssetManager.Web/Controllers/SupplierController.cs index 23bc014..f5d008e 100644 --- a/src/AssetManager.Web/Controllers/SupplierController.cs +++ b/src/AssetManager.Web/Controllers/SupplierController.cs @@ -36,13 +36,16 @@ public IActionResult Create() } // POST: Supplier/Create - [HttpPost] + [HttpPost, ActionName("Create")] [ValidateAntiForgeryToken] - public async Task Create(Supplier Supplier) + public async Task Insert(Supplier Supplier) { + if(Supplier == null) + { + return RedirectToAction(nameof(Create)); + } try { - // TODO: Add insert logic here await _supplierRepository.AddAsync(Supplier); @@ -56,11 +59,11 @@ public async Task Create(Supplier Supplier) // GET: Supplier/Edit/5 [HttpGet] - public async Task Edit(int id) + public async Task Edit(int id = 0) { - if (id == null) + if (id >= 0) { - return NotFound(); + return RedirectToAction(nameof(Index)); } var supplier = await _supplierRepository.GetByIdAsync(id); @@ -93,39 +96,39 @@ public async Task Edit(int id, Supplier supplier) } [HttpGet] - public async Task Details(int id) + public async Task Details(int id=0) { - if (id == null) + if (id >= 0) { - return NotFound(); + return RedirectToAction(nameof(Index)); } var supplier = await _supplierRepository.GetByIdAsync(id); if (supplier == null) { - return NotFound(); + return RedirectToAction(nameof(Index)); } return View(supplier); } // GET: Supplier/Delete/5 - public async Task Delete(int id) + public async Task Delete(int id=0) { - if (id == null) + if (id >= 0) { - return NotFound(); + return RedirectToAction(nameof(Index)); } var supplier = await _supplierRepository.GetByIdAsync(id); if (supplier == null) { - return NotFound(); + return RedirectToAction(nameof(Index)); } return View(supplier); } // POST: Supplier/Delete/5 - [HttpPost] + [HttpPost, ActionName("Delete")] [ValidateAntiForgeryToken] - public async Task Delete(int id, Supplier supplier) + public async Task DeleteConfirmed(int id, Supplier supplier) { try { From 937e866e12a7307043acb372868b559c73779590 Mon Sep 17 00:00:00 2001 From: "Md. Aftab Uddin Kajal" Date: Tue, 15 May 2018 19:19:10 +0600 Subject: [PATCH 17/17] Company controller modified --- .../Controllers/CompaniesController.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/AssetManager.Web/Controllers/CompaniesController.cs b/src/AssetManager.Web/Controllers/CompaniesController.cs index 413c594..7fe2687 100644 --- a/src/AssetManager.Web/Controllers/CompaniesController.cs +++ b/src/AssetManager.Web/Controllers/CompaniesController.cs @@ -90,8 +90,12 @@ public async Task Edit(int id, Company company) // GET: Companies/Details/5 [HttpGet] - public async Task Details(int id) + public async Task Details(int id = 0) { + if (id >= 0) + { + return RedirectToAction(nameof(Index)); + } var company = await _companyRepository.GetByIdAsync(id); if (company == null) @@ -103,8 +107,12 @@ public async Task Details(int id) // GET: Companies/Delete/5 [HttpGet] - public async Task Delete(int id) + public async Task Delete(int id = 0) { + if (id >= 0) + { + return RedirectToAction(nameof(Index)); + } var company = await _companyRepository.GetByIdAsync(id); if (company == null) @@ -115,14 +123,14 @@ public async Task Delete(int id) } // POST: Companies/Delete/5 - [HttpPost] + [HttpPost, ActionName("Delete")] [ValidateAntiForgeryToken] - public async Task Delete(int id, Company company) + public async Task DeleteConfirmed(int id, Company company) { try { - // TODO: Add delete logic here + if (id == company.Id) { await _companyRepository.DeleteAsync(company);
- @Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) | - @Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) | - @Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ }) + @Html.ActionLink("Edit", "Edit", new { id=item.Id }) | + @Html.ActionLink("Details", "Details", new { id = item.Id }) | + @Html.ActionLink("Delete", "Delete", new { id = item.Id })
@Html.DisplayNameFor(model => model.Address) - @Html.DisplayNameFor(model => model.AddressTwo) - @Html.DisplayNameFor(model => model.City) Action
- @Html.DisplayFor(modelItem => item.Address) - + @Html.DisplayFor(modelItem => item.Address), @Html.DisplayFor(modelItem => item.AddressTwo) @Html.DisplayFor(modelItem => item.City)