Skip to content

Commit 2f7f57e

Browse files
committed
update 16 Jan
1 parent e5221fa commit 2f7f57e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+809
-1331
lines changed
676 Bytes
Binary file not shown.

.vs/BookStore/v16/.suo

11 KB
Binary file not shown.
16 KB
Binary file not shown.
0 Bytes
Binary file not shown.
Binary file not shown.
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using BookStore.Data.Interface;
6+
using Microsoft.AspNetCore.Http;
7+
using Microsoft.AspNetCore.Mvc;
8+
9+
namespace BookStore.Areas.Dashboard.Controllers
10+
{
11+
// Dashboard/..
12+
[Area("Dashboard")]
13+
public class CategoryController : Controller
14+
{
15+
private readonly ICategoryRepository _categoryRepo;
16+
public CategoryController(ICategoryRepository categoryRepository)
17+
{
18+
_categoryRepo = categoryRepository;
19+
}
20+
21+
// GET: Dashboard/Category/GetData
22+
public ActionResult GetData()
23+
{
24+
//List<Models.Category> categories = _categoryRepo.Categories.ToList();
25+
List<Models.Category> categories = new List<Models.Category>
26+
{
27+
new Models.Category{ Name="Hello", Description="xxx",Id = 1},
28+
new Models.Category{ Name="Hello", Description="xxx",Id = 2},
29+
new Models.Category{ Name="Hello", Description="xxx",Id = 3},
30+
new Models.Category{ Name="Hello", Description="xxx",Id = 4},
31+
};
32+
return Json(new { data = categories });
33+
////return new JsonResult(categories);
34+
//return View(categories);
35+
}
36+
37+
// GET: Category/Details/5
38+
public ActionResult Details(int id)
39+
{
40+
return View();
41+
}
42+
43+
// GET: Category/Create
44+
public ActionResult Create()
45+
{
46+
return View();
47+
}
48+
49+
// POST: Category/Create
50+
[HttpPost]
51+
[ValidateAntiForgeryToken]
52+
public ActionResult Create(IFormCollection collection)
53+
{
54+
try
55+
{
56+
// TODO: Add insert logic here
57+
58+
return RedirectToAction(nameof(GetData));
59+
}
60+
catch
61+
{
62+
return View();
63+
}
64+
}
65+
66+
// GET: Category/Edit/5
67+
public ActionResult Edit(int id)
68+
{
69+
return View();
70+
}
71+
72+
// POST: Category/Edit/5
73+
[HttpPost]
74+
[ValidateAntiForgeryToken]
75+
public ActionResult Edit(int id, IFormCollection collection)
76+
{
77+
try
78+
{
79+
// TODO: Add update logic here
80+
81+
return RedirectToAction(nameof(GetData));
82+
}
83+
catch
84+
{
85+
return View();
86+
}
87+
}
88+
89+
// GET: Category/Delete/5
90+
public ActionResult Delete(int id)
91+
{
92+
return View();
93+
}
94+
95+
// POST: Category/Delete/5
96+
[HttpPost]
97+
[ValidateAntiForgeryToken]
98+
public ActionResult Delete(int id, IFormCollection collection)
99+
{
100+
try
101+
{
102+
// TODO: Add delete logic here
103+
104+
return RedirectToAction(nameof(GetData));
105+
}
106+
catch
107+
{
108+
return View();
109+
}
110+
}
111+
}
112+
}

BookStore/Areas/Dashboard/Controllers/HomeController.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Threading.Tasks;
5+
using BookStore.Data.Interface;
56
using Microsoft.AspNetCore.Authorization;
67
using Microsoft.AspNetCore.Http;
78
using Microsoft.AspNetCore.Mvc;
@@ -12,22 +13,33 @@ namespace BookStore.Areas.Dashboard.Controllers
1213
[Authorize]
1314
public class HomeController : Controller
1415
{
16+
private readonly ICategoryRepository _categoryRepo;
17+
private readonly IBookRepository _bookRepo;
18+
public HomeController(ICategoryRepository categoryRepository,IBookRepository bookRepository)
19+
{
20+
_categoryRepo = categoryRepository;
21+
_bookRepo = bookRepository;
22+
}
23+
1524
// GET: Home
1625
public ActionResult Index()
1726
{
27+
//var list = _categoryRepo.Categories;
1828
return View();
1929
}
2030

2131
// GET: Books
2232
public IActionResult Categories()
2333
{
24-
return View();
34+
var listItem = _categoryRepo.Categories;
35+
return View(listItem);
2536
}
2637

2738
// GET: Books
2839
public IActionResult Books()
2940
{
30-
return View();
41+
var listItem = _bookRepo.Books;
42+
return View(listItem);
3143
}
3244
}
3345
}

0 commit comments

Comments
 (0)