Rebase : Merge conflit entre dev et j3/seed_spotify.
This commit is contained in:
@@ -113,12 +113,15 @@ public class ArtisteController : Controller
|
||||
[HttpPost]
|
||||
public IActionResult Edit(ArtisteEditViewModel model)
|
||||
{
|
||||
var artiste = new Artiste
|
||||
var artiste = this.artisteRepository.Find(model.Id);
|
||||
|
||||
if (artiste == null)
|
||||
{
|
||||
IdArtiste = model.Id,
|
||||
Nom = model.Nom,
|
||||
Biographie = model.Biographie,
|
||||
};
|
||||
return this.RedirectToAction("Index");
|
||||
}
|
||||
|
||||
artiste.Nom = model.Nom;
|
||||
artiste.Biographie = model.Biographie;
|
||||
|
||||
this.artisteRepository.Update(artiste);
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -114,6 +114,33 @@ public class TitreController : Controller
|
||||
[HttpPost]
|
||||
public IActionResult Create(TitreAdminDTO model)
|
||||
{
|
||||
if (!this.ModelState.IsValid)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
this.titreAdminService.CreerTitre(model);
|
||||
return this.RedirectToAction("Index");
|
||||
}
|
||||
@@ -166,6 +193,34 @@ public class TitreController : Controller
|
||||
[HttpPost]
|
||||
public IActionResult Edit(TitreAdminDTO model)
|
||||
{
|
||||
if (!this.ModelState.IsValid)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
this.titreAdminService.ModifierTitre(model);
|
||||
return this.RedirectToAction("Index");
|
||||
}
|
||||
|
||||
@@ -14,11 +14,11 @@
|
||||
/// <summary>
|
||||
/// Définit le nom de l'artiste.
|
||||
/// </summary>
|
||||
public string Nom { get; set; }
|
||||
public string? Nom { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Définit la biographie de l'artiste.
|
||||
/// </summary>
|
||||
public string Biographie { get; set; }
|
||||
public string? Biographie { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -10,12 +10,15 @@
|
||||
/// <summary>
|
||||
/// Nom de l'artiste.
|
||||
/// </summary>
|
||||
[Required]
|
||||
[Required(ErrorMessage = "Le nom de l'auteur est obligatoire.")]
|
||||
[StringLength(50, ErrorMessage = "Le nom ne doit pas dépasser 50 caractères.")]
|
||||
public string Nom { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Biographie de l'artiste.
|
||||
/// </summary>
|
||||
/// </summary>*
|
||||
[Required(ErrorMessage = "La biographie ne peux pas etre vide.")]
|
||||
|
||||
public string Biographie { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -16,12 +16,11 @@
|
||||
/// <summary>
|
||||
/// Nom de l'artiste.
|
||||
/// </summary>
|
||||
[Required]
|
||||
[Required(ErrorMessage = "Le nom de l'auteur est obligatoire.")]
|
||||
[StringLength(50, ErrorMessage = "Le nom ne doit pas dépasser 50 caractères.")]
|
||||
|
||||
public string Nom { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Biographie de l'artiste.
|
||||
/// </summary>
|
||||
public string Biographie { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
// Copyright (c) Equipe 1 - BOBIN, MASI, NODON, VETU. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace Webzine.WebApplication.Areas.Administration.ViewModels.Style
|
||||
namespace Webzine.WebApplication.Areas.Administration.ViewModels.Styles
|
||||
{
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Webzine.WebApplication.Areas.Administration.ViewModels.Style
|
||||
/// <summary>
|
||||
/// Obtient ou définit le libellé du style.
|
||||
/// </summary>
|
||||
[Required]
|
||||
[Required(ErrorMessage = "Le libelle du style est obligatoire.")]
|
||||
public string Libelle { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
// Copyright (c) Equipe 1 - BOBIN, MASI, NODON, VETU. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace Webzine.WebApplication.Areas.Administration.ViewModels.Style
|
||||
namespace Webzine.WebApplication.Areas.Administration.ViewModels.Styles
|
||||
{
|
||||
/// <summary>
|
||||
/// ViewModel pour la suppression d'un style en administration.
|
||||
@@ -17,6 +17,6 @@ namespace Webzine.WebApplication.Areas.Administration.ViewModels.Style
|
||||
/// <summary>
|
||||
/// Obtient ou définit le libellé du style.
|
||||
/// </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>
|
||||
|
||||
namespace Webzine.WebApplication.Areas.Administration.ViewModels.Style
|
||||
namespace Webzine.WebApplication.Areas.Administration.ViewModels.Styles
|
||||
{
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Webzine.WebApplication.Areas.Administration.ViewModels.Style
|
||||
/// <summary>
|
||||
/// Obtient ou definit le libelle du style.
|
||||
/// </summary>
|
||||
[Required]
|
||||
[Required(ErrorMessage = "Le libelle du style est obligatoire.")]
|
||||
public string Libelle { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
namespace Webzine.WebApplication.Areas.Administration.ViewModels.Titre;
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
|
||||
/// <summary>
|
||||
@@ -15,36 +17,47 @@ public class AdminTitreForm
|
||||
/// <summary>
|
||||
/// Définit l'identifiant de l'artiste associé au titre.
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "L'id de l'artiste est obligatoire.")]
|
||||
|
||||
public int IdArtiste { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Définit le titre du titre.
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "Le labelle est obligatoire.")]
|
||||
|
||||
public string Libelle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Définit le nom de l'album associé au titre.
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "L'album est obligatoire.")]
|
||||
|
||||
public string Album { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Définit la chronique du titre, peut-être une critique ou une description du titre.
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "La chronique est obligatoire.")]
|
||||
public string Chronique { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Définit la date de sortie du titre.
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "La date de est obligatoire.")]
|
||||
|
||||
public DateTime DateSortie { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Définit la durée du titre en secondes.
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "La durée est obligatoire.")]
|
||||
public int Duree { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Définit l'URL de la jaquette de l'album associé au titre.
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "L'Url de la jaquette est obligatoire.")]
|
||||
public string UrlJaquette { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
<label class="col-md-3 col-form-label">Nom de l'artiste<span class="text-danger">*</span></label>
|
||||
<div class="col-md-9">
|
||||
<input asp-for="Nom" class="form-control" />
|
||||
<span asp-validation-for="Nom" class="text-danger"></span>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -19,6 +21,8 @@
|
||||
<label class="col-md-3 col-form-label">Biographie</label>
|
||||
<div class="col-md-9">
|
||||
<textarea asp-for="Biographie" class="form-control" rows="5"></textarea>
|
||||
<span asp-validation-for="Biographie" class="text-danger"></span>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
<label class="col-md-3 col-form-label">Nom de l'artiste<span class="text-danger">*</span></label>
|
||||
<div class="col-md-9">
|
||||
<input asp-for="Nom" class="form-control" />
|
||||
<span asp-validation-for="Nom" class="text-danger"></span>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -14,7 +16,10 @@
|
||||
<label class="col-md-3 col-form-label">Biographie</label>
|
||||
<div class="col-md-9">
|
||||
<textarea asp-for="Biographie" class="form-control" rows="5"></textarea>
|
||||
<span asp-validation-for="Biographie" class="text-danger"></span>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- BOUTONS -->
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
<select asp-for="IdArtiste"
|
||||
asp-items="Model.Artistes"
|
||||
class="form-select"></select>
|
||||
<span asp-validation-for="IdArtiste" class="text-danger"></span>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -16,6 +18,7 @@
|
||||
<label class="col-md-3 col-form-label">Titre<span class="text-danger">*</span></label>
|
||||
<div class="col-md-9">
|
||||
<input asp-for="Libelle" class="form-control"/>
|
||||
<span asp-validation-for="Libelle" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -24,6 +27,7 @@
|
||||
<label class="col-md-3 col-form-label">Album<span class="text-danger">*</span></label>
|
||||
<div class="col-md-9">
|
||||
<input asp-for="Album" class="form-control"/>
|
||||
<span asp-validation-for="Album" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -34,6 +38,8 @@
|
||||
<textarea asp-for="Chronique"
|
||||
class="form-control"
|
||||
rows="5"></textarea>
|
||||
<span asp-validation-for="Chronique" class="text-danger"></span>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -55,6 +61,8 @@
|
||||
class="form-control"
|
||||
type="number"
|
||||
min="0" />
|
||||
<span asp-validation-for="Duree" class="text-danger"></span>
|
||||
|
||||
<span class="input-group-text text-muted">seconds</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -66,6 +74,8 @@
|
||||
<div class="col-md-9">
|
||||
<input asp-for="UrlJaquette"
|
||||
class="form-control"/>
|
||||
<span asp-validation-for="UrlJaquette" class="text-danger"></span>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ try
|
||||
// controllers avec des vues.
|
||||
builder.Services.AddControllersWithViews(options =>
|
||||
{
|
||||
// options.Filters.Add<GlobalExceptionFilter>();
|
||||
options.Filters.Add<ValidationActionFilter>();
|
||||
options.Filters.Add<GlobalExceptionFilter>();
|
||||
});
|
||||
@@ -55,7 +56,7 @@ try
|
||||
});
|
||||
builder.Services.AddSingleton<EfSlowQueryInterceptor>();
|
||||
|
||||
// En fonction de la configuration, utilise soit les repositories basés sur une base de données, soit les repositories basés sur des listes locales.
|
||||
// En fonction de la configuration, utilise soit les repositories basés sur une base de données, soit les repositories basés sur des listes locales.
|
||||
// En fonction de la configuration, utilise soit les repositories bases sur une base de donnees, soit les repositories bases sur des listes locales.
|
||||
var repositoryType = builder.Configuration.GetValue<RepositoryType>("Repository");
|
||||
var seederType = builder.Configuration.GetValue<SeederType>("Seeder");
|
||||
|
||||
@@ -26,6 +26,6 @@
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"EfPerformance": {
|
||||
"SeuilMs": 10
|
||||
"SeuilMs": 60
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user