Formatage du code
continuous-integration/drone/push Build is passing Details

pull/37/head
Clement CHIEU 1 year ago
parent e35ccc8e63
commit 241802f3d5

@ -16,6 +16,7 @@ namespace API.Controllers
private readonly IInquiryService<InquiryDTO> _inquiryDataService;
private readonly ILogger<InquiriesController> _logger;
public InquiriesController(IInquiryService<InquiryDTO> inquiryDataService, ILogger<InquiriesController> logger)
{
_inquiryDataService = inquiryDataService;
@ -33,6 +34,7 @@ namespace API.Controllers
_logger.LogError("[ERREUR] Aucune enquête trouvée.");
return StatusCode(204);
}
_logger.LogInformation("[INFORMATION] {nb} Enquête(s) trouvée(s)", nbInquiry);
return Ok(_inquiryDataService.GetInquiries(page, number, orderCriteria));
}
@ -87,7 +89,6 @@ namespace API.Controllers
_logger.LogError("[ERREUR] Aucune enquête trouvée avec l'id {id}.", id);
return NotFound();
}
}
[HttpPost]
@ -99,8 +100,12 @@ namespace API.Controllers
{
return BadRequest();
}
_logger.LogInformation("[INFORMATION] Une enquête a été créé : title - {title}, description - {description}, isUser - {isUser}", dto.Title, dto.Description, dto.IsUser);
return Created(nameof(GetInquiries), _inquiryDataService.CreateInquiry(dto.Title, dto.Description, dto.IsUser));
_logger.LogInformation(
"[INFORMATION] Une enquête a été créé : title - {title}, description - {description}, isUser - {isUser}",
dto.Title, dto.Description, dto.IsUser);
return Created(nameof(GetInquiries),
_inquiryDataService.CreateInquiry(dto.Title, dto.Description, dto.IsUser));
}
[HttpPut("inquiry/{id}")]
@ -114,16 +119,20 @@ namespace API.Controllers
_logger.LogError("[ERREUR] Problème ID - La mise à jour de l'enquête avec l'id {id} a échouée.", id);
return BadRequest();
}
if (!ModelState.IsValid)
{
_logger.LogError("[ERREUR] Problème controlleur - La mise à jour de l'enquête avec l'id {id} a échouée.", id);
_logger.LogError(
"[ERREUR] Problème controlleur - La mise à jour de l'enquête avec l'id {id} a échouée.", id);
return BadRequest();
}
if (inquiryDTO != null)
{
_logger.LogInformation("[INFORMATION] La mise à jour de l'enquête avec l'id {id} a été effectuée", id);
return Ok(_inquiryDataService.UpdateInquiry(id, inquiryDTO));
}
_logger.LogError("[ERREUR] Aucune enquête trouvée avec l'id {id}.", id);
return NotFound();
}

@ -34,6 +34,7 @@ namespace API.Controllers
_logger.LogError("[ERREUR] Aucune leçon trouvée.");
return StatusCode(204);
}
_logger.LogInformation("[INFORMATION] {nb} Leçon(s) trouvée(s)", nbLesson);
return Ok(_lessonDataService.GetLessons(page, number, orderCriteria));
}
@ -88,7 +89,6 @@ namespace API.Controllers
_logger.LogError("[ERREUR] Aucune leçon trouvée avec l'id {id}.", id);
return NotFound();
}
}
[HttpPost]
@ -100,8 +100,12 @@ namespace API.Controllers
{
return BadRequest();
}
_logger.LogInformation("[INFORMATION] Une leçon a été créé : title - {title}, lastPublisher - {publisher}, lastEdit - {lastEdit}", dto.Title, dto.LastPublisher, dto.LastEdit);
return Created(nameof(GetLessons), _lessonDataService.CreateLesson(dto.Title, dto.LastPublisher, dto.LastEdit));
_logger.LogInformation(
"[INFORMATION] Une leçon a été créé : title - {title}, lastPublisher - {publisher}, lastEdit - {lastEdit}",
dto.Title, dto.LastPublisher, dto.LastEdit);
return Created(nameof(GetLessons),
_lessonDataService.CreateLesson(dto.Title, dto.LastPublisher, dto.LastEdit));
}
[HttpPut("lesson/{id}")]
@ -115,16 +119,20 @@ namespace API.Controllers
_logger.LogError("[ERREUR] Problème ID - La mise à jour de la leçon avec l'id {id} a échouée.", id);
return BadRequest();
}
if (!ModelState.IsValid)
{
_logger.LogError("[ERREUR] Problème controlleur - La mise à jour de la leçon avec l'id {id} a échouée.", id);
_logger.LogError("[ERREUR] Problème controlleur - La mise à jour de la leçon avec l'id {id} a échouée.",
id);
return BadRequest();
}
if (lessonDTO != null)
{
_logger.LogInformation("[INFORMATION] La mise à jour de la leçon avec l'id {id} a été effectuée", id);
return Ok(_lessonDataService.UpdateLesson(id, lessonDTO));
}
_logger.LogError("[ERREUR] Aucune leçon trouvée avec l'id {id}.", id);
return NotFound();
}

