Skip to content

Commit d914dfb

Browse files
committed
Dashboard/Categories
1 parent f59926e commit d914dfb

File tree

81 files changed

+669
-24325
lines changed

Some content is hidden

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

81 files changed

+669
-24325
lines changed
0 Bytes
Binary file not shown.

.vs/BookStore/v16/.suo

14.5 KB
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
-3.38 MB
Binary file not shown.

BookStore/Areas/Dashboard/Controllers/CategoryController.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,14 @@ public ActionResult Create()
4141

4242
// POST: Category/Create
4343
[HttpPost]
44-
[ValidateAntiForgeryToken]
44+
//[ValidateAntiForgeryToken]
4545
public IActionResult _AddOrEdit(Models.Category category)
4646
{
47+
if (!ModelState.IsValid)
48+
{
49+
return BadRequest(ModelState);
50+
}
51+
4752
if (_categoryRepo.AddEdit(category))
4853
{
4954
return Json(new { success = true, message = "Saved Successfully" });

BookStore/Areas/Dashboard/Views/Home/Categories.cshtml

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
@model Category
22
@{
33
ViewData["Title"] = "Books";
4+
//var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
5+
//string objJson = serializer.Serialize(Model);
46
}
57

68
<div class="row">
@@ -24,7 +26,7 @@
2426
<div class="tile">
2527
<h3 class="tile-title">Add Category</h3>
2628
<div class="tile-body">
27-
<form action="/Dashboard/Category/_AddOrEdit" method="post" id="form1" onsubmit="submitForm(this)">
29+
<form id="form1">
2830
<input type="hidden" asp-for="Id" value="0" />
2931
<div class="form-group">
3032
<label class="control-label">Name</label>
@@ -37,7 +39,7 @@
3739
</form>
3840
</div>
3941
<div class="tile-footer">
40-
<button class="btn btn-primary" type="submit" form="form1"><i class="fa fa-fw fa-lg fa-check-circle"></i>Add</button>&nbsp;&nbsp;&nbsp;<a class="btn btn-secondary" href="#"><i class="fa fa-fw fa-lg fa-times-circle"></i>Cancel</a>
42+
<button class="btn btn-primary" type="button" onclick="submitForm('#form1')"><i class="fa fa-fw fa-lg fa-check-circle"></i>Add</button>&nbsp;&nbsp;&nbsp;<a class="btn btn-secondary" href="#"><i class="fa fa-fw fa-lg fa-times-circle"></i>Cancel</a>
4143
</div>
4244
</div>
4345
</div>
@@ -73,39 +75,27 @@
7375
7476
//For Refresh DataTable while closing Popup Dialog
7577
function submitForm(form1) {
76-
alert(form1.action);
77-
$(form1).submit(function (e) {
78-
e.preventDefault();
79-
var url = form1.action;
80-
var method = form1.method;
81-
82-
});
83-
return this;
84-
//$(form1).submit(function (e) {
85-
// e.preventDefault();
86-
87-
// var url = "/Dashboard/Category/_AddOrEdit";
88-
// alert(url);
78+
var obj = $(form1).serialize();
8979
90-
// $.ajax({
91-
// type: "POST",
92-
// url: url,
93-
// data: $(form1).serialize(),
94-
// dataType: "json",
95-
// contentType: 'application/json',
96-
// success: function (data) {
97-
// if (data.success) {
98-
// dataTable.ajax.reload();
99-
// alert(data.message);
100-
// //$.notify(data.message, {
101-
// // globalPosition: "top center",
102-
// // className: "success",
103-
// //});
104-
// }
105-
// }
106-
// });
107-
// //return false;
108-
//});
80+
$.ajax({
81+
type: "post",
82+
url: "/Dashboard/Category/_AddOrEdit",
83+
data: obj,
84+
dataType: "json",
85+
contentType: 'application/x-www-form-urlencoded; charset=utf-8',
86+
success: function (data) {
87+
if (data.success) {
88+
dataTable.ajax.reload();
89+
alert(data.message);
90+
//$.notify(data.message, {
91+
// globalPosition: "top center",
92+
// className: "success",
93+
//});
94+
} else {
95+
alert("sorry");
96+
}
97+
}
98+
});
10999
}
110100
111101
if (document.location.hostname == 'pratikborsadiya.in') {

BookStore/Areas/Dashboard/Views/Shared/_LoginPartial.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<li><a class="dropdown-item" href="page-user.html"><i class="fa fa-user fa-lg"></i> Profile</a></li>
1414
<li>
1515
<a class="dropdown-item" href="javascript:document.getElementById('logoutForm').submit()"><i class="fa fa-sign-out fa-lg"></i> Logout</a>
16-
<form action="Account/Logout" id="logoutForm" method="post">
16+
<form action="~/Account/Logout" id="logoutForm" method="post">
1717
</form>
1818
</li>
1919
</ul>

BookStore/BookStore.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<ItemGroup>
1313
<PackageReference Include="Microsoft.AspNetCore.App" />
1414
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" PrivateAssets="All" />
15+
<PackageReference Include="Microsoft.jQuery.Unobtrusive.Validation" Version="3.2.11" />
1516
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.10" />
1617
</ItemGroup>
1718

Binary file not shown.

0 commit comments

Comments
 (0)