Merge pull request 'refactor: update namespaces and improve null handling in view models and controllers' (#196) from j3/fix/dev into dev
Reviewed-on: https://10.4.0.131/gitea/DI1-P4-E1/Webzine/pulls/196
This commit is contained in:
@@ -94,7 +94,6 @@ public class DbStyleRepository : IStyleRepository
|
|||||||
this.logger.LogDebug("Recherche du style avec l'ID: {Id}", id);
|
this.logger.LogDebug("Recherche du style avec l'ID: {Id}", id);
|
||||||
|
|
||||||
var style = this.context.Styles
|
var style = this.context.Styles
|
||||||
.AsNoTracking()
|
|
||||||
.Include(s => s.Titres)
|
.Include(s => s.Titres)
|
||||||
.SingleOrDefault(s => s.IdStyle == id);
|
.SingleOrDefault(s => s.IdStyle == id);
|
||||||
|
|
||||||
@@ -123,7 +122,6 @@ public class DbStyleRepository : IStyleRepository
|
|||||||
this.logger.LogDebug("Tri des styles par libellé");
|
this.logger.LogDebug("Tri des styles par libellé");
|
||||||
|
|
||||||
var styles = this.context.Styles
|
var styles = this.context.Styles
|
||||||
.AsNoTracking()
|
|
||||||
.OrderBy(s => s.Libelle);
|
.OrderBy(s => s.Libelle);
|
||||||
|
|
||||||
this.logger.LogDebug("La liste de styles a été récupérée.");
|
this.logger.LogDebug("La liste de styles a été récupérée.");
|
||||||
|
|||||||
@@ -97,12 +97,15 @@ public class ArtisteController : Controller
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public IActionResult Edit(ArtisteEditViewModel model)
|
public IActionResult Edit(ArtisteEditViewModel model)
|
||||||
{
|
{
|
||||||
var artiste = new Artiste
|
var artiste = this.artisteRepository.Find(model.Id);
|
||||||
|
|
||||||
|
if (artiste == null)
|
||||||
{
|
{
|
||||||
IdArtiste = model.Id,
|
return this.RedirectToAction("Index");
|
||||||
Nom = model.Nom,
|
}
|
||||||
Biographie = model.Biographie,
|
|
||||||
};
|
artiste.Nom = model.Nom;
|
||||||
|
artiste.Biographie = model.Biographie;
|
||||||
|
|
||||||
this.artisteRepository.Update(artiste);
|
this.artisteRepository.Update(artiste);
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ namespace Webzine.WebApplication.Areas.Administration.Controllers;
|
|||||||
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
using ViewModels.Styles;
|
||||||
|
|
||||||
using Webzine.Entity;
|
using Webzine.Entity;
|
||||||
using Webzine.Repository.Contracts;
|
using Webzine.Repository.Contracts;
|
||||||
using Webzine.WebApplication.Areas.Administration.ViewModels.Style;
|
using Webzine.WebApplication.Areas.Administration.ViewModels.Styles;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Controleur pour la gestion des styles dans l'administration du webzine.
|
/// Controleur pour la gestion des styles dans l'administration du webzine.
|
||||||
|
|||||||
@@ -14,11 +14,11 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Définit le nom de l'artiste.
|
/// Définit le nom de l'artiste.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Nom { get; set; }
|
public string? Nom { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Définit la biographie de l'artiste.
|
/// Définit la biographie de l'artiste.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Biographie { get; set; }
|
public string? Biographie { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,11 +20,7 @@
|
|||||||
[StringLength(50, ErrorMessage = "Le nom ne doit pas dépasser 50 caractères.")]
|
[StringLength(50, ErrorMessage = "Le nom ne doit pas dépasser 50 caractères.")]
|
||||||
|
|
||||||
public string Nom { get; set; }
|
public string Nom { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Biographie de l'artiste.
|
|
||||||
/// </summary>
|
|
||||||
[Required(ErrorMessage = "Le contenu de la biographie ne peut pas être vide.")]
|
|
||||||
public string Biographie { get; set; }
|
public string Biographie { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
// Copyright (c) Equipe 1 - BOBIN, MASI, NODON, VETU. All rights reserved.
|
// Copyright (c) Equipe 1 - BOBIN, MASI, NODON, VETU. All rights reserved.
|
||||||
// </copyright>
|
// </copyright>
|
||||||
|
|
||||||
namespace Webzine.WebApplication.Areas.Administration.ViewModels.Style
|
namespace Webzine.WebApplication.Areas.Administration.ViewModels.Styles
|
||||||
{
|
{
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Copyright (c) Equipe 1 - BOBIN, MASI, NODON, VETU. All rights reserved.
|
// Copyright (c) Equipe 1 - BOBIN, MASI, NODON, VETU. All rights reserved.
|
||||||
// </copyright>
|
// </copyright>
|
||||||
|
|
||||||
namespace Webzine.WebApplication.Areas.Administration.ViewModels.Style
|
namespace Webzine.WebApplication.Areas.Administration.ViewModels.Styles
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ViewModel pour la suppression d'un style en administration.
|
/// ViewModel pour la suppression d'un style en administration.
|
||||||
@@ -17,6 +17,6 @@ namespace Webzine.WebApplication.Areas.Administration.ViewModels.Style
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Obtient ou définit le libellé du style.
|
/// Obtient ou définit le libellé du style.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Libelle { get; set; }
|
public string? Libelle { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
// Copyright (c) Equipe 1 - BOBIN, MASI, NODON, VETU. All rights reserved.
|
// Copyright (c) Equipe 1 - BOBIN, MASI, NODON, VETU. All rights reserved.
|
||||||
// </copyright>
|
// </copyright>
|
||||||
|
|
||||||
namespace Webzine.WebApplication.Areas.Administration.ViewModels.Style
|
namespace Webzine.WebApplication.Areas.Administration.ViewModels.Styles
|
||||||
{
|
{
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
@model Webzine.WebApplication.Areas.Administration.ViewModels.Style.StyleCreateViewModel
|
@model Webzine.WebApplication.Areas.Administration.ViewModels.Styles.StyleCreateViewModel
|
||||||
|
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Créer un style";
|
ViewData["Title"] = "Créer un style";
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
@model Webzine.WebApplication.Areas.Administration.ViewModels.Style.StyleDeleteViewModel
|
@model Webzine.WebApplication.Areas.Administration.ViewModels.Styles.StyleDeleteViewModel
|
||||||
|
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Supprimer un style";
|
ViewData["Title"] = "Supprimer un style";
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
@model Webzine.WebApplication.Areas.Administration.ViewModels.Style.StyleEditViewModel
|
@model Webzine.WebApplication.Areas.Administration.ViewModels.Styles.StyleEditViewModel
|
||||||
|
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Editer un style";
|
ViewData["Title"] = "Editer un style";
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ try
|
|||||||
// controllers avec des vues.
|
// controllers avec des vues.
|
||||||
builder.Services.AddControllersWithViews(options =>
|
builder.Services.AddControllersWithViews(options =>
|
||||||
{
|
{
|
||||||
|
// options.Filters.Add<GlobalExceptionFilter>();
|
||||||
options.Filters.Add<ValidationActionFilter>();
|
options.Filters.Add<ValidationActionFilter>();
|
||||||
options.Filters.Add<GlobalExceptionFilter>();
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// Ajoute la compilation des vues lors de l'execution de l'application.
|
// Ajoute la compilation des vues lors de l'execution de l'application.
|
||||||
|
|||||||
Reference in New Issue
Block a user