@ -17,7 +17,8 @@ namespace API.Controllers
private readonly ILogger<ParagraphsController> _logger;
public ParagraphsController(IParagraphService<ParagraphDTO> paragraphDataService, ILogger<ParagraphsController> logger)
public ParagraphsController(IParagraphService<ParagraphDTO> paragraphDataService,
ILogger<ParagraphsController> logger)
{
_paragraphDataService = paragraphDataService;
_logger = logger;
@ -34,6 +35,7 @@ namespace API.Controllers
_logger.LogError("[ERREUR] Aucun paragraphe trouvé.");
return StatusCode(204);
}
_logger.LogInformation("[INFORMATION] {nb} Paragraphe(s) trouvé(s)", nbParagraph);
return Ok(_paragraphDataService.GetParagraphs(page, number, orderCriteria));
}
@ -47,7 +49,8 @@ namespace API.Controllers
{
_logger.LogInformation("[INFORMATION] Le paragraphe avec l'id {id} a été trouvé.", id);
return Ok(_paragraphDataService.GetParagraphById(id));
} catch (ArgumentException)
}
catch (ArgumentException)
{
_logger.LogError("[ERREUR] Aucun paragraphe trouvé avec l'id {id}.", id);
return NotFound();
@ -63,12 +66,12 @@ namespace API.Controllers
{
_logger.LogInformation("[INFORMATION] Le paragraphe avec le titre {title} a été trouvé.", title);
return Ok(_paragraphDataService.GetParagraphByTitle(title));
}catch (ArgumentException)
}
catch (ArgumentException)
{
_logger.LogError("[ERREUR] Aucun paragraphe trouvé avec le titre {title}.", title);
return NotFound();
}
}
[HttpDelete("paragraph/{id}")]
@ -81,12 +84,12 @@ namespace API.Controllers
{
_logger.LogInformation("[INFORMATION] Le paragraphe avec l'id {id} a été supprimé.", id);
return Ok(_paragraphDataService.DeleteParagraph(id));
} else
}
else
{
_logger.LogError("[ERREUR] Aucun paragraphe trouvé avec l'id {id}.", id);
return NotFound();
}
}
[HttpPost]
@ -94,12 +97,18 @@ namespace API.Controllers
[ProducesResponseType(typeof(string), 400)]
public IActionResult CreateParagraph([FromBody] ParagraphDTO dto)
{
if (dto.Title == null || dto.Content == null || dto.Info == null || dto.Query == null || dto.Comment == null)
if (dto.Title == null || dto.Content == null || dto.Info == null || dto.Query == null ||
dto.Comment == null)
{
return BadRequest();
}
_logger.LogInformation("[INFORMATION] Un paragraphe a été créé : title - {title}, content - {content}, info - {info}, query - {query}, comment - {comment}", dto.Title, dto.Content, dto.Info, dto.Query, dto.Comment);
return Created(nameof(GetParagraphs), _paragraphDataService.CreateParagraph(dto.Title, dto.Content, dto.Info, dto.Query, dto.Comment, dto.LessonId));
_logger.LogInformation(
"[INFORMATION] Un paragraphe a été créé : title - {title}, content - {content}, info - {info}, query - {query}, comment - {comment}",
dto.Title, dto.Content, dto.Info, dto.Query, dto.Comment);
return Created(nameof(GetParagraphs),
_paragraphDataService.CreateParagraph(dto.Title, dto.Content, dto.Info, dto.Query, dto.Comment,
dto.LessonId));
}
[HttpPut("paragraph/{id}")]
@ -113,16 +122,20 @@ namespace API.Controllers
_logger.LogError("[ERREUR] Problème ID - La mise à jour du paragraphe avec l'id {id} a échouée.", id);
return BadRequest();
}
if (!ModelState.IsValid)
{
_logger.LogError("[ERREUR] Problème controlleur - La mise à jour du paragraphe avec l'id {id} a échouée.", id);
_logger.LogError(
"[ERREUR] Problème controlleur - La mise à jour du paragraphe avec l'id {id} a échouée.", id);
return BadRequest();
}
if (paragraphDTO != null)
{
_logger.LogInformation("[INFORMATION] La mise à jour du paragraphe avec l'id {id} a été effectuée", id);
return Ok(_paragraphDataService.UpdateParagraph(id, paragraphDTO));
}
_logger.LogError("[ERREUR] Aucun paragraphe trouvé avec l'id {id}.", id);
return NotFound();
}

