diff --git a/Directory.Packages.props b/Directory.Packages.props index 3f0f6d4f..076da407 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -37,8 +37,8 @@ - + @@ -59,4 +59,4 @@ - + \ No newline at end of file diff --git a/src/Org/Controllers/Communicating/HyperLinkController.cs b/src/Api/Controllers/Business/HyperLinkController.cs similarity index 67% rename from src/Org/Controllers/Communicating/HyperLinkController.cs rename to src/Api/Controllers/Business/HyperLinkController.cs index af9678a3..18da5f1d 100644 --- a/src/Org/Controllers/Communicating/HyperLinkController.cs +++ b/src/Api/Controllers/Business/HyperLinkController.cs @@ -13,19 +13,19 @@ namespace Yavsc.Controllers public HyperLinkController(ApplicationDbContext context) { - _context = context; + _context = context; } // GET: HyperLink public async Task Index() { - return View(await _context.HyperLink.ToListAsync()); + return Ok(await _context.HyperLink.ToListAsync()); } // GET: HyperLink/Details/5 public async Task Details(string href, string method) { - if (href == null || method ==null) + if (href == null || method == null) { return NotFound(); } @@ -36,14 +36,9 @@ namespace Yavsc.Controllers return NotFound(); } - return View(hyperLink); + return Ok(hyperLink); } - // GET: HyperLink/Create - public IActionResult Create() - { - return View(); - } // POST: HyperLink/Create [HttpPost] @@ -54,15 +49,15 @@ namespace Yavsc.Controllers { _context.HyperLink.Add(hyperLink); await _context.SaveChangesAsync(); - return RedirectToAction("Index"); + return Ok(hyperLink); } - return View(hyperLink); + return BadRequest(ModelState); } // GET: HyperLink/Edit/5 public async Task Edit(string href, string method) { - if (href == null || method ==null) + if (href == null || method == null) { return NotFound(); } @@ -72,7 +67,7 @@ namespace Yavsc.Controllers { return NotFound(); } - return View(hyperLink); + return Ok(hyperLink); } // POST: HyperLink/Edit/5 @@ -84,36 +79,17 @@ namespace Yavsc.Controllers { _context.Update(hyperLink); await _context.SaveChangesAsync(); - return RedirectToAction("Index"); + return Ok(hyperLink); } - return View(hyperLink); - } - - // GET: HyperLink/Delete/5 - [ActionName("Delete")] - public async Task Delete(string href, string method) - { - if (href == null || method ==null) - { - return NotFound(); - } - - HyperLink hyperLink = await _context.HyperLink.SingleAsync(m => m.HRef == href && m.Method == method); - - if (hyperLink == null) - { - return NotFound(); - } - - return View(hyperLink); + return BadRequest(ModelState); } // POST: HyperLink/Delete/5 - [HttpPost, ActionName("Delete")] + [HttpDelete, ActionName("Delete")] [ValidateAntiForgeryToken] public async Task DeleteConfirmed(string HRef, string Method) { - if (HRef == null || Method ==null) + if (HRef == null || Method == null) { return NotFound(); } @@ -122,7 +98,7 @@ namespace Yavsc.Controllers _context.HyperLink.Remove(hyperLink); await _context.SaveChangesAsync(); - return RedirectToAction("Index"); + return Ok(); } } } diff --git a/src/Org/Coiffure-Avatars/Paul Schneider.png b/src/Org/Coiffure-Avatars/Paul Schneider.png deleted file mode 100644 index 90acca7a..00000000 Binary files a/src/Org/Coiffure-Avatars/Paul Schneider.png and /dev/null differ diff --git a/src/Org/Coiffure-Avatars/Paul Schneider.s.png b/src/Org/Coiffure-Avatars/Paul Schneider.s.png deleted file mode 100644 index f08217af..00000000 Binary files a/src/Org/Coiffure-Avatars/Paul Schneider.s.png and /dev/null differ diff --git a/src/Org/Coiffure-Avatars/Paul Schneider.xs.png b/src/Org/Coiffure-Avatars/Paul Schneider.xs.png deleted file mode 100644 index 1400a3a0..00000000 Binary files a/src/Org/Coiffure-Avatars/Paul Schneider.xs.png and /dev/null differ diff --git a/src/Org/Controllers/Communicating/DevicesController.cs b/src/Org/Controllers/Accounting/DevicesController.cs similarity index 100% rename from src/Org/Controllers/Communicating/DevicesController.cs rename to src/Org/Controllers/Accounting/DevicesController.cs diff --git a/src/Org/Controllers/Administration/AdministrationController.cs b/src/Org/Controllers/Administration/AdministrationController.cs index 00499b08..e2944e9e 100644 --- a/src/Org/Controllers/Administration/AdministrationController.cs +++ b/src/Org/Controllers/Administration/AdministrationController.cs @@ -30,6 +30,8 @@ namespace Yavsc.Controllers this._dbContext = context; } + + [Authorize("AdministratorOnly")] public async Task Role(string id) { var role = await _roleManager.FindByIdAsync(id); @@ -39,7 +41,7 @@ namespace Yavsc.Controllers Id = id, Name = role.Name, Users = (await this._userManager.GetUsersInRoleAsync(role.Name)) - .Select(u => new UserInfo (id, u.UserName, u.Email, u.Avatar)).ToArray() + .Select(u => new UserInfo(id, u.UserName, u.Email, u.Avatar)).ToArray() }; return View(roleUserCollection); } @@ -62,17 +64,16 @@ namespace Yavsc.Controllers if (!resultCreate.Succeeded) { AddErrors(resultCreate); - return false; } } + if (ModelState.ErrorCount > 0) return false; return true; - } + /// - /// Gives the (new if was not existing) administrator role - /// to current authenticated user, when no existing - /// administrator was found. - /// When nothing is to do, it returns a 404. + /// Gives the new, when not existing, administrator role + /// to current authenticated user. + /// If nothing is to do, it returns a 404. /// /// [Produces("application/json")] @@ -110,7 +111,6 @@ namespace Yavsc.Controllers } [Authorize("AdministratorOnly")] - [Produces("application/json")] public async Task Index() { var adminCount = await _userManager.GetUsersInRoleAsync( @@ -197,6 +197,7 @@ namespace Yavsc.Controllers ViewBag.UserId = new SelectList(_dbContext.Users, "Id", "UserName"); return View(model); } + private void AddErrors(IdentityResult result) { foreach (var error in result.Errors) diff --git a/src/Org/Controllers/Administration/DatabaseController.cs b/src/Org/Controllers/Administration/DatabaseController.cs index f85e44f4..7301fb87 100644 --- a/src/Org/Controllers/Administration/DatabaseController.cs +++ b/src/Org/Controllers/Administration/DatabaseController.cs @@ -7,7 +7,7 @@ using Yavsc.Models; namespace Yavsc.Controllers { - [Authorize()] + [Authorize("AdministratorOnly")] public class DatabaseController : Controller { private readonly ILogger logger; diff --git a/src/Server/Models/Musical/MusicalPreference.cs b/src/Server/Models/Musical/MusicalPreference.cs index 4bcbf8c8..35d787ef 100644 --- a/src/Server/Models/Musical/MusicalPreference.cs +++ b/src/Server/Models/Musical/MusicalPreference.cs @@ -1,5 +1,6 @@ using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; using Yavsc.Attributes.Validation; namespace Yavsc.Models.Musical @@ -17,7 +18,10 @@ namespace Yavsc.Models.Musical public int Rate { get; set; } [YaRequired] - public long TendencyId {get; set; } + public long TendencyId { get; set; } + + [ForeignKey("TendencyId")] + public virtual MusicalTendency MusicalTendency { get; set; } } } diff --git a/src/Server/Models/Payment/PaypalPayment.cs b/src/Server/Models/Payment/PaypalPayment.cs index 60c6b2e0..e8e41d6c 100644 --- a/src/Server/Models/Payment/PaypalPayment.cs +++ b/src/Server/Models/Payment/PaypalPayment.cs @@ -15,6 +15,7 @@ namespace Yavsc.Models.Payment { [YaRequired] public string ExecutorId { get; set; } + [ForeignKey("ExecutorId")] public virtual ApplicationUser Executor { get; set; } diff --git a/src/cli/cli.csproj b/src/cli/cli.csproj index c136b874..8def68b3 100644 --- a/src/cli/cli.csproj +++ b/src/cli/cli.csproj @@ -18,4 +18,4 @@ - + \ No newline at end of file diff --git a/test/yavscTests/Mandatory/BatchTests.cs b/test/yavscTests/Mandatory/BatchTests.cs index c39cb154..493b6cdf 100644 --- a/test/yavscTests/Mandatory/BatchTests.cs +++ b/test/yavscTests/Mandatory/BatchTests.cs @@ -3,7 +3,6 @@ using Microsoft.Extensions.DependencyInjection; using Yavsc.Models; using Xunit.Abstractions; using Yavsc.Server.Models.IT.SourceCode; -using yavscTests.Settings; using Microsoft.EntityFrameworkCore; using isnd.tests; @@ -14,13 +13,11 @@ namespace yavscTests public class BaseTestContext: IClassFixture, IDisposable { public readonly WebServerFixture _serverFixture; - private readonly TestingSetup _testingOptions; private readonly ITestOutputHelper _output; public BaseTestContext(ITestOutputHelper output, WebServerFixture fixture) { this._serverFixture = fixture; - _testingOptions = fixture.TestingSetup; this._output = output; } diff --git a/test/yavscTests/NonRegression/Database.cs b/test/yavscTests/NonRegression/Database.cs index 12157e09..02d60b26 100644 --- a/test/yavscTests/NonRegression/Database.cs +++ b/test/yavscTests/NonRegression/Database.cs @@ -1,6 +1,4 @@ -using System; using isnd.tests; -using Xunit; using Xunit.Abstractions; namespace yavscTests.Mandatory @@ -18,7 +16,6 @@ namespace yavscTests.Mandatory this.output = output; _serverFixture = serverFixture; - output.WriteLine($"Testing connection string is {_serverFixture?.TestingSetup?.ConnectionStrings.DefaultConnection}"); } /// diff --git a/test/yavscTests/NonRegression/EMailling.cs b/test/yavscTests/NonRegression/EMailling.cs index 5f7450b6..eab947eb 100644 --- a/test/yavscTests/NonRegression/EMailling.cs +++ b/test/yavscTests/NonRegression/EMailling.cs @@ -1,12 +1,8 @@ using isnd.tests; -using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using Xunit; using Xunit.Abstractions; -using Yavsc.Abstract.Manage; using Yavsc.Interface; -using Yavsc.Models; namespace yavscTests { diff --git a/test/yavscTests/Settings/DbConnectionSettings.cs b/test/yavscTests/Settings/DbConnectionSettings.cs deleted file mode 100644 index ad2e43c0..00000000 --- a/test/yavscTests/Settings/DbConnectionSettings.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace yavscTests.Settings -{ - public class DbConnectionSettings - { - public string? DefaultConnection { get; set; } - } -} diff --git a/test/yavscTests/Settings/Testing.cs b/test/yavscTests/Settings/Testing.cs deleted file mode 100644 index 96fe3516..00000000 --- a/test/yavscTests/Settings/Testing.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace yavscTests.Settings -{ - public class PasswordCreds - { - public string UserName { get; set; } - public string Password { get; set; } - } - public class TestingSetup - { - public DbConnectionSettings ConnectionStrings { get; set; } - - public PasswordCreds ValidCreds - { - get; set; - } - public PasswordCreds InvalidCreds - { - get; set; - } - public string YavscWebPath {get; set; } - } -} - diff --git a/test/yavscTests/WebServerFixture.cs b/test/yavscTests/WebServerFixture.cs index cafb7de7..133fc8b1 100644 --- a/test/yavscTests/WebServerFixture.cs +++ b/test/yavscTests/WebServerFixture.cs @@ -1,7 +1,4 @@ -using System.Net; -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting.Server; using Microsoft.AspNetCore.Hosting.Server.Features; using Microsoft.AspNetCore.Identity; @@ -9,15 +6,10 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -using Xunit; using Yavsc; using Yavsc.Models; -using Yavsc.Services; -using yavscTests.Settings; using Yavsc.Extensions; using Microsoft.EntityFrameworkCore; -using Microsoft.AspNetCore.Mvc.ModelBinding.Binders; -using Yavsc.Models.Auth; using Serilog; using Serilog.Events; using Serilog.Sinks.SystemConsole.Themes; @@ -46,7 +38,6 @@ namespace isnd.tests public ApplicationUser TestingUser { get; private set; } public bool DbCreated { get; internal set; } public SiteSettings SiteSettings { get => siteSettings; set => siteSettings = value; } - public TestingSetup? TestingSetup { get; internal set; } public string TestClientSecret { get; private set; } = "TestClientSecret"; public WebServerFixture() @@ -118,10 +109,7 @@ namespace isnd.tests Addresses.Add(address); } SiteSettings = app.Services.GetRequiredService>().Value; - - - } public void EnsureUser(string testingUserName, string password) diff --git a/test/yavscTests/yavscTests.csproj b/test/yavscTests/yavscTests.csproj index dfe5352a..81de4b76 100644 --- a/test/yavscTests/yavscTests.csproj +++ b/test/yavscTests/yavscTests.csproj @@ -24,11 +24,11 @@ - - - + + + - \ No newline at end of file + diff --git a/yavsc.sln b/yavsc.sln index 900b138d..8579fc75 100644 --- a/yavsc.sln +++ b/yavsc.sln @@ -17,6 +17,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Api", "src\Api\Api.csproj", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cli", "src\cli\cli.csproj", "{27DA6CEC-4266-4F78-BB32-8388F9A401D0}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{76A7FBA6-B7EC-4864-85C0-1F470794BA0F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "yavscTests", "test\yavscTests\yavscTests.csproj", "{CDCF676A-2037-472E-8C8B-67C5E4FDFEA1}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -50,6 +54,10 @@ Global {27DA6CEC-4266-4F78-BB32-8388F9A401D0}.Debug|Any CPU.Build.0 = Debug|Any CPU {27DA6CEC-4266-4F78-BB32-8388F9A401D0}.Release|Any CPU.ActiveCfg = Release|Any CPU {27DA6CEC-4266-4F78-BB32-8388F9A401D0}.Release|Any CPU.Build.0 = Release|Any CPU + {CDCF676A-2037-472E-8C8B-67C5E4FDFEA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CDCF676A-2037-472E-8C8B-67C5E4FDFEA1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CDCF676A-2037-472E-8C8B-67C5E4FDFEA1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CDCF676A-2037-472E-8C8B-67C5E4FDFEA1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {8AD551DA-AFB7-4C2A-BB33-9418E38659BC} = {CDB1BDB5-53F9-4B43-864F-60F2E74F44E2} @@ -58,5 +66,6 @@ Global {1F594222-C5CB-4D4A-94A1-C5AEB4990B59} = {CDB1BDB5-53F9-4B43-864F-60F2E74F44E2} {95DAD2B5-4324-4E89-A337-5703E45CFBE8} = {CDB1BDB5-53F9-4B43-864F-60F2E74F44E2} {27DA6CEC-4266-4F78-BB32-8388F9A401D0} = {CDB1BDB5-53F9-4B43-864F-60F2E74F44E2} + {CDCF676A-2037-472E-8C8B-67C5E4FDFEA1} = {76A7FBA6-B7EC-4864-85C0-1F470794BA0F} EndGlobalSection EndGlobal