first push

This commit is contained in:
2026-05-16 21:29:22 +02:00
commit 25edd4fac7
68 changed files with 3475 additions and 0 deletions
@@ -0,0 +1,53 @@
using Microsoft.EntityFrameworkCore;
using ModelsLib;
public class ConfigAppServices
{
private readonly IDbContextFactory<PhotoShareDbContext> _factory;
public ConfigAppServices(IDbContextFactory<PhotoShareDbContext> factory)
{
_factory = factory;
}
public async Task FillConfigTableWithDataPerDefault()
{
using var db = _factory.CreateDbContext();
db.ConfigDb.AddRange(
new ParametersDb("InstaQrCode", "/Images/qr.png"),
new ParametersDb("InstaLink", "https://www.instagram.com/helrira/"),
new ParametersDb("TitlePseudo", "Kévin"),
new ParametersDb("SubTitle1", "Passionné par la photo depuis 2025, je me spécialise dans le portrait avec modèles pour capturer l'essence et l'émotion de chaque rencontre."),
new ParametersDb("SubTitle2", "J'aime que chaque séance soit cadrée tout en gardant une part de surprise, de non prévu et surtout un bon moment pour chacun."),
new ParametersDb("Credentials", "Kévin Harlay(Helrira)")
);
await db.SaveChangesAsync();
}
public async Task<bool> HasAnyParametersAsync()
{
using var db = _factory.CreateDbContext();
return await db.ConfigDb.AnyAsync();
}
public async Task<EntityHome> readParametersApplication()
{
using var db = _factory.CreateDbContext();
var confDb = await db.ConfigDb
.AsNoTracking()
.ToDictionaryAsync(p => p.Key, p => p.Value);
return new EntityHome
{
InstaQrCode = confDb["InstaQrCode"],
InstaLink = confDb["InstaLink"],
TitlePseudo = confDb["TitlePseudo"],
SubTitle1 = confDb["SubTitle1"],
SubTitle2 = confDb["SubTitle2"],
Credentials = confDb["Credentials"]
};
}
}
+25
View File
@@ -0,0 +1,25 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using ModelsLib;
using System;
using System.Collections.Generic;
using System.Text;
public class DesireService
{
private readonly IDbContextFactory<PhotoShareDbContext> _factory;
private readonly IWebHostEnvironment _env;
public DesireService(IDbContextFactory<PhotoShareDbContext> factory, IWebHostEnvironment env)
{
_factory = factory;
_env = env;
}
public List<string> GetDEsireShooting()
{
using var db = _factory.CreateDbContext();
return db.DesireDb.Select(ds => ds.Desire).ToList();
}
}
+70
View File
@@ -0,0 +1,70 @@
using System.Net;
using System.Net.Mail;
using System.Text;
using Microsoft.Extensions.Configuration;
public class EmailService
{
private readonly IConfiguration _configuration;
public EmailService(IConfiguration configuration)
{
_configuration = configuration;
}
public async Task EnvoyerMailAsync(string sujet, StringBuilder contenuHtml)
{
var smtpConfig = _configuration.GetSection("Smtp");
var client = new SmtpClient
{
Host = smtpConfig["Host"],
Port = int.Parse(smtpConfig["Port"]),
EnableSsl = true,
Credentials = new NetworkCredential(
smtpConfig["User"],
smtpConfig["Password"]
)
};
var mail = new MailMessage
{
From = new MailAddress(smtpConfig["From"]),
Subject = sujet,
Body = contenuHtml.ToString(),
IsBodyHtml = true
};
mail.To.Add(smtpConfig["From"]);
await client.SendMailAsync(mail);
}
public async Task EnvoyerMailContactAsync(string Contact, string sujet, StringBuilder contenuHtml)
{
var smtpConfig = _configuration.GetSection("Smtp");
var client = new SmtpClient
{
Host = smtpConfig["Host"],
Port = int.Parse(smtpConfig["Port"]),
EnableSsl = true,
Credentials = new NetworkCredential(
smtpConfig["User"],
smtpConfig["Password"]
)
};
var mail = new MailMessage
{
From = new MailAddress(smtpConfig["From"]),
Subject = sujet,
Body = contenuHtml.ToString(),
IsBodyHtml = true
};
mail.To.Add(Contact);
await client.SendMailAsync(mail);
}
}
+83
View File
@@ -0,0 +1,83 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using ModelsLib;
using System.IO;
public class PhotoService
{
private readonly IDbContextFactory<PhotoShareDbContext> _factory;
private readonly IWebHostEnvironment _env;
public PhotoService(IDbContextFactory<PhotoShareDbContext> factory, IWebHostEnvironment env)
{
_factory = factory;
_env = env;
}
/// <summary>
///
/// </summary>
/// <param name="IdShooting"></param>
/// <param name="isSelected">Si true alors post traitement donc chargement du dossier export du dossier du shooting</param>
/// <returns></returns>
public List<string> LireContenu(string IdShooting, bool isSelected = false)
{
string path = "Photos/" + IdShooting;
if (isSelected)
{
path = path + "/export";
}
var photosPath = Path.Combine(_env.WebRootPath, path);
List<string> resultPathsAllPhotos = new List<string>();
if (Directory.Exists(photosPath))
{
var files = Directory.GetFiles(photosPath, "*.jpg");
foreach (var file in files)
{
var fullPath = file; // ton chemin complet
var relativePath = Path.GetRelativePath(_env.WebRootPath, fullPath);
resultPathsAllPhotos.Add(relativePath);
}
}
return resultPathsAllPhotos;
}
public ShootingData GetInfosShooting(string idShooting)
{
using var db = _factory.CreateDbContext();
return db.ShootingDb.Where(s => s.Key == idShooting).FirstOrDefault();
}
public async Task AddShootingInfoPerDefault(string idShooting)
{
await using var db = _factory.CreateDbContext();
db.ShootingDb.Add(
new ShootingData(idShooting, false, 20, DateTime.UtcNow, "")
);
await db.SaveChangesAsync();
}
public async Task UpdateShootingInfo(ShootingData shootingData)
{
using var db = _factory.CreateDbContext();
var entity = await db.ShootingDb.FirstOrDefaultAsync(x => x.Key == shootingData.Key);
if (entity != null)
{
entity.IsPhotosSelected = true;
await db.SaveChangesAsync();
}
}
}