@ -34,6 +34,7 @@ namespace API.Controllers
_logger.LogError("[ERREUR] Aucun utilisateur trouvé.");
return StatusCode(204);
}
_logger.LogInformation("[INFORMATION] {nb} Utilisateur(s) trouvé(s)", nbUser);
return Ok(_successDataService.GetSuccesses(page, number, orderCriteria));
}
@ -47,7 +48,8 @@ namespace API.Controllers
{
_logger.LogInformation("[INFORMATION] Le succès avec l'id de l'utilisateur {id} a été trouvé.", userId);
return Ok(_successDataService.GetSuccessByUserId(userId));
} catch (ArgumentException)
}
catch (ArgumentException)
{
_logger.LogError("[ERREUR] Aucun utilisateur trouvé avec l'id de l'utilisateur {id}.", userId);
return NotFound();
@ -61,14 +63,15 @@ namespace API.Controllers
{
try
{
_logger.LogInformation("[INFORMATION] Utilisateur avec l'id de l'enquête {inquiryId} a été trouvé.", inquiryId);
_logger.LogInformation("[INFORMATION] Utilisateur avec l'id de l'enquête {inquiryId} a été trouvé.",
inquiryId);
return Ok(_successDataService.GetSuccessByInquiryId(inquiryId));
}catch (ArgumentException)
}
catch (ArgumentException)
{
_logger.LogError("[ERREUR] Aucun utilisateur trouvé avec l'id de l'enquête {inquiryId}.", inquiryId);
return NotFound();
}
}
[HttpDelete("success/{id}")]
@ -81,12 +84,12 @@ namespace API.Controllers
{
_logger.LogInformation("[INFORMATION] Le succès avec l'id {id} a été supprimé.", id);
return Ok(_successDataService.DeleteSuccess(id));
} else
}
else
{
_logger.LogError("[ERREUR] Aucun succès trouvé avec l'id {id}.", id);
return NotFound();
}
}
[HttpPost]
@ -98,8 +101,11 @@ namespace API.Controllers
{
return BadRequest();
}*/
_logger.LogInformation("[INFORMATION] Un succès a été créé : userId - {userId}, inquiryId - {inquiryId}, isFinished - {isFinished}", dto.UserId, dto.InquiryId, dto.IsFinished);
return Created(nameof(GetSuccesses), _successDataService.CreateSuccess(dto.UserId, dto.InquiryId, dto.IsFinished));
_logger.LogInformation(
"[INFORMATION] Un succès a été créé : userId - {userId}, inquiryId - {inquiryId}, isFinished - {isFinished}",
dto.UserId, dto.InquiryId, dto.IsFinished);
return Created(nameof(GetSuccesses),
_successDataService.CreateSuccess(dto.UserId, dto.InquiryId, dto.IsFinished));
}
[HttpPut("success/{id}")]
@ -110,19 +116,26 @@ namespace API.Controllers
{
if (id != successDTO.UserId)
{
_logger.LogError("[ERREUR] Problème ID - La mise à jour du succès avec l'id de l'utilisateur {id} a échouée.", id);
_logger.LogError(
"[ERREUR] Problème ID - La mise à jour du succès avec l'id de l'utilisateur {id} a échouée.", id);
return BadRequest();
}
if (!ModelState.IsValid)
{
_logger.LogError("[ERREUR] Problème controlleur - La mise à jour du succès avec l'id de l'utilisateur {id} a échouée.", id);
_logger.LogError(
"[ERREUR] Problème controlleur - La mise à jour du succès avec l'id de l'utilisateur {id} a échouée.",
id);
return BadRequest();
}
if (successDTO != null)
{
_logger.LogInformation("[INFORMATION] La mise à jour du succès avec l'id de l'utilisateur {id} a été effectuée", id);
_logger.LogInformation(
"[INFORMATION] La mise à jour du succès avec l'id de l'utilisateur {id} a été effectuée", id);
return Ok(_successDataService.UpdateSuccess(id, successDTO));
}
_logger.LogError("[ERREUR] Aucun succès trouvé avec l'id de l'utilisateur {id}.", id);
return NotFound();
}

