public void DeleteTest() { NoteAppUser user = repo_user.Find(x => x.Username == "xxx"); if (user != null) { repo_user.Delete(user); } }
public void UpdateTest() { NoteAppUser user = repo_user.Find(x => x.Username == "aabb"); if (user != null) { user.Username = "******"; int result = repo_user.Save(); } }
public void CommentTest() { NoteAppUser user = repo_user.Find(x => x.Id == 1); Note note = repo_note.Find(x => x.Id == 3); Comment comment = new Comment() { Text = "Bu bir testtir.", CreateOn = DateTime.Now, ModifiedOn = DateTime.Now, ModifiedUsername = "******", Note = note, Owner = user }; repo_com.Insert(comment); }
protected override void Seed(DatabaseContext context) { //Adding admin user NoteAppUser admin = new NoteAppUser() { Name = "Bilal", Surname = "Keremoğlu", Email = "*****@*****.**", ActivateGuid = Guid.NewGuid(), IsActive = true, IsAdmin = true, Username = "******", Password = "******", CreateOn = DateTime.Now, ModifiedOn = DateTime.Now.AddMinutes(5), ModifiedUsername = "******" }; //Adding standart user NoteAppUser standartUser = new NoteAppUser() { Name = "Ayça", Surname = "Akar", Email = "*****@*****.**", ActivateGuid = Guid.NewGuid(), IsActive = true, IsAdmin = false, Username = "******", Password = "******", CreateOn = DateTime.Now, ModifiedOn = DateTime.Now.AddMinutes(5), ModifiedUsername = "******" }; context.NoteAppUsers.Add(admin); context.NoteAppUsers.Add(standartUser); //Adding fake user for (int i = 0; i < 10; i++) { NoteAppUser user = new NoteAppUser() { Name = FakeData.NameData.GetFirstName(), Surname = FakeData.NameData.GetSurname(), Email = FakeData.NetworkData.GetEmail(), ActivateGuid = Guid.NewGuid(), IsActive = true, IsAdmin = false, Username = $"user{i}", Password = "******", CreateOn = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now), ModifiedOn = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now), ModifiedUsername = $"user{i}", }; context.NoteAppUsers.Add(user); } context.SaveChanges(); //Userlist List <NoteAppUser> userlist = context.NoteAppUsers.ToList(); //adding fake categories.. for (int i = 0; i < 10; i++) { Category cat = new Category() { Title = FakeData.PlaceData.GetStreetName(), Description = FakeData.PlaceData.GetAddress(), CreateOn = DateTime.Now, ModifiedOn = DateTime.Now, ModifiedUsername = "******" }; context.Categories.Add(cat); for (int k = 0; k < FakeData.NumberData.GetNumber(5, 9); k++) { NoteAppUser owner = userlist[FakeData.NumberData.GetNumber(0, userlist.Count - 1)]; Note note = new Note() { Title = FakeData.TextData.GetAlphabetical(FakeData.NumberData.GetNumber(5, 25)), Text = FakeData.TextData.GetSentences(FakeData.NumberData.GetNumber(1, 3)), IsDraft = false, LikeCount = FakeData.NumberData.GetNumber(1, 9), Owner = owner, CreateOn = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now), ModifiedOn = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now), ModifiedUsername = owner.Username, }; cat.Notes.Add(note); //adding fake comments for (int j = 0; j < FakeData.NumberData.GetNumber(3, 8); j++) { NoteAppUser comment_owner = userlist[FakeData.NumberData.GetNumber(0, userlist.Count - 1)]; Comment comment = new Comment() { Text = FakeData.TextData.GetSentence(), Note = note, Owner = comment_owner, CreateOn = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now), ModifiedOn = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now), ModifiedUsername = comment_owner.Username, }; note.Comments.Add(comment); } //Adding fake likes.. for (int m = 0; m < note.LikeCount; m++) { Liked liked = new Liked() { LikedUser = userlist[m] }; note.Likes.Add(liked); } } } context.SaveChanges(); }