Skip to content

Commit ca3ea6f

Browse files
committed
Initial commit
0 parents  commit ca3ea6f

File tree

763 files changed

+743370
-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.

763 files changed

+743370
-0
lines changed

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.vs/WebAPI_Example/v15/.suo

156 KB
Binary file not shown.

.vs/WebAPI_Example/v15/Server/sqlite3/db.lock

Whitespace-only changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.

.vs/config/applicationhost.config

+1,041
Large diffs are not rendered by default.

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Fatih Çetinkaya
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

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# WebAPI_Tutorial

WebAPI.API/App_Start/BundleConfig.cs

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System.Web;
2+
using System.Web.Optimization;
3+
4+
namespace WebAPI.API
5+
{
6+
public class BundleConfig
7+
{
8+
// For more information on bundling, visit https://go.microsoft.com/fwlink/?LinkId=301862
9+
public static void RegisterBundles(BundleCollection bundles)
10+
{
11+
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
12+
"~/Scripts/jquery-{version}.js"));
13+
14+
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
15+
"~/Scripts/jquery.validate*"));
16+
17+
// Use the development version of Modernizr to develop with and learn from. Then, when you're
18+
// ready for production, use the build tool at https://modernizr.com to pick only the tests you need.
19+
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
20+
"~/Scripts/modernizr-*"));
21+
22+
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
23+
"~/Scripts/bootstrap.js"));
24+
25+
bundles.Add(new StyleBundle("~/Content/css").Include(
26+
"~/Content/bootstrap.css",
27+
"~/Content/site.css"));
28+
}
29+
}
30+
}

WebAPI.API/App_Start/FilterConfig.cs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.Web;
2+
using System.Web.Mvc;
3+
4+
namespace WebAPI.API
5+
{
6+
public class FilterConfig
7+
{
8+
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
9+
{
10+
filters.Add(new HandleErrorAttribute());
11+
}
12+
}
13+
}

WebAPI.API/App_Start/RouteConfig.cs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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 WebAPI.API
9+
{
10+
public class RouteConfig
11+
{
12+
public static void RegisterRoutes(RouteCollection routes)
13+
{
14+
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
15+
16+
routes.MapRoute(
17+
name: "Default",
18+
url: "{controller}/{action}/{id}",
19+
defaults: new { action = "Index", id = UrlParameter.Optional }
20+
);
21+
}
22+
}
23+
}
24+

WebAPI.API/App_Start/WebApiConfig.cs

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using Newtonsoft.Json.Serialization;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Web.Http;
6+
using WebAPI.API.Attributes;
7+
using WebAPI.API.Security;
8+
9+
namespace WebAPI.API
10+
{
11+
public static class WebApiConfig
12+
{
13+
public static void Register(HttpConfiguration config)
14+
{
15+
// Web API routes
16+
config.MapHttpAttributeRoutes();
17+
config.Filters.Add(new ApiExceptionAttribute()); // All Control Method.. Error Managment..
18+
config.MessageHandlers.Add(new APIKeyHandler()); // All Control Method..Auth Managment..
19+
20+
config.Routes.MapHttpRoute(
21+
name: "DefaultApi",
22+
routeTemplate: "servis/{controller}{id}", // api => servis...
23+
// routeTemplate: "api/{controller}/{id}",
24+
defaults: new { id = RouteParameter.Optional } // Gönderip göndermemek önemli değil
25+
);
26+
27+
// Return Json formatting..
28+
config.Formatters.JsonFormatter.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented;
29+
config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
30+
}
31+
}
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Net.Http;
5+
using System.Web;
6+
using System.Web.Http.Filters;
7+
8+
namespace WebAPI.API.Attributes
9+
{
10+
public class ApiExceptionAttribute:ExceptionFilterAttribute
11+
{
12+
// Override methot..
13+
public override void OnException(HttpActionExecutedContext actionExecutedContext)
14+
{
15+
HttpResponseMessage responseMessage = new HttpResponseMessage(System.Net.HttpStatusCode.NotImplemented);
16+
responseMessage.ReasonPhrase = actionExecutedContext.Exception.Message;
17+
actionExecutedContext.Response = responseMessage;
18+
base.OnException(actionExecutedContext);
19+
}
20+
}
21+
}

WebAPI.API/Content/Site.css

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
body {
2+
padding-top: 50px;
3+
padding-bottom: 20px;
4+
}
5+
6+
/* Set padding to keep content from hitting the edges */
7+
.body-content {
8+
padding-left: 15px;
9+
padding-right: 15px;
10+
}
11+
12+
/* Set width on the form input elements since they're 100% wide by default */
13+
input,
14+
select,
15+
textarea {
16+
max-width: 280px;
17+
}
18+

0 commit comments

Comments
 (0)