@ -72,7 +72,7 @@ namespace API.Controllers
if (success)
{
logger.LogInformation("[INFORMATION] L'utilisateur avec l'id {id} a été supprimé.", id);
return Ok(userService.DeleteUser(id));
return Ok();
}
else
{

@ -6,7 +6,8 @@ using Shared.Mapper;
namespace API.Service;
public class ParagraphDataServiceApi(IParagraphService<ParagraphEntity> paragraphService) : IParagraphService<ParagraphDTO>
public class ParagraphDataServiceApi(IParagraphService<ParagraphEntity> paragraphService)
: IParagraphService<ParagraphDTO>
{
public IEnumerable<ParagraphDTO> GetParagraphs(int page, int number, ParagraphOrderCriteria orderCriteria)
{
@ -16,13 +17,15 @@ public class ParagraphDataServiceApi(IParagraphService<ParagraphEntity> paragrap
public ParagraphDTO GetParagraphById(int id) => paragraphService.GetParagraphById(id).FromEntityToDTO();
public ParagraphDTO GetParagraphByTitle(string title) => paragraphService.GetParagraphByTitle(title).FromEntityToDTO();
public ParagraphDTO GetParagraphByTitle(string title) =>
paragraphService.GetParagraphByTitle(title).FromEntityToDTO();
public bool DeleteParagraph(int id) => paragraphService.DeleteParagraph(id);
public ParagraphDTO UpdateParagraph(int id, ParagraphDTO paragraph) =>
paragraphService.UpdateParagraph(id, paragraph.FromDTOToEntity()).FromEntityToDTO();
public ParagraphDTO CreateParagraph(string title, string content, string info, string query, string comment, int lessonId) =>
public ParagraphDTO CreateParagraph(string title, string content, string info, string query, string comment,
int lessonId) =>
paragraphService.CreateParagraph(title, content, info, query, comment, lessonId).FromEntityToDTO();
}

@ -6,6 +6,8 @@ namespace API
{
public class WebAPIDbContext : IdentityDbContext<IdentityUser>
{
public WebAPIDbContext(DbContextOptions<WebAPIDbContext> options) : base(options) { }
public WebAPIDbContext(DbContextOptions<WebAPIDbContext> options) : base(options)
{
}
}
}

@ -17,13 +17,18 @@ namespace DbContextLib
public DbSet<SolutionEntity> Solutions { get; set; }
public DbSet<SuccessEntity> Successes { get; set; }
public DbSet<NotepadEntity> Notepads { get; set; }
public UserDbContext(DbContextOptions<UserDbContext> options) : base(options) { }
public UserDbContext(DbContextOptions<UserDbContext> options) : base(options)
{
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!optionsBuilder.IsConfigured)
{
optionsBuilder.UseNpgsql("Host=localhost;Database=SQLuedo;Username=admin;Password=motdepasse");
}
base.OnConfiguring(optionsBuilder);
}

@ -91,9 +91,12 @@ public class InquiryDataService : IInquiryService<InquiryEntity>
throw new ArgumentException("Impossible de trouver l'enquête", nameof(id));
}
updatingInquiry.Title = inquiry.Title;
updatingInquiry.Description = inquiry.Description;
updatingInquiry.IsUser = inquiry.IsUser;
foreach (var pptt in typeof(InquiryEntity).GetProperties()
.Where(p => p.CanWrite && p.Name != nameof(InquiryEntity.Id)))
{
pptt.SetValue(updatingInquiry, pptt.GetValue(inquiry));
}
DbContext.SaveChangesAsync();
return updatingInquiry;
}

