(Rebase) Resolution de merge conflit entre dev et j3/feat/pagination
This commit is contained in:
@@ -74,14 +74,6 @@ public class ArtisteController : Controller
|
||||
[HttpPost]
|
||||
public IActionResult Create(ArtisteCreateViewModel model)
|
||||
{
|
||||
// vérifier si les données sont corrects.
|
||||
if (!this.ModelState.IsValid)
|
||||
{
|
||||
// Passer model en paramètre afin que
|
||||
// l'utilisateur conserve sa saissie.
|
||||
return this.View(model);
|
||||
}
|
||||
|
||||
// Créer un objet Artiste avecc les paramètres.
|
||||
var artiste = new Artiste
|
||||
{
|
||||
@@ -121,18 +113,16 @@ public class ArtisteController : Controller
|
||||
[HttpPost]
|
||||
public IActionResult Edit(ArtisteEditViewModel model)
|
||||
{
|
||||
var artiste = new Artiste
|
||||
{
|
||||
IdArtiste = model.Id,
|
||||
Nom = model.Nom,
|
||||
Biographie = model.Biographie,
|
||||
};
|
||||
var artiste = this.artisteRepository.Find(model.Id);
|
||||
|
||||
if (!this.ModelState.IsValid)
|
||||
if (artiste == null)
|
||||
{
|
||||
return this.View(artiste);
|
||||
return this.RedirectToAction("Index");
|
||||
}
|
||||
|
||||
artiste.Nom = model.Nom;
|
||||
artiste.Biographie = model.Biographie;
|
||||
|
||||
this.artisteRepository.Update(artiste);
|
||||
|
||||
return this.RedirectToAction("Index");
|
||||
|
||||
@@ -96,11 +96,6 @@ namespace Webzine.WebApplication.Areas.Administration.Controllers
|
||||
{
|
||||
var commentaire = this.commentaireRepository.Find(model.IdCommentaire);
|
||||
|
||||
if (!this.ModelState.IsValid)
|
||||
{
|
||||
return this.View(commentaire);
|
||||
}
|
||||
|
||||
if (commentaire != null)
|
||||
{
|
||||
this.commentaireRepository.Delete(commentaire);
|
||||
|
||||
@@ -5,8 +5,11 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Webzine.Business.Contracts;
|
||||
using Webzine.Business.Contracts.Dto;
|
||||
|
||||
/// <summary>
|
||||
/// Contrôleur pour gérer le tableau de bord de l'administration.
|
||||
/// </summary>
|
||||
[Area("Administration")]
|
||||
public class DashboardController : Controller // TODO à refaire
|
||||
public class DashboardController : Controller
|
||||
{
|
||||
private readonly ILogger<DashboardController> logger;
|
||||
private readonly IDashboardService dashboardService;
|
||||
|
||||
@@ -2,9 +2,10 @@ namespace Webzine.WebApplication.Areas.Administration.Controllers;
|
||||
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
using ViewModels.Styles;
|
||||
|
||||
using Webzine.Entity;
|
||||
using Webzine.Repository.Contracts;
|
||||
using Webzine.WebApplication.Areas.Administration.ViewModels.Style;
|
||||
|
||||
/// <summary>
|
||||
/// Controleur pour la gestion des styles dans l'administration du webzine.
|
||||
@@ -77,11 +78,6 @@ public class StyleController : Controller
|
||||
[HttpPost]
|
||||
public IActionResult Create(StyleCreateViewModel model)
|
||||
{
|
||||
if (!this.ModelState.IsValid)
|
||||
{
|
||||
return this.View(model);
|
||||
}
|
||||
|
||||
var style = new Style
|
||||
{
|
||||
Libelle = model.Libelle,
|
||||
@@ -138,7 +134,6 @@ public class StyleController : Controller
|
||||
/// </summary>
|
||||
/// <param name="id">L'identifiant du style a editer.</param>
|
||||
/// <returns>La vue d'edition ou une redirection vers l'index si le style n'existe pas.</returns>
|
||||
[HttpGet]
|
||||
public IActionResult Edit(int id)
|
||||
{
|
||||
var style = this.styleRepository.Find(id);
|
||||
@@ -165,11 +160,6 @@ public class StyleController : Controller
|
||||
[HttpPost]
|
||||
public IActionResult Edit(StyleEditViewModel model)
|
||||
{
|
||||
if (!this.ModelState.IsValid)
|
||||
{
|
||||
return this.View(model);
|
||||
}
|
||||
|
||||
var style = this.styleRepository.Find(model.IdStyle);
|
||||
if (style == null)
|
||||
{
|
||||
|
||||
@@ -114,13 +114,35 @@ public class TitreController : Controller
|
||||
[HttpPost]
|
||||
public IActionResult Create(TitreAdminDTO model)
|
||||
{
|
||||
if (this.ModelState.IsValid)
|
||||
if (!this.ModelState.IsValid)
|
||||
{
|
||||
this.titreAdminService.CreerTitre(model);
|
||||
return this.RedirectToAction("Index");
|
||||
var form = new AdminTitreForm
|
||||
{
|
||||
IdArtiste = model.IdArtiste,
|
||||
Libelle = model.Libelle,
|
||||
Album = model.Album,
|
||||
Chronique = model.Chronique,
|
||||
DateSortie = model.DateSortie,
|
||||
Duree = model.Duree,
|
||||
UrlJaquette = model.UrlJaquette,
|
||||
UrlEcoute = model.UrlEcoute,
|
||||
Styles = model.Styles,
|
||||
Artistes = this.artisteRepository.FindAll().Select(a => new SelectListItem
|
||||
{
|
||||
Value = a.IdArtiste.ToString(),
|
||||
Text = a.Nom,
|
||||
}).ToList(),
|
||||
AllStyles = this.styleRepository.FindAll().Select(s => new SelectListItem
|
||||
{
|
||||
Value = s.IdStyle.ToString(),
|
||||
Text = s.Libelle,
|
||||
}).ToList(),
|
||||
};
|
||||
return this.View(form);
|
||||
}
|
||||
|
||||
return this.View(model);
|
||||
this.titreAdminService.CreerTitre(model);
|
||||
return this.RedirectToAction("Index");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -171,13 +193,36 @@ public class TitreController : Controller
|
||||
[HttpPost]
|
||||
public IActionResult Edit(TitreAdminDTO model)
|
||||
{
|
||||
if (this.ModelState.IsValid)
|
||||
if (!this.ModelState.IsValid)
|
||||
{
|
||||
this.titreAdminService.ModifierTitre(model);
|
||||
return this.RedirectToAction("Index");
|
||||
var form = new AdminTitreForm
|
||||
{
|
||||
Id = model.Id,
|
||||
IdArtiste = model.IdArtiste,
|
||||
Libelle = model.Libelle,
|
||||
Album = model.Album,
|
||||
Chronique = model.Chronique,
|
||||
DateSortie = model.DateSortie,
|
||||
Duree = model.Duree,
|
||||
UrlJaquette = model.UrlJaquette,
|
||||
UrlEcoute = model.UrlEcoute,
|
||||
Styles = model.Styles,
|
||||
Artistes = this.artisteRepository.FindAll().Select(a => new SelectListItem
|
||||
{
|
||||
Value = a.IdArtiste.ToString(),
|
||||
Text = a.Nom,
|
||||
}).ToList(),
|
||||
AllStyles = this.styleRepository.FindAll().Select(s => new SelectListItem
|
||||
{
|
||||
Value = s.IdStyle.ToString(),
|
||||
Text = s.Libelle,
|
||||
}).ToList(),
|
||||
};
|
||||
return this.View(form);
|
||||
}
|
||||
|
||||
return this.View(model);
|
||||
this.titreAdminService.ModifierTitre(model);
|
||||
return this.RedirectToAction("Index");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user