Skip to content

Commit 0f3c45d

Browse files
committed
Create Wishmaster.Backend
1 parent c0a82cb commit 0f3c45d

23 files changed

+351
-87
lines changed

src/CodeBaseResearch.sln

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "helpers", "helpers", "{34CB
4545
EndProject
4646
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "plugins", "plugins", "{1A11F1C7-3BEF-41B9-AA32-4089A82D52F5}"
4747
EndProject
48-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wishmaster.ViewModels", "Wishmaster.ViewModels\Wishmaster.ViewModels.csproj", "{2C0C33D9-F77C-4BC9-A76B-6E4684C44484}"
48+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wishmaster.ViewModels", "Wishmaster.ViewModels\Wishmaster.ViewModels.csproj", "{2C0C33D9-F77C-4BC9-A76B-6E4684C44484}"
49+
EndProject
50+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wishmaster.Backend", "Wishmaster.Backend\Wishmaster.Backend.csproj", "{88324AD6-95BB-4005-A3A6-8F5BBE67FDDA}"
4951
EndProject
5052
Global
5153
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -105,6 +107,10 @@ Global
105107
{2C0C33D9-F77C-4BC9-A76B-6E4684C44484}.Debug|Any CPU.Build.0 = Debug|Any CPU
106108
{2C0C33D9-F77C-4BC9-A76B-6E4684C44484}.Release|Any CPU.ActiveCfg = Release|Any CPU
107109
{2C0C33D9-F77C-4BC9-A76B-6E4684C44484}.Release|Any CPU.Build.0 = Release|Any CPU
110+
{88324AD6-95BB-4005-A3A6-8F5BBE67FDDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
111+
{88324AD6-95BB-4005-A3A6-8F5BBE67FDDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
112+
{88324AD6-95BB-4005-A3A6-8F5BBE67FDDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
113+
{88324AD6-95BB-4005-A3A6-8F5BBE67FDDA}.Release|Any CPU.Build.0 = Release|Any CPU
108114
EndGlobalSection
109115
GlobalSection(SolutionProperties) = preSolution
110116
HideSolutionNode = FALSE
@@ -125,6 +131,7 @@ Global
125131
{34CB587C-1143-49CD-998B-9D2EC0433B8A} = {1F050E3A-0A38-4AF1-B07C-B617830BF970}
126132
{1A11F1C7-3BEF-41B9-AA32-4089A82D52F5} = {1F050E3A-0A38-4AF1-B07C-B617830BF970}
127133
{2C0C33D9-F77C-4BC9-A76B-6E4684C44484} = {1F050E3A-0A38-4AF1-B07C-B617830BF970}
134+
{88324AD6-95BB-4005-A3A6-8F5BBE67FDDA} = {1F050E3A-0A38-4AF1-B07C-B617830BF970}
128135
EndGlobalSection
129136
GlobalSection(ExtensibilityGlobals) = postSolution
130137
SolutionGuid = {32FDA729-10C6-4F1C-A4ED-3CF3428EA708}
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
using System.Linq;
22
using Microsoft.AspNetCore.Mvc;
3-
using Wishmaster.Mvc;
4-
using Wishmaster.Services;
3+
using Wishmaster.Backend.Mvc;
4+
using Wishmaster.Backend.Services;
55
using Wishmaster.ViewModels;
66

7-
namespace Wishmaster.Controllers
7+
namespace Wishmaster.Backend.Controllers
88
{
9-
[Route("api")]
9+
[Route("api/app-data")]
1010
public class AppDataController : BaseController
1111
{
1212
private readonly INavigationService _navigationService;
@@ -17,16 +17,16 @@ public AppDataController(INavigationService navigationService)
1717
}
1818

1919
[HttpGet("get-app-data")]
20-
public IActionResult GetAppData()
20+
public ActionResult<AppDataViewModel> GetAppData()
2121
{
2222
var links = _navigationService.GetSidebarLinks();
2323

24-
var viewModel = new AppDataViewModel
24+
var viewModel = new AppDataViewModel
2525
{
2626
SidebarNavigation = links.Select(x => x.ToViewModel()).ToArray(),
2727
};
2828

29-
return Success(viewModel);
29+
return Json(viewModel);
3030
}
3131
}
3232
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System;
22
using Microsoft.AspNetCore.Mvc;
3-
using Wishmaster.Mvc;
3+
using Wishmaster.Backend.Mvc;
44

5-
namespace Wishmaster.Controllers
5+
namespace Wishmaster.Backend.Controllers
66
{
77
[Route("api/space")]
88
public class SpaceController : BaseController
@@ -13,9 +13,9 @@ public SpaceController()
1313
}
1414

1515
[HttpGet("list")]
16-
public IActionResult List()
16+
public ActionResult<string> List()
1717
{
18-
return Success("HELLO");
18+
return Json("HELLO");
1919
}
2020
}
2121
}

src/Wishmaster/Models/AppData.cs renamed to src/Wishmaster.Backend/Models/AppData.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
using System.Collections.Generic;
22
using System.Windows;
33

4-
namespace Wishmaster.Models
4+
namespace Wishmaster.Backend.Models
55
{
66
public class AppData
77
{
88
public int? WindowWidth { get; set; }
99
public int? WindowHeight { get; set; }
10-
public WindowState? WindowState { get; set; }
10+
public int? WindowState { get; set; }
1111

1212
public string AccessToken { get; set; } = "";
1313
public List<ScopeDataItem> Scopes { get; set; } = new List<ScopeDataItem>();

src/Wishmaster/Models/Navigation/NavLink.cs renamed to src/Wishmaster.Backend/Models/Navigation/NavLink.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using System.Text;
44
using Wishmaster.ViewModels;
55

6-
namespace Wishmaster.Models.Navigation
6+
namespace Wishmaster.Backend.Models.Navigation
77
{
88
public class NavLink
99
{

src/Wishmaster/Mvc/ApiResponse.cs renamed to src/Wishmaster.Backend/Mvc/ApiResponse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22

3-
namespace Wishmaster.Mvc
3+
namespace Wishmaster.Backend.Mvc
44
{
55
public class ApiResponse<T>
66
{
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System.Linq;
2+
using Microsoft.AspNetCore.Mvc;
3+
using Microsoft.AspNetCore.Mvc.ModelBinding;
4+
using Newtonsoft.Json;
5+
6+
namespace Wishmaster.Backend.Mvc
7+
{
8+
public abstract class BaseController : Controller
9+
{
10+
[NonAction]
11+
protected ActionResult<ApiResponse<T>> Success<T>(T model)
12+
=> ApiResponse<T>.Success(model);
13+
14+
[NonAction]
15+
protected ActionResult<ApiResponse<object>> Success(object? model = null)
16+
=> Success<object>(model!);
17+
18+
[NonAction]
19+
protected ActionResult<ApiResponse<object>> Failure(ResultCode errorCode, string message)
20+
=> ApiResponse<object>.Failure(errorCode, message);
21+
22+
[NonAction]
23+
protected ActionResult<ApiResponse<object>> Failure(ModelStateDictionary modelState)
24+
{
25+
var messages = modelState.Values.SelectMany(x => x.Errors, (x, y) => y.ErrorMessage);
26+
return ApiResponse<object>.Failure(ResultCode.BadRequest, JsonConvert.SerializeObject(messages));
27+
}
28+
}
29+
}

src/Wishmaster/Mvc/UrlHelperAccessor.cs renamed to src/Wishmaster.Backend/Mvc/UrlHelperAccessor.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
using Microsoft.AspNetCore.Mvc;
1+
using System;
2+
using Microsoft.AspNetCore.Mvc;
23
using Microsoft.AspNetCore.Mvc.Infrastructure;
34
using Microsoft.AspNetCore.Mvc.Routing;
45
using Microsoft.Extensions.DependencyInjection;
56

6-
namespace Wishmaster.Mvc
7+
namespace Wishmaster.Backend.Mvc
78
{
89
public class UrlHelperAccessor
910
{
@@ -23,7 +24,7 @@ public IUrlHelper GetHelper()
2324
{
2425
return _actionContextAccessor.ActionContext != null
2526
? _urlHelperFactory.GetUrlHelper(_actionContextAccessor.ActionContext)
26-
: throw new System.Exception("Service currently created not by controller action");
27+
: throw new Exception("Service currently created not by controller action");
2728
}
2829
}
2930

src/Wishmaster/Services/AppDataProvider.cs renamed to src/Wishmaster.Backend/Services/AppDataProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using Wishmaster.Models;
1+
using Wishmaster.Backend.Models;
22

3-
namespace Wishmaster.Services
3+
namespace Wishmaster.Backend.Services
44
{
55
public interface IAppDataProvider
66
{

src/Wishmaster/Services/DataManager.cs renamed to src/Wishmaster.Backend/Services/DataManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.IO;
33
using Newtonsoft.Json;
44

5-
namespace Wishmaster.Services
5+
namespace Wishmaster.Backend.Services
66
{
77
public class DataManager<T>
88
{

0 commit comments

Comments
 (0)