@ -83,9 +83,12 @@ public class LessonDataService : ILessonService<LessonEntity>
throw new ArgumentException("Impossible de trouver la leçon", nameof(id));
}
updatingLesson.Title = lesson.Title;
updatingLesson.LastPublisher = lesson.LastPublisher;
updatingLesson.LastEdit = lesson.LastEdit;
foreach (var pptt in typeof(LessonEntity).GetProperties()
.Where(p => p.CanWrite && p.Name != nameof(LessonEntity.Id)))
{
pptt.SetValue(updatingLesson, pptt.GetValue(lesson));
}
DbContext.SaveChangesAsync();
return updatingLesson;
}

@ -81,7 +81,7 @@ public class ParagraphDataService : IParagraphService<ParagraphEntity>
return true;
}
public ParagraphEntity UpdateParagraph(int id, ParagraphEntity paragraphDTO)
public ParagraphEntity UpdateParagraph(int id, ParagraphEntity paragraph)
{
var updatingParagraph = DbContext.Paragraphs.FirstOrDefault(p => p.Id == id);
if (updatingParagraph == null)
@ -89,11 +89,12 @@ public class ParagraphDataService : IParagraphService<ParagraphEntity>
throw new ArgumentException("Impossible de trouver le paragraphe", nameof(id));
}
updatingParagraph.Title = paragraphDTO.Title;
updatingParagraph.Content = paragraphDTO.Content;
updatingParagraph.Info = paragraphDTO.Info;
updatingParagraph.Query = paragraphDTO.Query;
updatingParagraph.Comment = paragraphDTO.Comment;
foreach (var pptt in typeof(ParagraphEntity).GetProperties().Where(p =>
p.CanWrite && p.Name != nameof(ParagraphEntity.Id) && p.Name != nameof(ParagraphEntity.LessonId)))
{
pptt.SetValue(updatingParagraph, pptt.GetValue(paragraph));
}
DbContext.SaveChangesAsync();
return updatingParagraph;
}

@ -83,9 +83,12 @@ public class SuccessDataService : ISuccessService<SuccessEntity>
throw new ArgumentException("Impossible de trouver le succès", nameof(id));
}
updatingSuccess.UserId = success.UserId;
updatingSuccess.InquiryId = success.InquiryId;
updatingSuccess.IsFinished = success.IsFinished;
foreach (var pptt in typeof(SuccessEntity).GetProperties().Where(p =>
p.CanWrite && p.Name != nameof(SuccessEntity.UserId) && p.Name != nameof(SuccessEntity.InquiryId)))
{
pptt.SetValue(updatingSuccess, pptt.GetValue(success));
}
DbContext.SaveChangesAsync();
return updatingSuccess;
}

@ -85,10 +85,12 @@ public class UserDataService : IUserService<UserEntity>
throw new ArgumentException("Impossible de trouver l'utilisateur", nameof(id));
}
updatingUser.Username = user.Username;
updatingUser.Password = user.Password;
updatingUser.Email = user.Email;
updatingUser.IsAdmin = user.IsAdmin;
foreach (var pptt in typeof(UserEntity).GetProperties()
.Where(p => p.CanWrite && p.Name != nameof(UserEntity.Id)))
{
pptt.SetValue(updatingUser, pptt.GetValue(user));
}
DbContext.SaveChangesAsync();
return updatingUser;
}

