diff --git a/.vs/BWPM/DesignTimeBuild/.dtbcache.v2 b/.vs/BWPM/DesignTimeBuild/.dtbcache.v2 new file mode 100644 index 0000000..56b882e Binary files /dev/null and b/.vs/BWPM/DesignTimeBuild/.dtbcache.v2 differ diff --git a/.vs/BWPM/config/applicationhost.config b/.vs/BWPM/config/applicationhost.config new file mode 100644 index 0000000..60d55b7 --- /dev/null +++ b/.vs/BWPM/config/applicationhost.config @@ -0,0 +1,1007 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.vs/BWPM/v16/.suo b/.vs/BWPM/v16/.suo new file mode 100644 index 0000000..7402943 Binary files /dev/null and b/.vs/BWPM/v16/.suo differ diff --git a/App/APP.csproj b/App/APP.csproj index 711a6b4..40e4e29 100644 --- a/App/APP.csproj +++ b/App/APP.csproj @@ -5,7 +5,9 @@ - + + + diff --git a/App/APP.csproj.user b/App/APP.csproj.user index c0554b1..593f0eb 100644 --- a/App/APP.csproj.user +++ b/App/APP.csproj.user @@ -3,7 +3,12 @@ MvcControllerEmptyScaffolder root/Common/MVC/Controller - RazorViewEmptyScaffolder + RazorViewScaffolder root/Common/MVC/View + 650 + True + True + False + \ No newline at end of file diff --git a/App/Controllers/FormController.cs b/App/Controllers/FormController.cs index 7c51576..d1b9bbd 100644 --- a/App/Controllers/FormController.cs +++ b/App/Controllers/FormController.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace sf1.Controllers +namespace App.Controllers { public class FormController : Controller { diff --git a/App/Controllers/HomeController.cs b/App/Controllers/HomeController.cs index f915a6b..e97b9f8 100644 --- a/App/Controllers/HomeController.cs +++ b/App/Controllers/HomeController.cs @@ -5,9 +5,9 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; -using sf1.Models; +using App.Models; -namespace sf1.Controllers +namespace App.Controllers { public class HomeController : Controller { diff --git a/App/Controllers/LoginController.cs b/App/Controllers/LoginController.cs new file mode 100644 index 0000000..4490dd8 --- /dev/null +++ b/App/Controllers/LoginController.cs @@ -0,0 +1,37 @@ +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using APP.Models; + + +namespace APP.Controllers +{ + public class LoginController : Controller + { + public IActionResult Index() + { + return View(); + } + public IActionResult Login(LoginModel model) + { + App.Helper.HttpClientHelper httpcli = new App.Helper.HttpClientHelper(); + + string username = model.UserName; + string password = model.Password; + httpcli.CallService("user",username+','+password, "GET", null); + if (httpcli.Results.resultstatus==true && httpcli.Results.daten !="[]") + { + APP.Models.SessionClass.UserName = "AAA"; + return Json(new { success = true }); + } + else + { + return Json(new { error = "Kann nicht angemeldet werden!" }); + }; + + return Json(new { error = "" }); + } + } +} diff --git a/App/Controllers/UserController.cs b/App/Controllers/UserController.cs index 112156d..bf722b0 100644 --- a/App/Controllers/UserController.cs +++ b/App/Controllers/UserController.cs @@ -10,20 +10,18 @@ using Syncfusion.EJ2; using BWPMModels; using System.Collections; using Syncfusion.EJ2.Base; -using sf1.Models; using Microsoft.Extensions.Configuration; using Newtonsoft.Json; using System.Reflection; +using App.Models; -namespace sf1.Controllers +namespace App.Controllers { public partial class UserController : Controller { - private const string URL = "http://localhost/CoreWebAPI1/api/"; + public IActionResult Index() { - - return View(); } @@ -85,8 +83,6 @@ namespace sf1.Controllers Helper.HttpClientHelper httpcli = new Helper.HttpClientHelper(); User u = new User(); u = value.value; - u.Teststring = "hallo"; - u.aktiv = true; httpcli.CallService("user", "", "POST", u); if (httpcli.Results.resultstatuscode != "OK") { @@ -108,6 +104,8 @@ namespace sf1.Controllers return Json(value); } + + } } diff --git a/App/Helper/HttpClientHelper.cs b/App/Helper/HttpClientHelper.cs index 0cbca24..09c7399 100644 --- a/App/Helper/HttpClientHelper.cs +++ b/App/Helper/HttpClientHelper.cs @@ -1,16 +1,16 @@ -using MyModels; +using BWPMModels; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Net.Http; -using System.Net.Http; + using System.Net.Http.Headers; using System.Net.Http.Formatting; using System.Threading.Tasks; -using sf1.Models; +using App.Models; -namespace sf1.Helper +namespace App.Helper { public class HttpClientHelper { @@ -60,6 +60,7 @@ namespace sf1.Helper Results.daten = readTask.Result; + break; } break; diff --git a/App/Helper/ParameterHelper.cs b/App/Helper/ParameterHelper.cs index 54b4e28..977b800 100644 --- a/App/Helper/ParameterHelper.cs +++ b/App/Helper/ParameterHelper.cs @@ -1,15 +1,15 @@ -using Microsoft.Extensions.Configuration; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Configuration; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; -namespace sf1.Helper +namespace App.Helper { public class ParameterHelper { - public string GetParameter(string Keyvalue) { var configuation = GetConfiguration(); @@ -22,4 +22,8 @@ namespace sf1.Helper return builder.Build(); } } + + + } + diff --git a/App/Models/CRUDModel.cs b/App/Models/CRUDModel.cs index 805cce3..b670212 100644 --- a/App/Models/CRUDModel.cs +++ b/App/Models/CRUDModel.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace sf1.Models +namespace App.Models { public class ICRUDModel where T : class { diff --git a/App/Models/ErrorViewModel.cs b/App/Models/ErrorViewModel.cs index eb01bbd..ca3da71 100644 --- a/App/Models/ErrorViewModel.cs +++ b/App/Models/ErrorViewModel.cs @@ -1,6 +1,6 @@ using System; -namespace sf1.Models +namespace App.Models { public class ErrorViewModel { diff --git a/App/Models/LoginModel.cs b/App/Models/LoginModel.cs new file mode 100644 index 0000000..9f61154 --- /dev/null +++ b/App/Models/LoginModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace APP.Models +{ + public class LoginModel + { + public string UserName { get; set; } + public string Password { get; set; } + } +} diff --git a/App/Models/MenuItem.cs b/App/Models/MenuItem.cs new file mode 100644 index 0000000..c06d721 --- /dev/null +++ b/App/Models/MenuItem.cs @@ -0,0 +1,61 @@ + +using Microsoft.AspNetCore.Http; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; +using BWPMModels; + + +namespace App.Models +{ + public class AppMenuItem + { + + public string id { get; set; } + public string text { get; set; } + public string parentId { get; set; } + public string url { get; set; } + + //public static List MenuItems(string usertype) + public static List MenuItems(string usertype) + { + + + Helper.HttpClientHelper httpcli = new Helper.HttpClientHelper(); + httpcli.CallService("MenuItem", APP.Models.SessionClass.UserType, "GET", null); + if (httpcli.Results.resultstatus == true) + { + List mis = new List(); + List menus = JsonConvert.DeserializeObject>(httpcli.Results.daten); + //List mis = new List(); + + //mis.Add (new AppMenuItem { id = "1", text = "Text 1", parentId = "", url = "Home" }); + //mis.Add(new AppMenuItem { id = "2", text = "Text 2", parentId = "1", url = "Form" }); + //mis.Add(new AppMenuItem { id = "3", text = "Text3", parentId = "null", url = "" }); + //return mis; + + foreach (BWPMModels.MenuItem item in menus) + { + mis.Add(new AppMenuItem { id = item.ID, text = item.text, parentId = item.parentId, url = item.url }); + } + if (APP.Models.SessionClass.UserName == "") + { + mis.Add(new AppMenuItem { id = "999", text = "Login" , parentId = "", url = "Login"}); + } + + return mis; + } + + //ViewBag.DataSource = users; + + //menus.Add(new MenuItem { id = "1", text = "Text 1", parentId = "", url="Home" }); + //menus.Add(new MenuItem { id = "2", text = "Text 2", parentId = "1", url="Form"}); + //menus.Add(new MenuItem { id = "3", text = "Text3", parentId = "null",url="" }); + + return null; + } + + } + +} diff --git a/App/Models/SessionClass.cs b/App/Models/SessionClass.cs new file mode 100644 index 0000000..be83932 --- /dev/null +++ b/App/Models/SessionClass.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace APP.Models +{ + public static class SessionClass + { + public static string UserType { get; set; } = "0"; + public static string UserName { get; set; } = ""; + + public static void SetSessionValue() + { + UserType = "1"; + } + + } + + +} diff --git a/App/Startup.cs b/App/Startup.cs index 43eec77..6bef4b2 100644 --- a/App/Startup.cs +++ b/App/Startup.cs @@ -20,6 +20,7 @@ namespace sf1 { public class Startup { + public Startup(IConfiguration configuration) { Configuration = configuration; @@ -35,12 +36,23 @@ namespace sf1 { options.SerializerSettings.ContractResolver = new DefaultContractResolver(); }); + services.AddDistributedMemoryCache(); + services.AddSession(options => + { + options.IdleTimeout= TimeSpan.FromSeconds(60); + options.Cookie.Name = ".bwpm.Session"; + options.Cookie.IsEssential = true; + }); + + APP.Models.SessionClass.SetSessionValue(); + } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { + if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); @@ -57,7 +69,8 @@ namespace sf1 app.UseRouting(); app.UseAuthorization(); - + app.UseSession(); + app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( diff --git a/App/ViewComponents/MenuItemsViewComponent.cs b/App/ViewComponents/MenuItemsViewComponent.cs new file mode 100644 index 0000000..66dca24 --- /dev/null +++ b/App/ViewComponents/MenuItemsViewComponent.cs @@ -0,0 +1,34 @@ +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +//using App.Models; +using Microsoft.AspNetCore.Http; +using BWPMModels; +using App.Models; + +namespace APP.ViewComponents +{ + public class MenuItemsViewComponent : ViewComponent + { + List menuItems = new List(); + //List menuItems = new List(); + public MenuItemsViewComponent() + { + //HttpContext.Session.SetString("usertype","1"); + //string usertype = HttpContext.Session.GetString("usertype"); + menuItems = AppMenuItem.MenuItems(APP.Models.SessionClass.UserType); + ViewBag.menuitems = menuItems; + var model = menuItems; + } + + public async Task InvokeAsync() + { + var model = menuItems; + ViewBag.menuitems = menuItems; + return await Task.FromResult((IViewComponentResult)View("MenuItems", model)); + } + + } +} diff --git a/App/Views/Shared/Components/Menuitems/MenuItems.cshtml b/App/Views/Shared/Components/Menuitems/MenuItems.cshtml new file mode 100644 index 0000000..448310d --- /dev/null +++ b/App/Views/Shared/Components/Menuitems/MenuItems.cshtml @@ -0,0 +1,5 @@ +@{ + ViewData["Title"] = "Error"; +} + + diff --git a/App/Views/Shared/Components/UserStatus/UserStatus.cshtml b/App/Views/Shared/Components/UserStatus/UserStatus.cshtml new file mode 100644 index 0000000..a5f4a3f --- /dev/null +++ b/App/Views/Shared/Components/UserStatus/UserStatus.cshtml @@ -0,0 +1,5 @@ +@{ + ViewData["Title"] = "Error"; +} + +Ich bin der User-Status \ No newline at end of file diff --git a/App/Views/Shared/_Layout.cshtml b/App/Views/Shared/_Layout.cshtml index 9002802..170d3a4 100644 --- a/App/Views/Shared/_Layout.cshtml +++ b/App/Views/Shared/_Layout.cshtml @@ -1,4 +1,9 @@ - +@using Syncfusion.EJ2 +@model APP.Models.LoginModel +@{ + var defaultanimation = new Syncfusion.EJ2.Popups.DialogAnimationSettings { Effect = Syncfusion.EJ2.Popups.DialogEffect.Zoom }; +} + @@ -6,39 +11,102 @@ @ViewData["Title"] - sf1 - + + - + - + - sf1 - - - - - - - Home - - - Privacy - - + BWPMToggle navigation + + @(await Component.InvokeAsync("MenuItems")) + @* + Home + Projects + CV + Hire me + *@ + Login + + + + + + + + + + + + + + + + + + Login + + + + + + + + + @RenderBody() +