From 409edd4199df46280607dfe7eb1ce9b12a0139b1 Mon Sep 17 00:00:00 2001 From: tonyfages Date: Mon, 11 Mar 2024 19:42:46 +0100 Subject: [PATCH] fix problem Formualire --- .../API/Controllers/ArticleController.cs | 4 +-- .../API/Entity_FrameWork.Article.db | Bin 36864 -> 4096 bytes .../Entity_FrameWork.Article.db-shm | Bin 32768 -> 32768 bytes .../API/Entity_FrameWork.Article.db-wal | Bin 0 -> 86552 bytes .../API_DbDataManager/DbManagerArticle.cs | 13 ++++--- .../API_DbDataManager/DbManagerFormulaire.cs | 10 +++--- .../API_DbDataManager/Extensions.cs | 4 +-- .../API_Mapping/FormulaireMapping.cs | 4 +-- .../Verax_API_EF/API_Model/FormulaireDTO.cs | 2 +- .../API_Services/IArticleService.cs | 3 +- .../DbContextLib/LibraryContext.cs | 33 ++++++++---------- .../Entities/ArticleUserEntity.cs | 2 +- .../Verax_API_EF/Entities/FormEntity.cs | 7 ++-- .../Verax_API_EF/Entities/UserEntity.cs | 4 ++- Verax_API_EF/Verax_API_EF/Model/Formulaire.cs | 2 +- .../Verax_API_EF/StubbedContextLib/Class1.cs | 16 ++++----- .../Entity_FrameWork.Article.db | Bin 45056 -> 45056 bytes .../Entity_FrameWork.Article.db-wal | Bin 12392 -> 0 bytes .../Test_Console_EF/Test_Console_Article.cs | 29 ++++++++------- 19 files changed, 64 insertions(+), 69 deletions(-) rename Verax_API_EF/Verax_API_EF/{Test_Console_EF => API}/Entity_FrameWork.Article.db-shm (97%) create mode 100644 Verax_API_EF/Verax_API_EF/API/Entity_FrameWork.Article.db-wal delete mode 100644 Verax_API_EF/Verax_API_EF/Test_Console_EF/Entity_FrameWork.Article.db-wal diff --git a/Verax_API_EF/Verax_API_EF/API/Controllers/ArticleController.cs b/Verax_API_EF/Verax_API_EF/API/Controllers/ArticleController.cs index b5b096c..a7aae26 100644 --- a/Verax_API_EF/Verax_API_EF/API/Controllers/ArticleController.cs +++ b/Verax_API_EF/Verax_API_EF/API/Controllers/ArticleController.cs @@ -43,9 +43,9 @@ namespace API.Controllers [HttpPost("/article")] - public async Task CreateArticle(long id, string title, string description, string author, string date, int lectureTime) + public async Task CreateArticle(Article article) { - return await _articleService.CreateArticle(id, title, description, author, date, lectureTime); + return await _articleService.CreateArticle(article); } [HttpDelete("/article/{id}")] diff --git a/Verax_API_EF/Verax_API_EF/API/Entity_FrameWork.Article.db b/Verax_API_EF/Verax_API_EF/API/Entity_FrameWork.Article.db index d1afbee0e70fb87729e26f8c4193e01e73c690e4..9a472209435d88229f65ab7a0ca30d67df87a462 100644 GIT binary patch delta 33 ncmZozz|^2HL7J73fq{W>Vxv7bBZFSrD_$UvL143>!ZdyWecuN5 literal 36864 zcmeI*&2QUe90zc}Bu&z(^~4lKQZ(>>NPGLvNZqc#=k(%w%qGh0$L zx-HEU(gOL5P$##AOHafJXHdAG?I8_PQDvAtvY`2;IATnsny)I z4Sl$I(~Op6zMdqOs(xKBv*Koz6}L7v*y?7nQZ46bKTDQw^kkE)RL&Q2<(uq=ev{?4 zs+;*DWnR#W)x~aR)dp|zB&+J%l#!pAAGKzV$IIi}?BPTigy zH}Id-m~Q#QEn4rl$m1R#GfB3-S=RH{i(WIwM*%DA>v~x)uId%$4G>B$dW4EjiSe_h zZ|F4AR&$lr+?qa}x_>$pNu<;AN1I;X1bQ>DBRtw)fp{vci+!ACC;jBT^C8&RK_2Sx z355=K{X!ty#jZuam{c%ZQV(R?+atOlP}9*~7>`bkbc7%K*uFSsl?3bmJ0x=9sl--V zmb}Y|bE`?yqaCB;+FrQlFzDT#Ou$V{l%nEle(${Mo%#3U-stk{?yo|lBgx;}A3u{$ zmhm&cpJurGC!P6^J3kBc!^tOZ(QZwSD7CqDR9wL@o0C(O?dJH!XF6386@GZ=)*NKU=8r8_#0f7u=6 zcZ@5q=>{6#9q`FD?$p}m;n7#!{-xPzaQba9>FT|~Yi_5_tERZTkN>*x%gJ@zhTR@Z zKb@MPVXDr4DQO>TSz2L%00bZa0SG_<0uX=z1Rwwb2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13>qVaNHf_7TMesJ{U9 z7C?W2WqAgnQV@Uu1Rwwb2tWV=5P$##AOL}-3pDo^pe=)Te*sk#;^q=(auZSCHjT|0uX=z1Rwwb2tWV=5P$##AOL}tDzHjXqq2CsVVax14q5Gy6ID~s z6**0dn1Cmb;NwN?wj{uQ@mD={GHv}L60SG_<0uX=z1Rwwb2rO5D zo0>I+ES-QArvv#OW(H-5MK3wZJf)*U$0srT&tlE@=awR3hJ!MWv%h`GvU%-<`khrh!>DTVzZ`I=hzeQZ&<1{a}fdB*`009U<00Izz00bZa0SGKAaJ_MX zHH*XrK22eP&d8cbo*z0?%O9#yt^j?fq=Af4o*lVXT)>k@5G}lQ`XN6z!rEm!kKlrK zPP?+`kzgSNAOHafKmY;|fB*y_009U<00PTZpgE6#>gi91)QD`w3>2F5ypQ0q?Ju@} zc;($^@IHd&+MuWx1Rwwb2tWV=5P$##AOHafK;XIr8sA6Yzt;N*zAb;H|BFBV+Eo!3 z@M*J(X5|sk!v-)w00Izz00bZa0SG_<0uX=z1R!wZ1g CreateArticle(long id, string title, string description, string author, string date, int lectureTime) + public async Task CreateArticle(Article article) { var entity = new Entities.ArticleEntity() { - Id = id, - Title = title, - Description = description, - Author = author, - DatePublished = date, - LectureTime = lectureTime, + Title = article.Title, + Description = article.Description, + Author = article.Author, + DatePublished = article.DatePublished, + LectureTime = article.LectureTime, }; _context.ArticleSet.Add(entity); await _context.SaveChangesAsync(); diff --git a/Verax_API_EF/Verax_API_EF/API_DbDataManager/DbManagerFormulaire.cs b/Verax_API_EF/Verax_API_EF/API_DbDataManager/DbManagerFormulaire.cs index 2f879cd..4cb5671 100644 --- a/Verax_API_EF/Verax_API_EF/API_DbDataManager/DbManagerFormulaire.cs +++ b/Verax_API_EF/Verax_API_EF/API_DbDataManager/DbManagerFormulaire.cs @@ -33,7 +33,7 @@ public class DbManagerFormulaire : IFormulaireService formulaireList = _context.FormSet.OrderBy(f => f.DatePublication).Select(f => f.ToModel()).ToList(); break; case FormOrderCriteria.ByPseudo: - formulaireList = _context.FormSet.OrderBy(f => f.Pseudo).Select(f => f.ToModel()).ToList(); + formulaireList = _context.FormSet.OrderBy(f => f.UserEntityPseudo).Select(f => f.ToModel()).ToList(); break; default: formulaireList = _context.FormSet.Select(f => f.ToModel()).ToList(); @@ -54,9 +54,10 @@ public class DbManagerFormulaire : IFormulaireService var entity = new FormEntity() { Id = formulaire.Id, - Pseudo = formulaire.Pseudo, + Link = formulaire.Lien, Theme = formulaire.Theme, - DatePublication = formulaire.Date + DatePublication = formulaire.Date, + UserEntityPseudo = formulaire.UserPseudo }; _context.FormSet.Add(entity); @@ -77,9 +78,10 @@ public class DbManagerFormulaire : IFormulaireService { var entity = _context.FormSet.FirstOrDefault(f => f.Id == id); if (entity == null) return false; - entity.Pseudo = formulaire.Pseudo; entity.Theme = formulaire.Theme; entity.DatePublication = formulaire.Date; + entity.Link = formulaire.Lien; + entity.UserEntityPseudo = formulaire.UserPseudo; await _context.SaveChangesAsync(); return true; } diff --git a/Verax_API_EF/Verax_API_EF/API_DbDataManager/Extensions.cs b/Verax_API_EF/Verax_API_EF/API_DbDataManager/Extensions.cs index 511f7da..d35d9b8 100644 --- a/Verax_API_EF/Verax_API_EF/API_DbDataManager/Extensions.cs +++ b/Verax_API_EF/Verax_API_EF/API_DbDataManager/Extensions.cs @@ -26,10 +26,10 @@ public static class Extensions => new User{ Pseudo = user.Pseudo, Mdp = user.Mdp, Prenom = user.Prenom, Nom = user.Nom, Mail = user.Mail, Role = user.Role}; public static FormEntity ToEntity(this Formulaire form) - => new FormEntity{ Id = form.Id, Pseudo = form.Pseudo, Theme = form.Theme, Link = form.Lien}; + => new FormEntity{ Id = form.Id, UserEntityPseudo = form.UserPseudo, Theme = form.Theme, Link = form.Lien}; public static Formulaire ToModel(this FormEntity form) - => new Formulaire{ Id = form.Id, Pseudo = form.Pseudo, Theme = form.Theme, Lien = form.Link}; + => new Formulaire{ Id = form.Id, UserPseudo = form.UserEntityPseudo, Theme = form.Theme, Lien = form.Link}; } \ No newline at end of file diff --git a/Verax_API_EF/Verax_API_EF/API_Mapping/FormulaireMapping.cs b/Verax_API_EF/Verax_API_EF/API_Mapping/FormulaireMapping.cs index eef95ef..8a0e631 100644 --- a/Verax_API_EF/Verax_API_EF/API_Mapping/FormulaireMapping.cs +++ b/Verax_API_EF/Verax_API_EF/API_Mapping/FormulaireMapping.cs @@ -11,7 +11,7 @@ public static class FormulaireMapping Theme = f.Theme, Date = f.Date, Lien = f.Lien, - Pseudo = f.Pseudo + UserPseudo = f.UserPseudo }; public static Formulaire ToModel(this FormulaireDTO f) => new() @@ -20,6 +20,6 @@ public static class FormulaireMapping Theme = f.Theme, Date = f.Date, Lien = f.Lien, - Pseudo = f.Pseudo + UserPseudo = f.UserPseudo }; } \ No newline at end of file diff --git a/Verax_API_EF/Verax_API_EF/API_Model/FormulaireDTO.cs b/Verax_API_EF/Verax_API_EF/API_Model/FormulaireDTO.cs index df256d4..67b5e38 100644 --- a/Verax_API_EF/Verax_API_EF/API_Model/FormulaireDTO.cs +++ b/Verax_API_EF/Verax_API_EF/API_Model/FormulaireDTO.cs @@ -6,7 +6,7 @@ public class FormulaireDTO public string Theme { get; set; } public string Date { get; set; } public string Lien { get; set; } - public string Pseudo { get; set; } + public string UserPseudo { get; set; } } \ No newline at end of file diff --git a/Verax_API_EF/Verax_API_EF/API_Services/IArticleService.cs b/Verax_API_EF/Verax_API_EF/API_Services/IArticleService.cs index 28a2851..c10505b 100644 --- a/Verax_API_EF/Verax_API_EF/API_Services/IArticleService.cs +++ b/Verax_API_EF/Verax_API_EF/API_Services/IArticleService.cs @@ -10,8 +10,7 @@ namespace API_Services Task GetArticleById(int id, int index, int count, ArticleOrderCriteria orderCriterium); - Task CreateArticle(long id, string title, string description, string author, string date, - int lectureTime); + Task CreateArticle(Article article); Task DeleteArticle(long id); diff --git a/Verax_API_EF/Verax_API_EF/DbContextLib/LibraryContext.cs b/Verax_API_EF/Verax_API_EF/DbContextLib/LibraryContext.cs index 774ded2..08e8dba 100644 --- a/Verax_API_EF/Verax_API_EF/DbContextLib/LibraryContext.cs +++ b/Verax_API_EF/Verax_API_EF/DbContextLib/LibraryContext.cs @@ -41,12 +41,12 @@ public class LibraryContext : DbContext modelBuilder.Entity() .HasMany(u => u.Forms) .WithOne(f => f.User) - .HasForeignKey(f => f.UserEntityId); + .HasForeignKey(f => f.UserEntityPseudo); modelBuilder.Entity() .HasOne(f => f.User) .WithMany(u => u.Forms) - .HasForeignKey(f => f.UserEntityId); + .HasForeignKey(f => f.UserEntityPseudo); modelBuilder.Entity().HasData( new ArticleEntity @@ -83,24 +83,24 @@ public class LibraryContext : DbContext modelBuilder.Entity().HasData( new UserEntity { - Id = 1, Nom = "Fages", Prenom = "Tony", Pseudo = "TonyF", Mail = "tony@gmail.com", Mdp = "1234", Role = "Admin" + Nom = "Fages", Prenom = "Tony", Pseudo = "TonyF", Mail = "tony@gmail.com", Mdp = "1234", Role = "Admin" }, new UserEntity { - Id = 2, Nom = "Smith", Prenom = "Tom", Pseudo = "TomS", Mail = "tom@mail.com", Mdp = "1234", + Nom = "Smith", Prenom = "Tom", Pseudo = "TomS", Mail = "tom@mail.com", Mdp = "1234", Role = "User" }, new UserEntity { - Id = 3, Nom = "M&M's", Prenom = "Red", Pseudo = "RedM", Mail = "M&M#mail.com", Mdp = "1234", Role = "Modérator" + Nom = "M&M's", Prenom = "Red", Pseudo = "RedM", Mail = "M&M#mail.com", Mdp = "1234", Role = "Modérator" }, new UserEntity { - Id = 4, Nom = "Cascarra", Prenom = "Cascarra", Pseudo = "Sha", Mail = "ShaCasca@gmail.com", Mdp = "1234", Role = "Admin" + Nom = "Cascarra", Prenom = "Cascarra", Pseudo = "Sha", Mail = "ShaCasca@gmail.com", Mdp = "1234", Role = "Admin" }, new UserEntity { - Id = 5, Nom = "Sillard", Prenom = "Noa", Pseudo = "NoaSil", Mail = "", Mdp = "1234", Role = "Admin" + Nom = "Sillard", Prenom = "Noa", Pseudo = "NoaSil", Mail = "", Mdp = "1234", Role = "Admin" } ); @@ -108,27 +108,27 @@ public class LibraryContext : DbContext new ArticleUserEntity { ArticleEntityId = 1, - UserEntityId = 1 + UserEntityPseudo = "TonyF" }, new ArticleUserEntity { ArticleEntityId = 2, - UserEntityId = 2 + UserEntityPseudo = "NoaSil" }, new ArticleUserEntity { ArticleEntityId = 3, - UserEntityId = 3 + UserEntityPseudo = "Sha" }, new ArticleUserEntity { ArticleEntityId = 3, - UserEntityId = 1 + UserEntityPseudo = "RedM" }, new ArticleUserEntity { ArticleEntityId = 2, - UserEntityId = 3 + UserEntityPseudo = "TomS" } ); @@ -136,26 +136,23 @@ public class LibraryContext : DbContext new FormEntity { Id = 1, - Pseudo= "Form 1", DatePublication = "Form 1 Description", Link = "hhtp://form1.com", - UserEntityId = 1 + UserEntityPseudo = "Sha" }, new FormEntity { Id = 2, - Pseudo= "Form 2", DatePublication = "Form 2 Description", Link = "hhtp://form2.com", - UserEntityId = 2 + UserEntityPseudo = "Sha" }, new FormEntity { Id = 3, - Pseudo= "Form 3", DatePublication = "Form 3 Description", Link = "hhtp://form3.com", - UserEntityId = 3 + UserEntityPseudo = "Sha" } ); } diff --git a/Verax_API_EF/Verax_API_EF/Entities/ArticleUserEntity.cs b/Verax_API_EF/Verax_API_EF/Entities/ArticleUserEntity.cs index 2faf6b7..74bb542 100644 --- a/Verax_API_EF/Verax_API_EF/Entities/ArticleUserEntity.cs +++ b/Verax_API_EF/Verax_API_EF/Entities/ArticleUserEntity.cs @@ -2,6 +2,6 @@ namespace Entities; public class ArticleUserEntity { - public long UserEntityId { get; set; } + public string UserEntityPseudo { get; set; } public long ArticleEntityId { get; set; } } \ No newline at end of file diff --git a/Verax_API_EF/Verax_API_EF/Entities/FormEntity.cs b/Verax_API_EF/Verax_API_EF/Entities/FormEntity.cs index 75b43e0..8a45973 100644 --- a/Verax_API_EF/Verax_API_EF/Entities/FormEntity.cs +++ b/Verax_API_EF/Verax_API_EF/Entities/FormEntity.cs @@ -6,11 +6,8 @@ public class FormEntity public string Theme { get; set; } = string.Empty; public string DatePublication { get; set; } = string.Empty; public string Link { get; set; } = string.Empty; - public string Pseudo { get; set; } = string.Empty; - - public long UserEntityId { get; set; } - public UserEntity User { get; set; } = null; - + public string UserEntityPseudo{ get; set; } + public UserEntity User { get; set; } = null!; } \ No newline at end of file diff --git a/Verax_API_EF/Verax_API_EF/Entities/UserEntity.cs b/Verax_API_EF/Verax_API_EF/Entities/UserEntity.cs index 7d8680a..d7604c0 100644 --- a/Verax_API_EF/Verax_API_EF/Entities/UserEntity.cs +++ b/Verax_API_EF/Verax_API_EF/Entities/UserEntity.cs @@ -1,8 +1,10 @@ +using System.ComponentModel.DataAnnotations; + namespace Entities; public class UserEntity { - public long Id { get; set; } + [Key] public string Pseudo { get; set; } = string.Empty; public string Mdp { get; set; } = string.Empty; diff --git a/Verax_API_EF/Verax_API_EF/Model/Formulaire.cs b/Verax_API_EF/Verax_API_EF/Model/Formulaire.cs index 9b883fb..6dee834 100644 --- a/Verax_API_EF/Verax_API_EF/Model/Formulaire.cs +++ b/Verax_API_EF/Verax_API_EF/Model/Formulaire.cs @@ -6,5 +6,5 @@ public class Formulaire public string Theme { get; set; } public string Date { get; set; } public string Lien { get; set; } - public string Pseudo { get; set; } + public string UserPseudo { get; set; } } \ No newline at end of file diff --git a/Verax_API_EF/Verax_API_EF/StubbedContextLib/Class1.cs b/Verax_API_EF/Verax_API_EF/StubbedContextLib/Class1.cs index b922036..6ef8d5f 100644 --- a/Verax_API_EF/Verax_API_EF/StubbedContextLib/Class1.cs +++ b/Verax_API_EF/Verax_API_EF/StubbedContextLib/Class1.cs @@ -45,16 +45,16 @@ public class StubbedContext : LibraryContext modelBuilder.Entity().HasData( new UserEntity { - Id = 1, Nom = "Fages", Prenom = "Tony", Pseudo = "TonyF", Mail = "tony@gmail.com", Mdp = "1234", Role = "Admin" + Nom = "Fages", Prenom = "Tony", Pseudo = "TonyF", Mail = "tony@gmail.com", Mdp = "1234", Role = "Admin" }, new UserEntity { - Id = 2, Nom = "Smith", Prenom = "Tom", Pseudo = "TomS", Mail = "tom@mail.com", Mdp = "1234", + Nom = "Smith", Prenom = "Tom", Pseudo = "TomS", Mail = "tom@mail.com", Mdp = "1234", Role = "User" }, new UserEntity { - Id = 3, Nom = "M&M's", Prenom = "Red", Pseudo = "RedM", Mail = "M&M#mail.com", Mdp = "1234", Role = "Modérator" + Nom = "M&M's", Prenom = "Red", Pseudo = "RedM", Mail = "M&M#mail.com", Mdp = "1234", Role = "Modérator" } ); @@ -62,27 +62,27 @@ public class StubbedContext : LibraryContext new ArticleUserEntity { ArticleEntityId = 1, - UserEntityId = 1 + UserEntityPseudo = "Sha" }, new ArticleUserEntity { ArticleEntityId = 2, - UserEntityId = 2 + UserEntityPseudo = "Sha" }, new ArticleUserEntity { ArticleEntityId = 3, - UserEntityId = 3 + UserEntityPseudo = "Sha" }, new ArticleUserEntity { ArticleEntityId = 3, - UserEntityId = 1 + UserEntityPseudo = "Sha" }, new ArticleUserEntity { ArticleEntityId = 2, - UserEntityId = 3 + UserEntityPseudo = "Sha" } ); } diff --git a/Verax_API_EF/Verax_API_EF/Test_Console_EF/Entity_FrameWork.Article.db b/Verax_API_EF/Verax_API_EF/Test_Console_EF/Entity_FrameWork.Article.db index 16746d575d690983803c342494bc39c7fa82814b..730f5f313fadef5a28a425a80dd2ed5741567cb9 100644 GIT binary patch delta 93 zcmZp8z|`=7X~QFbMz+n5{S^&(Soo6|_|Nmt<YE90%|um!`y6&q)-Q6hWt$e`=wdT6_U@aqFK*gH03CXh*?O5LCp?*;f!0 z6<@%~JV4#rr64#J@lt7V=>wF0e~{$v2j9SbZo12zN@twbn&-G#E~&Tk>ABb7;IjR7 z@nNsWdDcq(?=Szv_gC)Cb%r$wjXBz-pX`Hz00bZa0SG_<0uX=z1Rwwb2tZ(L1QbFR z`5iy>cAZF41UA`kI3b&)XLyq3H^ay+*Bmw%*^=aBS%dq6=hjkNxqaM9?gd0z;^;fQ zqepCjf&c^{009U<00Izz00bZa0SHXCz_y;vW#xk772Ud8aT;oErFdL&%ni-3G|RBo zs!8U-wP$WHQh z5=xHrs!a^xf5IA(u!ads(D}cF-2a0)B4G{_Cfiaac?S0a6~FiJ;yuMvtSQnCM|-qG uziD@}w;rp900bZa0SG_<0uX=z1Rwwb2#mdeNMv405uPU`c?$v|viu9FKzGal diff --git a/Verax_API_EF/Verax_API_EF/Test_Console_EF/Test_Console_Article.cs b/Verax_API_EF/Verax_API_EF/Test_Console_EF/Test_Console_Article.cs index ae275db..df969d9 100644 --- a/Verax_API_EF/Verax_API_EF/Test_Console_EF/Test_Console_Article.cs +++ b/Verax_API_EF/Verax_API_EF/Test_Console_EF/Test_Console_Article.cs @@ -117,7 +117,7 @@ void listForms() var forms = context.FormSet; foreach (var form in forms) { - Console.WriteLine($"{form.Id} - {form.Link} - {form.DatePublication} - {form.Pseudo} - {form.Theme} - {form.UserEntityId}"); + Console.WriteLine($"{form.Id} - {form.Link} - {form.DatePublication} - {form.Theme} - {form.UserEntityPseudo}"); } } } @@ -132,8 +132,7 @@ void addForm() Theme = "Covid", DatePublication = "16-02-2024", Link = "https://www.covid.com", - Pseudo = "Tony Fages", - UserEntityId = 1 + UserEntityPseudo = "Sha" }; context.FormSet.Add(form); context.SaveChanges(); @@ -175,7 +174,7 @@ void listUser() var users = context.UserSet; foreach (var user in users) { - Console.WriteLine($"{user.Id} - {user.Pseudo} - {user.Nom} - {user.Prenom} - {user.Mail} - {user.Role}"); + Console.WriteLine($" {user.Pseudo} - {user.Nom} - {user.Prenom} - {user.Mail} - {user.Role}"); } } } @@ -186,7 +185,7 @@ void addUser() { var user = new UserEntity { - Id = 7, Nom = "Fages", Prenom = "Tony", Pseudo = "TonyF", Mail = "tony@gmail.com", Mdp = "1234", Role = "Admin" + Nom = "Fages", Prenom = "Tony", Pseudo = "TonyF", Mail = "tony@gmail.com", Mdp = "1234", Role = "Admin" }; context.UserSet.Add(user); context.SaveChanges(); @@ -198,7 +197,7 @@ void updateUser() { using (var context = new LibraryContext()) { - var user = context.UserSet.Where(u => u.Id.Equals(7)); + var user = context.UserSet.Where(u => u.Pseudo.Equals("Sha")); foreach (var users in user) { @@ -213,7 +212,7 @@ void deleteUser() { using (var context = new LibraryContext()) { - var user = context.UserSet.Where(u => u.Id.Equals(7)); + var user = context.UserSet.Where(u => u.Pseudo.Equals("Sha")); foreach (var users in user) { @@ -231,7 +230,7 @@ void listArticleUser() var articleUsers = context.ArticleUserSet; foreach (var articleUser in articleUsers) { - Console.WriteLine($"{articleUser.ArticleEntityId} - {articleUser.UserEntityId}"); + Console.WriteLine($"{articleUser.ArticleEntityId} - {articleUser.UserEntityPseudo}"); } } } @@ -243,7 +242,7 @@ void addArticleUser() var articleUser = new ArticleUserEntity { ArticleEntityId = 2, - UserEntityId = 1 + UserEntityPseudo = "Sha" }; context.ArticleUserSet.Add(articleUser); context.SaveChanges(); @@ -255,8 +254,8 @@ void updateArticleUser() { using (var context = new LibraryContext()) { - var articleUser = context.ArticleUserSet.FirstOrDefault(au => au.UserEntityId.Equals(2)); - if (articleUser != null) articleUser.UserEntityId = 3; + var articleUser = context.ArticleUserSet.FirstOrDefault(au => au.UserEntityPseudo.Equals("Sha")); + if (articleUser != null) articleUser.UserEntityPseudo = "Sha"; context.SaveChanges(); } listArticleUser(); @@ -266,7 +265,7 @@ void deleteArticleUser() { using (var context = new LibraryContext()) { - var articleUser = context.ArticleUserSet.Where(au => au.UserEntityId.Equals(1)).Where(u => u.ArticleEntityId.Equals(1)); + var articleUser = context.ArticleUserSet.Where(au => au.UserEntityPseudo.Equals(1)).Where(u => u.ArticleEntityId.Equals(1)); foreach (var articleUsers in articleUser) { @@ -281,10 +280,10 @@ void listFormUser() { using (var context = new LibraryContext()) { - var formUsers = context.FormSet; + var formUsers = context.FormSet.Where(u => u.UserEntityPseudo.Equals(1)); foreach (var formUser in formUsers) { - Console.WriteLine($"{formUser.UserEntityId}"); + Console.WriteLine($"{formUser.UserEntityPseudo} - {formUser.Theme} - {formUser.Link}"); } } } @@ -295,7 +294,7 @@ void addFormUser() { var formUser = new FormEntity { - UserEntityId = 1 + UserEntityPseudo = "Sha", }; context.FormSet.Add(formUser); context.SaveChanges();