Skip to content

Commit 249738c

Browse files
Add project files.
1 parent 489fede commit 249738c

File tree

132 files changed

+4740
-0
lines changed

Some content is hidden

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

132 files changed

+4740
-0
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Yusuf SEZER
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# ASP.NET MVC Blog
2+
A blog application developed with various .NET package such as ASP.NET MVC, Entity Framework.
3+
4+
## [Download](https://github.com/yusufsefasezer/aspnet-mvc-blog/archive/master.zip)
5+
6+
## Features
7+
- ASP.NET MVC Blog
8+
- Extensible
9+
- Customizable
10+
- Flexible management panel
11+
- Simple bootstrap theme system
12+
- SEF link (slug)
13+
14+
- ASP.NET
15+
- ASP.NET MVC
16+
- Routing
17+
- Validation
18+
- ViewModel
19+
20+
- Entitiy Framework
21+
- Code First
22+
- Migration
23+
- Fluent API
24+
25+
## How to use
26+
First of all you must set database connection in `Web.config` file.
27+
28+
Afterwards install required packages with Nuget package manager or Visual Studio IDE.
29+
30+
Lastly run the migration on Package Manager Console and start application.
31+
32+
`Update-Database`
33+
34+
That's all :)
35+
36+
## Screenshot
37+
38+
- [Homepage](screenshot/homepage.png)
39+
- [Dashboard](screenshot/overview.png)
40+
- [Create new post](screenshot/create-new-post.png)
41+
- [Edit post](screenshot/edit.png)
42+
- [Options](screenshot/options.png)
43+
44+
45+
# License
46+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details
47+
48+
Created by [Yusuf SEZER](http://www.yusufsezer.com)

aspnet-mvc-blog.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.28803.452
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "aspnet-mvc-blog", "aspnet-mvc-blog\aspnet-mvc-blog.csproj", "{4BFF0256-7E8B-437A-A220-783A42628DD6}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{4BFF0256-7E8B-437A-A220-783A42628DD6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{4BFF0256-7E8B-437A-A220-783A42628DD6}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{4BFF0256-7E8B-437A-A220-783A42628DD6}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{4BFF0256-7E8B-437A-A220-783A42628DD6}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {54828CF5-A099-495C-A4FF-981E33DB710D}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System.Web;
2+
using System.Web.Optimization;
3+
4+
namespace aspnet_mvc_blog
5+
{
6+
public class BundleConfig
7+
{
8+
public static void RegisterBundles(BundleCollection bundles)
9+
{
10+
bundles.Add(new ScriptBundle("~/bundles/admin").Include("~/Scripts/sb-admin.js"));
11+
bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/Style.css", "~/Content/site.css"));
12+
bundles.Add(new StyleBundle("~/Content/admin").Include("~/Content/sb-admin.css"));
13+
14+
//BundleTable.EnableOptimizations = true;
15+
}
16+
}
17+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.Web;
2+
using System.Web.Mvc;
3+
4+
namespace aspnet_mvc_blog
5+
{
6+
public class FilterConfig
7+
{
8+
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
9+
{
10+
filters.Add(new HandleErrorAttribute());
11+
}
12+
}
13+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Web;
5+
using System.Web.Mvc;
6+
using System.Web.Routing;
7+
8+
namespace aspnet_mvc_blog
9+
{
10+
public class RouteConfig
11+
{
12+
public static void RegisterRoutes(RouteCollection routes)
13+
{
14+
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
15+
16+
routes.MapMvcAttributeRoutes();
17+
18+
routes.MapRoute(
19+
name: "Default",
20+
url: "{controller}/{action}/{id}",
21+
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
22+
namespaces: new string[] { "aspnet_mvc_blog.Controllers" }
23+
);
24+
}
25+
}
26+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System.Web.Mvc;
2+
3+
namespace aspnet_mvc_blog.Areas.Admin
4+
{
5+
public class AdminAreaRegistration : AreaRegistration
6+
{
7+
public override string AreaName
8+
{
9+
get
10+
{
11+
return "Admin";
12+
}
13+
}
14+
15+
public override void RegisterArea(AreaRegistrationContext context)
16+
{
17+
context.MapRoute(
18+
"Admin_default",
19+
"Admin/{controller}/{action}/{id}",
20+
new { controller = "Home", action = "Index", id = UrlParameter.Optional },
21+
namespaces: new string[] { "aspnet_mvc_blog.Areas.Admin.Controllers" }
22+
);
23+
}
24+
}
25+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Net;
5+
using System.Web;
6+
using System.Web.Mvc;
7+
8+
namespace aspnet_mvc_blog.Areas.Admin.Controllers
9+
{
10+
public class AuthorsController : ControllerBase
11+
{
12+
public ActionResult Index()
13+
{
14+
return View(db.Authors.OrderByDescending(p => p.ID).ToList());
15+
}
16+
17+
public ActionResult Create()
18+
{
19+
return View();
20+
}
21+
22+
[HttpPost]
23+
[ValidateAntiForgeryToken]
24+
public ActionResult Create(aspnet_mvc_blog.Models.Entity.Author author)
25+
{
26+
if (ModelState.IsValid)
27+
{
28+
try
29+
{
30+
db.Authors.Add(author);
31+
db.SaveChanges();
32+
return RedirectToAction("Index");
33+
}
34+
catch
35+
{
36+
ModelState.AddModelError(string.Empty, "This E-mail has already been used.");
37+
}
38+
}
39+
40+
return View(author);
41+
}
42+
43+
44+
public ActionResult Edit(int? id)
45+
{
46+
if (id == null)
47+
{
48+
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
49+
}
50+
51+
aspnet_mvc_blog.Models.Entity.Author author = db.Authors.Find(id);
52+
if (author == null)
53+
{
54+
return HttpNotFound();
55+
}
56+
return View(author);
57+
}
58+
59+
[HttpPost]
60+
[ValidateAntiForgeryToken]
61+
public ActionResult Edit(aspnet_mvc_blog.Models.Entity.Author author)
62+
{
63+
if (ModelState.IsValid)
64+
{
65+
try
66+
{
67+
db.Entry(author).State = System.Data.Entity.EntityState.Modified;
68+
db.SaveChanges();
69+
return RedirectToAction("Index");
70+
}
71+
catch
72+
{
73+
ModelState.AddModelError(string.Empty, "This E-mail has already been used.");
74+
}
75+
}
76+
77+
return View(author);
78+
}
79+
80+
public ActionResult Delete(int? id)
81+
{
82+
if (id == null)
83+
{
84+
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
85+
}
86+
87+
aspnet_mvc_blog.Models.Entity.Author author = db.Authors.Find(id);
88+
if (author == null)
89+
{
90+
return HttpNotFound();
91+
}
92+
93+
db.Authors.Remove(author);
94+
db.SaveChanges();
95+
return RedirectToAction("Index");
96+
}
97+
}
98+
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Net;
5+
using System.Web;
6+
using System.Web.Mvc;
7+
8+
namespace aspnet_mvc_blog.Areas.Admin.Controllers
9+
{
10+
public class CategoriesController : ControllerBase
11+
{
12+
public ActionResult Index()
13+
{
14+
ViewModels.CategoryViewModel model = new ViewModels.CategoryViewModel();
15+
model.Categories = db.Categories.OrderBy(p => p.Name).ToList();
16+
return View(model);
17+
}
18+
19+
[HttpPost]
20+
[ValidateAntiForgeryToken]
21+
public ActionResult Index(aspnet_mvc_blog.Models.Entity.Category category)
22+
{
23+
if (ModelState.IsValid)
24+
{
25+
try
26+
{
27+
28+
if (category.Slug == null)
29+
{
30+
category.Slug = category.Name.GenerateSlug();
31+
}
32+
category.Slug?.GenerateSlug();
33+
34+
db.Categories.Add(category);
35+
db.SaveChanges();
36+
return RedirectToAction("Index");
37+
}
38+
catch (Exception)
39+
{
40+
ModelState.AddModelError(string.Empty, "Someting went wrong.");
41+
}
42+
}
43+
return View(new ViewModels.CategoryViewModel { Category = category, Categories = db.Categories.ToList() });
44+
}
45+
46+
public ActionResult Edit(int? id)
47+
{
48+
if (id == null)
49+
{
50+
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
51+
}
52+
53+
ViewModels.CategoryViewModel model = new ViewModels.CategoryViewModel();
54+
model.Categories = db.Categories.ToList();
55+
model.Category = db.Categories.Find(id);
56+
57+
if (model.Categories == null)
58+
{
59+
return HttpNotFound();
60+
}
61+
return View(model);
62+
}
63+
64+
[HttpPost]
65+
[ValidateAntiForgeryToken]
66+
public ActionResult Edit(ViewModels.CategoryViewModel model)
67+
{
68+
if (ModelState.IsValid)
69+
{
70+
try
71+
{
72+
db.Entry(model.Category).State = System.Data.Entity.EntityState.Modified;
73+
db.SaveChanges();
74+
return RedirectToAction("Index");
75+
}
76+
catch
77+
{
78+
ModelState.AddModelError(string.Empty, "Someting went wrong.");
79+
}
80+
}
81+
82+
return View(new ViewModels.CategoryViewModel { Category = model.Category, Categories = db.Categories.ToList() });
83+
}
84+
85+
public ActionResult Delete(int? id)
86+
{
87+
if (id == null) return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
88+
89+
aspnet_mvc_blog.Models.Entity.Category category = db.Categories.Find(id);
90+
if (category == null) return HttpNotFound();
91+
try
92+
{
93+
category.Entries.ToList()
94+
.ForEach(p => db.Entry(p).State = System.Data.Entity.EntityState.Deleted);
95+
db.Categories.RemoveRange(category.SubCategories);
96+
db.Categories.Remove(category);
97+
db.SaveChanges();
98+
}
99+
catch { }
100+
101+
return RedirectToAction("Index");
102+
}
103+
}
104+
}

0 commit comments

Comments
 (0)