@ -2,12 +2,13 @@
public class InquiryTableDTO
{
public int OwnerId { get; set; }
public string DatabaseName { get; set; }
public string ConnectionInfo { get; set; }
public InquiryTableDTO() { }
public InquiryTableDTO()
{
}
public InquiryTableDTO(int ownerId, string databaseName, string connectionInfo)
{

@ -8,7 +8,10 @@ public class LessonDTO
public DateOnly? LastEdit { get; set; }
public ICollection<ContentLessonDTO> Content { get; set; } = new List<ContentLessonDTO>();
public LessonDTO() { }
public LessonDTO()
{
}
public LessonDTO(int id, string title, string lastPublisher, DateOnly? lastEdit)
{
Id = id;

@ -7,7 +7,9 @@ public class NotepadDTO
public int InquiryId { get; set; }
public string Notes { get; set; }
public NotepadDTO() { }
public NotepadDTO()
{
}
public NotepadDTO(int id, int userId, int inquiryId, string notes)
{
@ -16,6 +18,7 @@ public class NotepadDTO
InquiryId = inquiryId;
Notes = notes;
}
public NotepadDTO(int userId, int inquiryId, string notes)
{
UserId = userId;

@ -8,8 +8,13 @@ public class SolutionDTO
public string MurderPlace { get; set; }
public string MurderWeapon { get; set; }
public string Explanation { get; set; }
public SolutionDTO() { }
public SolutionDTO(int ownerId, string murdererFirstName, string murdererLastName, string murderPlace, string murderWeapon, string explanation)
public SolutionDTO()
{
}
public SolutionDTO(int ownerId, string murdererFirstName, string murdererLastName, string murderPlace,
string murderWeapon, string explanation)
{
OwnerId = ownerId;
MurdererFirstName = murdererFirstName;
@ -18,7 +23,9 @@ public class SolutionDTO
MurderWeapon = murderWeapon;
Explanation = explanation;
}
public SolutionDTO(string murdererFirstName, string murdererLastName, string murderPlace, string murderWeapon, string explanation)
public SolutionDTO(string murdererFirstName, string murdererLastName, string murderPlace, string murderWeapon,
string explanation)
{
MurdererFirstName = murdererFirstName;
MurdererLastName = murdererLastName;

@ -6,7 +6,9 @@ public class SuccessDTO
public int InquiryId { get; set; }
public bool IsFinished { get; set; }
public SuccessDTO() { }
public SuccessDTO()
{
}
public SuccessDTO(int userId, int inquiryId, bool isFinished)
{

@ -8,7 +8,10 @@ public class UserDTO
public string Email { get; set; }
public bool IsAdmin { get; set; }
public UserDTO() { }
public UserDTO()
{
}
public UserDTO(int id, string username, string password, string email, bool isAdmin)
{
Id = id;

@ -6,10 +6,13 @@ namespace Entities;
[Table("BlackList")]
public class BlackListEntity
{
[Key]
public string Email { get; set; }
[Key] public string Email { get; set; }
public DateOnly ExpirationDate { get; set; }
public BlackListEntity() { }
public BlackListEntity()
{
}
public BlackListEntity(string email, DateOnly expirationDate)
{
Email = email;

@ -11,16 +11,20 @@ public class InquiryTableEntity
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Required]
public int OwnerId { get; set; }
public InquiryEntity Owner { get; set; }
public string DatabaseName { get; set; }
public string ConnectionInfo { get; set; }
public InquiryTableEntity() { }
public InquiryTableEntity()
{
}
public InquiryTableEntity(int inquiryId)
{
OwnerId = inquiryId;
}
public InquiryTableEntity(int inquiryId, string databaseName, string connectionInfo)
{
OwnerId = inquiryId;

@ -11,7 +11,9 @@ public class LessonEntity
public DateOnly? LastEdit { get; set; }
public ICollection<ContentLessonEntity> Content { get; set; } = new List<ContentLessonEntity>();
public LessonEntity() { }
public LessonEntity()
{
}
public LessonEntity(int id, string title, string lastPublisher, DateOnly? lastEdit)
{

@ -7,16 +7,16 @@ public class NotepadEntity
{
public int Id { get; set; }
[ForeignKey(nameof(User))]
public int UserId { get; set; }
[ForeignKey(nameof(User))] public int UserId { get; set; }
public UserEntity User { get; set; }
[ForeignKey(nameof(Inquiry))]
public int InquiryId { get; set; }
[ForeignKey(nameof(Inquiry))] public int InquiryId { get; set; }
public InquiryEntity Inquiry { get; set; }
public string Notes { get; set; }
public NotepadEntity() { }
public NotepadEntity()
{
}
public NotepadEntity(int id, int userId, UserEntity user, int inquiryId, InquiryEntity inquiry, string notes)
{
@ -27,6 +27,7 @@ public class NotepadEntity
Inquiry = inquiry;
Notes = notes;
}
public NotepadEntity(int userId, UserEntity user, int inquiryId, InquiryEntity inquiry, string notes)
{
UserId = userId;

@ -11,18 +11,25 @@ public class SolutionEntity
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Required]
public int OwnerId { get; set; }
public InquiryEntity? Owner { get; set; }
public string? MurdererFirstName { get; set; }
public string? MurdererLastName { get; set; }
public string? MurderPlace { get; set; }
public string? MurderWeapon { get; set; }
public string? Explaination { get; set; }
public SolutionEntity() { }
public SolutionEntity()
{
}
public SolutionEntity(int ownerId)
{
OwnerId = ownerId;
}
public SolutionEntity(int ownerId, InquiryEntity? owner, string murdererFirstName, string murdererLastName, string murderPlace, string murderWeapon, string explaination)
public SolutionEntity(int ownerId, InquiryEntity? owner, string murdererFirstName, string murdererLastName,
string murderPlace, string murderWeapon, string explaination)
{
OwnerId = ownerId;
Owner = owner;
@ -32,7 +39,9 @@ public class SolutionEntity
MurderWeapon = murderWeapon;
Explaination = explaination;
}
public SolutionEntity(InquiryEntity? owner, string murdererFirstName, string murdererLastName, string murderPlace, string murderWeapon, string explaination)
public SolutionEntity(InquiryEntity? owner, string murdererFirstName, string murdererLastName, string murderPlace,
string murderWeapon, string explaination)
{
Owner = owner;
MurdererFirstName = murdererFirstName;
@ -41,7 +50,9 @@ public class SolutionEntity
MurderWeapon = murderWeapon;
Explaination = explaination;
}
public SolutionEntity(int ownerId, string murdererFirstName, string murdererLastName, string murderPlace, string murderWeapon, string explanation)
public SolutionEntity(int ownerId, string murdererFirstName, string murdererLastName, string murderPlace,
string murderWeapon, string explanation)
{
OwnerId = ownerId;
MurdererFirstName = murdererFirstName;

@ -5,16 +5,16 @@ namespace Entities;
[Table("Success")]
public class SuccessEntity
{
[ForeignKey(nameof(User))]
public int UserId { get; set; }
[ForeignKey(nameof(User))] public int UserId { get; set; }
public UserEntity User { get; set; }
[ForeignKey(nameof(Inquiry))]
public int InquiryId { get; set; }
[ForeignKey(nameof(Inquiry))] public int InquiryId { get; set; }
public InquiryEntity Inquiry { get; set; }
public bool IsFinished { get; set; }
public SuccessEntity() { }
public SuccessEntity()
{
}
public SuccessEntity(int userId, UserEntity user, int inquiryId, InquiryEntity inquiry, bool isFinished)
{

@ -7,7 +7,9 @@ public class Inquiry
public string Description { get; set; }
public bool IsUser { get; set; }
public Inquiry() { }
public Inquiry()
{
}
public Inquiry(int id, string title, string description, bool isUser)
{

@ -6,12 +6,14 @@ public class InquiryTable
public string DatabaseName { get; set; }
public string ConnectionInfo { get; set; }
public InquiryTable() { }
public InquiryTable()
{
}
public InquiryTable(int inquiryId, string databaseName, string connectionInfo)
{
OwnerId = inquiryId;
DatabaseName = databaseName;
ConnectionInfo = connectionInfo;
}
}

@ -7,7 +7,9 @@ public class Notepad
public int InquiryId { get; set; }
public string Notes { get; set; }
public Notepad() { }
public Notepad()
{
}
public Notepad(int id, int userId, int inquiryId, string notes)
{
@ -16,6 +18,7 @@ public class Notepad
InquiryId = inquiryId;
Notes = notes;
}
public Notepad(int userId, int inquiryId, string notes)
{
UserId = userId;

@ -2,5 +2,8 @@ namespace Model.OrderCriteria;
public enum InquiryOrderCriteria
{
None, ByTitle, ByDescription, ByIsUser
None,
ByTitle,
ByDescription,
ByIsUser
}

@ -2,5 +2,8 @@ namespace Model.OrderCriteria;
public enum LessonOrderCriteria
{
None, ByTitle, ByLastPublisher, ByLastEdit
None,
ByTitle,
ByLastPublisher,
ByLastEdit
}

@ -2,5 +2,10 @@ namespace Model.OrderCriteria;
public enum ParagraphOrderCriteria
{
None, ByTitle, ByContent, ByInfo, ByQuery, ByComment
None,
ByTitle,
ByContent,
ByInfo,
ByQuery,
ByComment
}

@ -2,5 +2,8 @@ namespace Model.OrderCriteria;
public enum SuccessOrderCriteria
{
None, ByUserId, ByInquiryId, ByIsFinished
None,
ByUserId,
ByInquiryId,
ByIsFinished
}

@ -2,5 +2,9 @@ namespace Model.OrderCriteria;
public enum UserOrderCriteria
{
None, ById, ByUsername, ByEmail, ByIsAdmin
None,
ById,
ByUsername,
ByEmail,
ByIsAdmin
}

@ -8,8 +8,13 @@ public class Solution
public string MurderPlace { get; set; }
public string MurderWeapon { get; set; }
public string Explanation { get; set; }
public Solution() { }
public Solution(int ownerId, string murdererFirstName, string murdererLastName, string murderPlace, string murderWeapon, string explanation)
public Solution()
{
}
public Solution(int ownerId, string murdererFirstName, string murdererLastName, string murderPlace,
string murderWeapon, string explanation)
{
OwnerId = ownerId;
MurdererFirstName = murdererFirstName;
@ -18,7 +23,9 @@ public class Solution
MurderWeapon = murderWeapon;
Explanation = explanation;
}
public Solution(string murdererFirstName, string murdererLastName, string murderPlace, string murderWeapon, string explanation)
public Solution(string murdererFirstName, string murdererLastName, string murderPlace, string murderWeapon,
string explanation)
{
MurdererFirstName = murdererFirstName;
MurdererLastName = murdererLastName;

@ -6,7 +6,9 @@ public class Success
public int InquiryId { get; set; }
public bool IsFinished { get; set; }
public Success() { }
public Success()
{
}
public Success(int userId, int inquiryId, bool isFinished)
{

@ -8,7 +8,10 @@ public class User
public string Email { get; set; }
public bool IsAdmin { get; set; }
public User() { }
public User()
{
}
public User(int id, string username, string password, string email, bool isAdmin)
{
Id = id;

@ -9,6 +9,8 @@ namespace Shared
public TParagraph GetParagraphByTitle(string title);
public bool DeleteParagraph(int id);
public TParagraph UpdateParagraph(int id, TParagraph paragraph);
public TParagraph CreateParagraph(string title, string content, string info, string query, string comment, int lessonId);
public TParagraph CreateParagraph(string title, string content, string info, string query, string comment,
int lessonId);
}
}

@ -5,7 +5,6 @@ namespace TestAPI
[Fact]
public void Test1()
{
}
}
}

@ -9,6 +9,7 @@ namespace TestEF
private const string _password = "password";
private const bool _isAdmin = true;
private const int _id = 42;
[Fact]
public void TestDefaultConstructor()
{

Loading…
Cancel
Save