Skip to content

Commit

Permalink
Delete Post Metod from CategoryConteroller
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKhatibian committed Oct 5, 2023
1 parent 843c110 commit c1004c8
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 45 deletions.
Binary file modified .vs/WebMarket/v16/.suo
Binary file not shown.
24 changes: 4 additions & 20 deletions WebMarketApp/Controllers/CategoryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,26 +106,10 @@ public IActionResult Delete(int? id)
{
return NotFound();
}

return View(categoryFromDb);
}

//Post For Delete
[HttpPost]
public IActionResult Delete(Category obj)
{
if (obj.Name == obj.DisplayOrder.ToString())
{
ModelState.AddModelError("Name", "مقدرا فیلد ها نباید یکسان باشد");
}
if (ModelState.IsValid)
{
_db.Categories.Remove(obj);
_db.SaveChanges();
TempData["Success"] = "دسته با مو فقیت حذف شد";
return RedirectToAction("Index");
}
return View();
_db.Categories.Remove(categoryFromDb);
_db.SaveChanges();
TempData["Success"] = "دسته با مو فقیت حذف شد";
return RedirectToAction("Index");
}
}
}
Binary file modified WebMarketApp/bin/Debug/net5.0/WebMarketApp.Views.dll
Binary file not shown.
Binary file modified WebMarketApp/bin/Debug/net5.0/WebMarketApp.Views.pdb
Binary file not shown.
Binary file modified WebMarketApp/bin/Debug/net5.0/WebMarketApp.dll
Binary file not shown.
Binary file modified WebMarketApp/bin/Debug/net5.0/WebMarketApp.pdb
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma checksum "C:\Users\Khatibian\source\repos\WebMarket\WebMarketApp\Views\Category\Delete.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "716bab6ba0a39819c1d42320fe9ac1fcda250226"
#pragma checksum "C:\Users\Khatibian\source\repos\WebMarket\WebMarketApp\Views\Category\Delete.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "0458ff3fb53367126784f8358410a8acfb212f57"
// <auto-generated/>
#pragma warning disable 1591
[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.Views_Category_Delete), @"mvc.1.0.view", @"/Views/Category/Delete.cshtml")]
Expand Down Expand Up @@ -26,7 +26,7 @@ namespace AspNetCore
#line default
#line hidden
#nullable disable
[global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"716bab6ba0a39819c1d42320fe9ac1fcda250226", @"/Views/Category/Delete.cshtml")]
[global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"0458ff3fb53367126784f8358410a8acfb212f57", @"/Views/Category/Delete.cshtml")]
[global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"0cc420133c922e1be44a5d36a8b4d6b0e07171a9", @"/Views/_ViewImports.cshtml")]
public class Views_Category_Delete : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<Category>
{
Expand Down Expand Up @@ -78,10 +78,10 @@ public class Views_Category_Delete : global::Microsoft.AspNetCore.Mvc.Razor.Razo
#line hidden
#nullable disable
WriteLiteral("\r\n");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("form", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "716bab6ba0a39819c1d42320fe9ac1fcda2502267060", async() => {
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("form", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "0458ff3fb53367126784f8358410a8acfb212f577060", async() => {
WriteLiteral("\r\n <div class=\"p-4\"> \r\n <div class=\"border p-2 mt-2\">\r\n <div class=\"row pb-2 text-center\">\r\n <h4>حذف دسته</h4>\r\n <hr />\r\n </div>\r\n");
WriteLiteral(" <div class=\"mb-2\">\r\n ");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("label", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "716bab6ba0a39819c1d42320fe9ac1fcda2502267621", async() => {
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("label", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "0458ff3fb53367126784f8358410a8acfb212f577621", async() => {
}
);
__Microsoft_AspNetCore_Mvc_TagHelpers_LabelTagHelper = CreateTagHelper<global::Microsoft.AspNetCore.Mvc.TagHelpers.LabelTagHelper>();
Expand All @@ -102,7 +102,7 @@ public class Views_Category_Delete : global::Microsoft.AspNetCore.Mvc.Razor.Razo
Write(__tagHelperExecutionContext.Output);
__tagHelperExecutionContext = __tagHelperScopeManager.End();
WriteLiteral("\r\n ");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "716bab6ba0a39819c1d42320fe9ac1fcda2502269130", async() => {
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "0458ff3fb53367126784f8358410a8acfb212f579130", async() => {
}
);
__Microsoft_AspNetCore_Mvc_TagHelpers_InputTagHelper = CreateTagHelper<global::Microsoft.AspNetCore.Mvc.TagHelpers.InputTagHelper>();
Expand All @@ -115,6 +115,9 @@ public class Views_Category_Delete : global::Microsoft.AspNetCore.Mvc.Razor.Razo
#line hidden
#nullable disable
__tagHelperExecutionContext.AddTagHelperAttribute("asp-for", __Microsoft_AspNetCore_Mvc_TagHelpers_InputTagHelper.For, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes);
BeginWriteTagHelperAttribute();
__tagHelperStringValueBuffer = EndWriteTagHelperAttribute();
__tagHelperExecutionContext.AddHtmlAttribute("disabled", Html.Raw(__tagHelperStringValueBuffer), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.Minimized);
__tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_0);
await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
if (!__tagHelperExecutionContext.Output.IsContentModified)
Expand All @@ -124,7 +127,7 @@ public class Views_Category_Delete : global::Microsoft.AspNetCore.Mvc.Razor.Razo
Write(__tagHelperExecutionContext.Output);
__tagHelperExecutionContext = __tagHelperScopeManager.End();
WriteLiteral("\r\n ");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("span", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "716bab6ba0a39819c1d42320fe9ac1fcda25022610720", async() => {
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("span", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "0458ff3fb53367126784f8358410a8acfb212f5711043", async() => {
}
);
__Microsoft_AspNetCore_Mvc_TagHelpers_ValidationMessageTagHelper = CreateTagHelper<global::Microsoft.AspNetCore.Mvc.TagHelpers.ValidationMessageTagHelper>();
Expand All @@ -146,7 +149,7 @@ public class Views_Category_Delete : global::Microsoft.AspNetCore.Mvc.Razor.Razo
Write(__tagHelperExecutionContext.Output);
__tagHelperExecutionContext = __tagHelperScopeManager.End();
WriteLiteral("\r\n <br />\r\n ");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("label", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "716bab6ba0a39819c1d42320fe9ac1fcda25022612413", async() => {
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("label", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "0458ff3fb53367126784f8358410a8acfb212f5712736", async() => {
}
);
__Microsoft_AspNetCore_Mvc_TagHelpers_LabelTagHelper = CreateTagHelper<global::Microsoft.AspNetCore.Mvc.TagHelpers.LabelTagHelper>();
Expand All @@ -167,7 +170,7 @@ public class Views_Category_Delete : global::Microsoft.AspNetCore.Mvc.Razor.Razo
Write(__tagHelperExecutionContext.Output);
__tagHelperExecutionContext = __tagHelperScopeManager.End();
WriteLiteral("\r\n ");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "716bab6ba0a39819c1d42320fe9ac1fcda25022613931", async() => {
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "0458ff3fb53367126784f8358410a8acfb212f5714254", async() => {
}
);
__Microsoft_AspNetCore_Mvc_TagHelpers_InputTagHelper = CreateTagHelper<global::Microsoft.AspNetCore.Mvc.TagHelpers.InputTagHelper>();
Expand All @@ -180,6 +183,9 @@ public class Views_Category_Delete : global::Microsoft.AspNetCore.Mvc.Razor.Razo
#line hidden
#nullable disable
__tagHelperExecutionContext.AddTagHelperAttribute("asp-for", __Microsoft_AspNetCore_Mvc_TagHelpers_InputTagHelper.For, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes);
BeginWriteTagHelperAttribute();
__tagHelperStringValueBuffer = EndWriteTagHelperAttribute();
__tagHelperExecutionContext.AddHtmlAttribute("disabled", Html.Raw(__tagHelperStringValueBuffer), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.Minimized);
__tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_0);
await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
if (!__tagHelperExecutionContext.Output.IsContentModified)
Expand All @@ -189,7 +195,7 @@ public class Views_Category_Delete : global::Microsoft.AspNetCore.Mvc.Razor.Razo
Write(__tagHelperExecutionContext.Output);
__tagHelperExecutionContext = __tagHelperScopeManager.End();
WriteLiteral("\r\n ");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("span", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "716bab6ba0a39819c1d42320fe9ac1fcda25022615530", async() => {
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("span", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "0458ff3fb53367126784f8358410a8acfb212f5716176", async() => {
}
);
__Microsoft_AspNetCore_Mvc_TagHelpers_ValidationMessageTagHelper = CreateTagHelper<global::Microsoft.AspNetCore.Mvc.TagHelpers.ValidationMessageTagHelper>();
Expand All @@ -211,7 +217,7 @@ public class Views_Category_Delete : global::Microsoft.AspNetCore.Mvc.Razor.Razo
Write(__tagHelperExecutionContext.Output);
__tagHelperExecutionContext = __tagHelperScopeManager.End();
WriteLiteral("\r\n </div>\r\n <button type=\"submit\" class=\"btn btn-primary\" style=\"width: 150px\" >حذف</button>\r\n ");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "716bab6ba0a39819c1d42320fe9ac1fcda25022617325", async() => {
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "0458ff3fb53367126784f8358410a8acfb212f5717971", async() => {
WriteLiteral("بازگشت به دسته بندی");
}
);
Expand Down Expand Up @@ -251,7 +257,7 @@ public class Views_Category_Delete : global::Microsoft.AspNetCore.Mvc.Razor.Razo
WriteLiteral("\r\n");
DefineSection("Scripts", async() => {
WriteLiteral("\r\n ");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("partial", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "716bab6ba0a39819c1d42320fe9ac1fcda25022620461", async() => {
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("partial", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "0458ff3fb53367126784f8358410a8acfb212f5721107", async() => {
}
);
__Microsoft_AspNetCore_Mvc_TagHelpers_PartialTagHelper = CreateTagHelper<global::Microsoft.AspNetCore.Mvc.TagHelpers.PartialTagHelper>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma checksum "C:\Users\Khatibian\source\repos\WebMarket\WebMarketApp\Views\Category\Index.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "364ff77239d01aea191cafbb212d3340b7458c4a"
#pragma checksum "C:\Users\Khatibian\source\repos\WebMarket\WebMarketApp\Views\Category\Index.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "a4351bb796ae9c2e19546a483c6a767f23c57deb"
// <auto-generated/>
#pragma warning disable 1591
[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.Views_Category_Index), @"mvc.1.0.view", @"/Views/Category/Index.cshtml")]
Expand Down Expand Up @@ -26,7 +26,7 @@ namespace AspNetCore
#line default
#line hidden
#nullable disable
[global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"364ff77239d01aea191cafbb212d3340b7458c4a", @"/Views/Category/Index.cshtml")]
[global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"a4351bb796ae9c2e19546a483c6a767f23c57deb", @"/Views/Category/Index.cshtml")]
[global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"0cc420133c922e1be44a5d36a8b4d6b0e07171a9", @"/Views/_ViewImports.cshtml")]
public class Views_Category_Index : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<IEnumerable<Category>>
{
Expand Down Expand Up @@ -67,8 +67,33 @@ public class Views_Category_Index : global::Microsoft.AspNetCore.Mvc.Razor.Razor
#line default
#line hidden
#nullable disable
WriteLiteral("\r\n<div class=\"container p-3\">\r\n <div class=\"row pt-4\">\r\n <div class=\"col-6 text-center\">\r\n <h4 class=\"text-light\">لیست دسته بندی</h4>\r\n </div>\r\n <div class=\"col-6 text-end\">\r\n ");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "364ff77239d01aea191cafbb212d3340b7458c4a5108", async() => {
WriteLiteral("\r\n<div class=\"container p-3\">\r\n");
#nullable restore
#line 7 "C:\Users\Khatibian\source\repos\WebMarket\WebMarketApp\Views\Category\Index.cshtml"
if (TempData["Success"] != null)
{

#line default
#line hidden
#nullable disable
WriteLiteral(" <div class=\"text-end\">\r\n <h3 class=\"text-danger\">\r\n ");
#nullable restore
#line 11 "C:\Users\Khatibian\source\repos\WebMarket\WebMarketApp\Views\Category\Index.cshtml"
Write(TempData["Success"]);

#line default
#line hidden
#nullable disable
WriteLiteral("\r\n </h3>\r\n </div>\r\n");
#nullable restore
#line 14 "C:\Users\Khatibian\source\repos\WebMarket\WebMarketApp\Views\Category\Index.cshtml"
}

#line default
#line hidden
#nullable disable
WriteLiteral("\r\n <div class=\"row pt-4\">\r\n <div class=\"col-6 text-center\">\r\n <h4 class=\"text-light\">لیست دسته بندی</h4>\r\n </div>\r\n <div class=\"col-6 text-end\">\r\n ");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "a4351bb796ae9c2e19546a483c6a767f23c57deb5902", async() => {
WriteLiteral("\r\n <i class=\"bi bi-plus-circle-dotted\"></i> ایجاد دسته جدید\r\n ");
}
);
Expand Down Expand Up @@ -102,13 +127,13 @@ Name Of Type
</th>
<th>
Edit
</th>
</th>
</tr>
</thead>
<tbody>
");
#nullable restore
#line 34 "C:\Users\Khatibian\source\repos\WebMarket\WebMarketApp\Views\Category\Index.cshtml"
#line 43 "C:\Users\Khatibian\source\repos\WebMarket\WebMarketApp\Views\Category\Index.cshtml"
foreach (var obj in Model)
{

Expand All @@ -117,22 +142,22 @@ Name Of Type
#nullable disable
WriteLiteral(" <tr>\r\n <td width=\"50%\">\r\n ");
#nullable restore
#line 38 "C:\Users\Khatibian\source\repos\WebMarket\WebMarketApp\Views\Category\Index.cshtml"
#line 47 "C:\Users\Khatibian\source\repos\WebMarket\WebMarketApp\Views\Category\Index.cshtml"
Write(obj.Name);

#line default
#line hidden
#nullable disable
WriteLiteral("\r\n </td>\r\n <td width=\"30%\">\r\n ");
#nullable restore
#line 41 "C:\Users\Khatibian\source\repos\WebMarket\WebMarketApp\Views\Category\Index.cshtml"
#line 50 "C:\Users\Khatibian\source\repos\WebMarket\WebMarketApp\Views\Category\Index.cshtml"
Write(obj.DisplayOrder);

#line default
#line hidden
#nullable disable
WriteLiteral("\r\n </td>\r\n <td>\r\n <div class=\"w-75 btn-group\" role=\"group\">\r\n ");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "364ff77239d01aea191cafbb212d3340b7458c4a8163", async() => {
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "a4351bb796ae9c2e19546a483c6a767f23c57deb8941", async() => {
WriteLiteral("<i class=\"bi bi-pencil-fill\"></i> ویرایش");
}
);
Expand All @@ -148,7 +173,7 @@ Name Of Type
}
BeginWriteTagHelperAttribute();
#nullable restore
#line 45 "C:\Users\Khatibian\source\repos\WebMarket\WebMarketApp\Views\Category\Index.cshtml"
#line 54 "C:\Users\Khatibian\source\repos\WebMarket\WebMarketApp\Views\Category\Index.cshtml"
WriteLiteral(obj.ID);

#line default
Expand All @@ -164,8 +189,8 @@ Name Of Type
}
Write(__tagHelperExecutionContext.Output);
__tagHelperExecutionContext = __tagHelperScopeManager.End();
WriteLiteral("\r\n </div>\r\n <div class=\"w-75 btn-group\" role=\"group\">\r\n ");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "364ff77239d01aea191cafbb212d3340b7458c4a10729", async() => {
WriteLiteral("\r\n </div>\r\n <br />\r\n <div class=\"w-75 btn-group\" role=\"group\">\r\n ");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "a4351bb796ae9c2e19546a483c6a767f23c57deb11541", async() => {
WriteLiteral("<i class=\"bi bi-trash\"></i> Delete");
}
);
Expand All @@ -181,7 +206,7 @@ Name Of Type
}
BeginWriteTagHelperAttribute();
#nullable restore
#line 48 "C:\Users\Khatibian\source\repos\WebMarket\WebMarketApp\Views\Category\Index.cshtml"
#line 58 "C:\Users\Khatibian\source\repos\WebMarket\WebMarketApp\Views\Category\Index.cshtml"
WriteLiteral(obj.ID);

#line default
Expand All @@ -199,7 +224,7 @@ Name Of Type
__tagHelperExecutionContext = __tagHelperScopeManager.End();
WriteLiteral("\r\n </div>\r\n </td>\r\n </tr>\r\n");
#nullable restore
#line 52 "C:\Users\Khatibian\source\repos\WebMarket\WebMarketApp\Views\Category\Index.cshtml"
#line 62 "C:\Users\Khatibian\source\repos\WebMarket\WebMarketApp\Views\Category\Index.cshtml"
}

#line default
Expand Down
Binary file modified WebMarketApp/obj/Debug/net5.0/WebMarketApp.Views.dll
Binary file not shown.
Binary file modified WebMarketApp/obj/Debug/net5.0/WebMarketApp.Views.pdb
Binary file not shown.
Binary file modified WebMarketApp/obj/Debug/net5.0/WebMarketApp.dll
Binary file not shown.
Binary file modified WebMarketApp/obj/Debug/net5.0/WebMarketApp.pdb
Binary file not shown.

0 comments on commit c1004c8

Please sign in to comment.