Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 048ba10

Browse files
author
kadir.avci
committed
Added new files, changed repository, added service pattern for testing
1 parent 14f0c74 commit 048ba10

File tree

60 files changed

+43003
-471
lines changed

Some content is hidden

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

60 files changed

+43003
-471
lines changed
0 Bytes
Binary file not shown.
84 KB
Binary file not shown.
0 Bytes
Binary file not shown.
-3.35 MB
Binary file not shown.

‎Common/Attributes/AjaxOnly.cs‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using Microsoft.AspNetCore.Mvc.Abstractions;
2+
using Microsoft.AspNetCore.Mvc.ActionConstraints;
3+
using Microsoft.AspNetCore.Routing;
4+
using Microsoft.Extensions.Primitives;
5+
using System;
6+
using System.Linq;
7+
8+
namespace Common.Attributes
9+
{
10+
public sealed class AjaxOnly : ActionMethodSelectorAttribute
11+
{
12+
public override bool IsValidForRequest(RouteContext routeContext, ActionDescriptor action)
13+
{
14+
if (routeContext.HttpContext.Request.Headers != null &&
15+
routeContext.HttpContext.Request.Headers.ContainsKey("X-Requested-With") &&
16+
routeContext.HttpContext.Request.Headers.TryGetValue("X-Requested-With", out StringValues requestedWithHeader))
17+
{
18+
if (requestedWithHeader.Contains("XMLHttpRequest"))
19+
{
20+
return true;
21+
}
22+
}
23+
24+
//TODO: check how we can redirect or change the status code for the ajax responses
25+
//These doesn't work!!!
26+
//routeContext.HttpContext.Response.StatusCode = 401;
27+
//routeContext.HttpContext.Response.Redirect("/asdsad");
28+
29+
return false;
30+
}
31+
}
32+
}

‎Common/Common.csproj‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
<Reference Include="Microsoft.AspNetCore.Html.Abstractions">
1919
<HintPath>C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.html.abstractions2円.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Html.Abstractions.dll</HintPath>
2020
</Reference>
21+
<Reference Include="Microsoft.AspNetCore.Mvc.Core">
22+
<HintPath>C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.core2円.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Core.dll</HintPath>
23+
</Reference>
2124
<Reference Include="Microsoft.AspNetCore.Mvc.ViewFeatures">
2225
<HintPath>C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.viewfeatures2円.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.ViewFeatures.dll</HintPath>
2326
</Reference>

‎Common/Dto/ToolbarVM.cs‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace Common.Dto
2+
{
3+
public class ToolbarVM
4+
{
5+
public int MenuId { get; set; } = 0;
6+
public string HelpUrl { get; set; } = string.Empty;
7+
public bool CanCreate { get; set; } = false;
8+
public bool CanDelete { get; set; } = false;
9+
public bool CanEdit { get; set; } = false;
10+
public bool CanExport { get; set; } = false;
11+
public bool CanRead { get; set; } = false;
12+
public bool CanSave { get; set; } = false;
13+
}
14+
}

‎Common/Filters/Statistics.cs‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using Microsoft.AspNetCore.Mvc.Filters;
2+
using System;
3+
using System.Threading.Tasks;
4+
5+
namespace Common.Filters
6+
{
7+
public sealed class Statistics : IAsyncActionFilter
8+
{
9+
public DateTime begin;
10+
public DateTime end;
11+
public double difference;
12+
13+
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
14+
{
15+
#region Before Executing
16+
17+
begin = DateTime.Now;
18+
19+
#endregion Before Executing
20+
21+
#region Run Normal Logic
22+
23+
var resultContext = await next();
24+
25+
#endregion Run Normal Logic
26+
27+
#region After Executing
28+
29+
end = DateTime.Now;
30+
difference = (end - begin).TotalMilliseconds;
31+
32+
//TODO put a limit here
33+
//Make smthn like that: if request takes more than 3 seconds then log it and create a ticket to check why it takes too much time
34+
if (difference > 0)
35+
{
36+
// log statistics
37+
}
38+
39+
#endregion After Executing
40+
}
41+
}
42+
}

‎Common/Helpers/UrlHelper.cs‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Microsoft.AspNetCore.Http;
2+
using Microsoft.Extensions.Primitives;
3+
4+
namespace Common.Helpers
5+
{
6+
public class UrlHelper
7+
{
8+
public static int GetMenuFromUrl(HttpRequest request)
9+
{
10+
var menuId = 0;
11+
12+
if (request.Query.Count > 0)
13+
{
14+
var queryString = request.Query;
15+
StringValues menuParameters;
16+
17+
queryString.TryGetValue("menu", out menuParameters);
18+
menuId = int.Parse(menuParameters);
19+
}
20+
21+
return menuId;
22+
}
23+
}
24+
}

‎Common/bin/Debug/netcoreapp2.2/Common.deps.json‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"Microsoft.Extensions.Configuration.Json": "2.2.0",
1515
"Microsoft.AspNetCore.Hosting.Abstractions": "2.2.0.0",
1616
"Microsoft.AspNetCore.Html.Abstractions": "2.2.0.0",
17+
"Microsoft.AspNetCore.Mvc.Core": "2.2.0.0",
1718
"Microsoft.AspNetCore.Mvc.ViewFeatures": "2.2.0.0",
1819
"Microsoft.AspNetCore.Razor": "2.2.0.0"
1920
},
@@ -211,6 +212,14 @@
211212
}
212213
}
213214
},
215+
"Microsoft.AspNetCore.Mvc.Core/2.2.0.0": {
216+
"runtime": {
217+
"Microsoft.AspNetCore.Mvc.Core.dll": {
218+
"assemblyVersion": "2.2.0.0",
219+
"fileVersion": "2.2.0.0"
220+
}
221+
}
222+
},
214223
"Microsoft.AspNetCore.Mvc.ViewFeatures/2.2.0.0": {
215224
"runtime": {
216225
"Microsoft.AspNetCore.Mvc.ViewFeatures.dll": {
@@ -371,6 +380,11 @@
371380
"serviceable": false,
372381
"sha512": ""
373382
},
383+
"Microsoft.AspNetCore.Mvc.Core/2.2.0.0": {
384+
"type": "reference",
385+
"serviceable": false,
386+
"sha512": ""
387+
},
374388
"Microsoft.AspNetCore.Mvc.ViewFeatures/2.2.0.0": {
375389
"type": "reference",
376390
"serviceable": false,

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /