public async Task <IActionResult> Create([Bind("Id,name,description,actionType,organizationId,creationDateTime,startDateTime,endDateTime")] CharityAction charityAction, string loggedOrg = null) { if (loggedOrg == null) { if (HttpContext.Session.GetString("username") == null) { return(RedirectToAction("", "")); } } if (ModelState.IsValid) { string orgId = loggedOrg; if (orgId == null) { orgId = HttpContext.Session.GetString("idOfLoggedAccount"); } charityAction.organizationId = Guid.Parse(orgId); charityAction.creationDateTime = DateTime.Now; charityAction.Id = Guid.NewGuid(); _context.Add(charityAction); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(charityAction)); }
public async Task MakeDonationHandler_Handle_CharityActionDonation_AsAnonymous_Return_Correct() { DonationsContext.OpenInMemoryConnection(); try { MakeDonationResponse response; var charity = new Charity() { CharityKey = Guid.NewGuid(), Name = "TestName", CoverImage = "TestImage", ThankYou = "ThankYou" }; var charityAction = new CharityAction() { ActionEndDateTime = DateTime.UtcNow, Name = "TestName", CharityActionKey = Guid.NewGuid(), Charity = charity, CoverImage = "TestImage", ThankYou = "ThankYou" }; var makeDonationRequest = new MakeDonationRequest { CharityKey = charity.CharityKey, CharityActionKey = charityAction.CharityActionKey, Amount = 10m, IsAnonymous = false }; using (var context = DonationsContext.GetInMemoryContext()) { context.Charities.Add(charity); context.CharityActions.Add(charityAction); await context.SaveChangesAsync(); var handler = new MakeDonationRequestHandler(context, AutoMapperHelper.BuildMapper(new MappingProfile())); response = await handler.Handle(makeDonationRequest); } using (var context = DonationsContext.GetInMemoryContext()) { Assert.AreEqual(1, context.CharityActionDonations.Count()); Assert.IsTrue(response.IsSuccess); Assert.AreEqual(makeDonationRequest.Amount, context.CharityActionDonations.First().Amount); Assert.AreEqual(makeDonationRequest.IsAnonymous, context.CharityActionDonations.First().IsAnonymous); Assert.AreEqual(charityAction.ThankYou, response.ThankYou); Assert.AreEqual(charityAction.CoverImage, response.CoverImage); } } finally { DonationsContext.CloseInMemoryConnection(); } }
public async Task <IActionResult> Edit(Guid id, [Bind("Id,name,description,actionType,organizationId,creationDateTime,startDateTime,endDateTime")] CharityAction charityAction) { if (id != charityAction.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(charityAction); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CharityActionExists(charityAction.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(charityAction)); }
public async Task GetCharityActionByKeyRequest_Handle_Returns_Null() { CharityActionContext.OpenInMemoryConnection(); try { //Arrange using (var context = CharityActionContext.GetInMemoryContext()) { var keyAction = Guid.NewGuid(); var user = new UserKey { Key = Guid.NewGuid() }; var users = new Collection <UserKey> { user }; var charity = new Charity { CharityKey = Guid.NewGuid() }; var charityAction = new CharityAction { CharityActionKey = keyAction, UserKeys = users, Category = Core.Enums.Category.None, IBAN = "", Name = "", Description = "0-IBAN", CoverImage = "", Logo = "", Charity = charity }; context.Add(charityAction); context.SaveChanges(); } var request = new GetCharityActionByKeyRequest(); GetCharityActionByKeyResponse response; //Act using (var context = CharityActionContext.GetInMemoryContext()) { var handler = new GetCharityActionByKeyRequestHandler(context, AutoMapperHelper.BuildMapper(new MappingProfile())); response = await handler.Handle(request); } //Assert Assert.IsFalse(response.IsSuccess); } finally { CharityActionContext.CloseInMemoryConnection(); } }
public async Task ApproveCharityRequest_Handle_Returns_AlreadyActive() { CharityActionContext.OpenInMemoryConnection(); try { var busMock = new Mock <IBus>(); busMock.Setup(m => m.PublishAsync(It.IsAny <CharityActionCreatedEvent>())).Returns(Task.FromResult(true)); ApproveCharityActionResponse response; var request = new ApproveCharityActionRequest { CharityActionKey = Guid.NewGuid() }; var charity = new Charity { CharityKey = Guid.NewGuid() }; var charityAction = new CharityAction { CharityActionKey = request.CharityActionKey, IsApproved = true, Name = "0", Category = Category.AnimalProtection, IBAN = "1111-1111", CoverImage = "x", Charity = charity }; using (var context = CharityActionContext.GetInMemoryContext()) { context.CharityActions.Add(charityAction); context.SaveChanges(); } using (var context = CharityActionContext.GetInMemoryContext()) { var handler = new ApproveCharityActionRequestHandler(context, AutoMapperHelper.BuildMapper(new MappingProfile()), busMock.Object); response = await handler.Handle(request); } using (var context = CharityActionContext.GetInMemoryContext()) { Assert.IsTrue(context.CharityActions.Single().IsApproved); Assert.IsFalse(response.IsSuccess); Assert.AreEqual(ErrorType.AlreadyActive, response.ErrorType); } busMock.Verify(m => m.PublishAsync(It.Is <CharityActionCreatedEvent>(e => e.CharityActionKey == request.CharityActionKey)), Times.Never); } finally { CharityActionContext.CloseInMemoryConnection(); } }
public async Task CharityActionUpdatedEventHandler_Handle_Returns_Success() { DonationsContext.OpenInMemoryConnection(); try { var charity = new DAL.Charity { CharityKey = Guid.NewGuid(), Name = "Test", ChartityActions = new List <CharityAction>(), }; var charityAction = new CharityAction() { ActionEndDateTime = DateTime.UtcNow, Name = "TestName", CharityActionKey = Guid.NewGuid(), Charity = charity }; var updatedCharityActionEvent = new CharityActionUpdatedEvent() { CharityActionKey = charityAction.CharityActionKey, CoverImage = "pretty image", Name = "Pretty CharityAction Name", ThankYou = "ThankYouVeryMuch" }; using (var context = DonationsContext.GetInMemoryContext()) { context.CharityActions.Add(charityAction); context.SaveChanges(); } using (var context = DonationsContext.GetInMemoryContext()) { var handler = new CharityActionUpdatedEventHandler(context); await handler.ConsumeAsync(updatedCharityActionEvent); } using (var context = DonationsContext.GetInMemoryContext()) { Assert.AreEqual(1, context.CharityActions.Count()); Assert.AreEqual(updatedCharityActionEvent.ActionEndDateTime, context.CharityActions.Single().ActionEndDateTime); Assert.AreEqual(updatedCharityActionEvent.CoverImage, context.CharityActions.Single().CoverImage); Assert.AreEqual(updatedCharityActionEvent.ThankYou, context.CharityActions.Single().ThankYou); Assert.AreEqual(updatedCharityActionEvent.Name, context.CharityActions.Single().Name); } } finally { DonationsContext.CloseInMemoryConnection(); } }
public async Task UserUpdatedEventHandler_Consume_Updates_Name() { CharityActionContext.OpenInMemoryConnection(); try { var userUpdatedEvent = new UserUpdatedEvent { UserKey = Guid.NewGuid(), FirstName = "Ellen", LastName = "Doe", EmailAddress = "*****@*****.**", ProfileImage = "new image" }; var charity = new Charity { CharityKey = Guid.NewGuid() }; var charityAction = new CharityAction { OrganiserUserKey = userUpdatedEvent.UserKey, OrganiserUserName = "******", OrganiserImage = "old image", Charity = charity }; using (var context = CharityActionContext.GetInMemoryContext()) { context.CharityActions.Add(charityAction); context.SaveChanges(); } using (var context = CharityActionContext.GetInMemoryContext()) { var handler = new UserUpdatedEventHandler(context); await handler.ConsumeAsync(userUpdatedEvent); } using (var context = CharityActionContext.GetInMemoryContext()) { Assert.AreEqual("Ellen Doe", context.CharityActions.Single().OrganiserUserName); Assert.AreEqual("new image", context.CharityActions.Single().OrganiserImage); } } finally { CharityActionContext.CloseInMemoryConnection(); } }
public async Task GetCharityTotalRequestHandler_Handle_With_CharityActions_Return_NoDonationsFound() { DonationsContext.OpenInMemoryConnection(); try { GetCharityTotalResponse response; var user = new User { UserKey = Guid.NewGuid(), ProfileImage = "PrettyImage", UserName = "******" }; var charity = new Charity() { CharityKey = Guid.NewGuid(), Name = "TestName", }; var charityAction = new CharityAction() { ActionEndDateTime = DateTime.UtcNow, Name = "TestName", CharityActionKey = Guid.NewGuid(), Charity = charity }; var charityDonation = new CharityDonation { Amount = 1m, DateTimeStamp = DateTime.UtcNow.AddHours(-1), DonationType = DonationType.Once, IsAnonymous = false, Charity = charity, User = user }; var charityDonation1 = new CharityDonation { Amount = 5m, DateTimeStamp = DateTime.UtcNow.AddHours(-4), DonationType = DonationType.Once, IsAnonymous = false, Charity = charity, User = user }; var charityActionDonation = new CharityActionDonation { Amount = 10m, DateTimeStamp = DateTime.UtcNow.AddHours(-3), DonationType = DonationType.Once, IsAnonymous = false, CharityAction = charityAction }; var getCharityTotalRequest = new GetCharityTotalRequest { CharityKey = charity.CharityKey, From = DateTime.UtcNow.AddDays(-1), To = DateTime.UtcNow, IncludeCharityActions = true, NumberOfDonations = 3, SortOrder = SortOrder.Desc }; using (var context = DonationsContext.GetInMemoryContext()) { var handler = new GetCharityTotalRequestHandler(context, AutoMapperHelper.BuildMapper(new MappingProfile())); response = await handler.Handle(getCharityTotalRequest); } Assert.AreEqual(ErrorType.NoDonationsFound, response.ErrorType); Assert.IsFalse(response.IsSuccess); } finally { DonationsContext.CloseInMemoryConnection(); } }
public async Task GetCharityTotalRequestHandler_Handle_Without_To_And_From_Return_Correct() { DonationsContext.OpenInMemoryConnection(); try { GetCharityTotalResponse response; var user = new User { UserKey = Guid.NewGuid(), ProfileImage = "PrettyImage", UserName = "******" }; var charity = new Charity() { CharityKey = Guid.NewGuid(), Name = "TestName", }; var charityAction = new CharityAction() { ActionEndDateTime = DateTime.UtcNow, Name = "TestName", CharityActionKey = Guid.NewGuid(), Charity = charity }; var charityDonation = new CharityDonation { Amount = 1m, DateTimeStamp = DateTime.UtcNow.AddHours(-1), DonationType = DonationType.Once, IsAnonymous = false, Charity = charity, User = user }; var charityDonation1 = new CharityDonation { Amount = 5m, DateTimeStamp = DateTime.UtcNow.AddHours(-4), DonationType = DonationType.Once, IsAnonymous = false, Charity = charity, User = user }; var charityActionDonation = new CharityActionDonation { Amount = 10m, DateTimeStamp = DateTime.UtcNow.AddHours(-3), DonationType = DonationType.Once, IsAnonymous = false, CharityAction = charityAction }; var getCharityTotalRequest = new GetCharityTotalRequest { CharityKey = charity.CharityKey, IncludeCharityActions = false, NumberOfDonations = 3, SortOrder = SortOrder.Desc }; using (var context = DonationsContext.GetInMemoryContext()) { context.CharityDonations.Add(charityDonation); context.CharityDonations.Add(charityDonation1); context.CharityActionDonations.Add(charityActionDonation); context.SaveChanges(); var handler = new GetCharityTotalRequestHandler(context, AutoMapperHelper.BuildMapper(new MappingProfile())); response = await handler.Handle(getCharityTotalRequest); } Assert.AreEqual(2, response.NumberOfDonators); Assert.IsTrue(response.IsSuccess); Assert.AreEqual(charityDonation.Amount, response.Donations.First().Amount); Assert.AreEqual(charityDonation.DateTimeStamp, response.Donations.First().DateTimeStamp); Assert.AreEqual(charityDonation.User.ProfileImage, response.Donations.First().ProfileImage); Assert.AreEqual(charityDonation.User.UserName, response.Donations.First().UserName); Assert.AreEqual(charityDonation1.Amount, response.Donations.Last().Amount); Assert.AreEqual(charityDonation1.DateTimeStamp, response.Donations.Last().DateTimeStamp); Assert.AreEqual(charityDonation1.User.ProfileImage, response.Donations.Last().ProfileImage); Assert.AreEqual(charityDonation1.User.UserName, response.Donations.Last().UserName); Assert.AreEqual(charityDonation.Amount + charityDonation1.Amount, response.TotalDonatedAmount); } finally { DonationsContext.CloseInMemoryConnection(); } }
public async Task MakeDonationHandler_Handle_Return_CharityActionNotFound() { DonationsContext.OpenInMemoryConnection(); try { MakeDonationResponse response; var user = new User { UserKey = Guid.NewGuid(), ProfileImage = "PrettyImage", UserName = "******" }; var charity = new Charity() { CharityKey = Guid.NewGuid(), Name = "TestName", CoverImage = "TestImage", ThankYou = "ThankYou" }; var charityAction = new CharityAction() { ActionEndDateTime = DateTime.UtcNow, Name = "TestName", CharityActionKey = Guid.NewGuid(), Charity = charity, CoverImage = "TestImage", ThankYou = "ThankYou" }; var makeDonationRequest = new MakeDonationRequest { CharityKey = charity.CharityKey, CharityActionKey = charityAction.CharityActionKey, Amount = 10m, UserKey = user.UserKey, IsAnonymous = false }; using (var context = DonationsContext.GetInMemoryContext()) { context.Charities.Add(charity); context.Users.Add(user); await context.SaveChangesAsync(); var handler = new MakeDonationRequestHandler(context, AutoMapperHelper.BuildMapper(new MappingProfile())); response = await handler.Handle(makeDonationRequest); } using (var context = DonationsContext.GetInMemoryContext()) { Assert.IsFalse(context.CharityDonations.Any()); Assert.IsFalse(context.CharityActionDonations.Any()); Assert.AreEqual(ErrorType.CharityActionNotFound, response.ErrorType); Assert.IsFalse(response.IsSuccess); } } finally { DonationsContext.CloseInMemoryConnection(); } }
public async Task GetCharityActionByUrlRequestHandler_Handle_Returns_CharityAction() { CharityActionContext.OpenInMemoryConnection(); try { //Arrange var keyAction = Guid.NewGuid(); var charityKey = Guid.NewGuid(); var key = Guid.NewGuid(); var user = new UserKey { Key = key }; using (var context = CharityActionContext.GetInMemoryContext()) { var charity = new Charity { CharityKey = charityKey, Url = "some" }; var charityAction = new CharityAction { CharityActionKey = keyAction, UserKeys = new List <UserKey> { user }, Category = Core.Enums.Category.None, IBAN = "", Name = "", Description = "0-IBAN", CoverImage = "", Logo = "test", Charity = charity, UrlComponent = "none" }; context.UserKeys.Add(user); context.CharityActions.Add(charityAction); context.SaveChanges(); } var request = new GetCharityActionByUrlRequest { CharityUrl = "some", CharityActionUrlComponent = "none" }; GetCharityActionByUrlResponse response; //Act using (var context = CharityActionContext.GetInMemoryContext()) { var handler = new GetCharityActionByUrlRequestHandler(context, AutoMapperHelper.BuildMapper(new MappingProfile())); response = await handler.Handle(request); } //Assert using (var context = CharityActionContext.GetInMemoryContext()) { Assert.AreEqual(response.CharityAction.CharityActionKey, context.CharityActions.Single().CharityActionKey); Assert.AreEqual(response.CharityAction.CharityKey, charityKey); CollectionAssert.AreEquivalent(response.CharityAction.UserKeys.Select(k => k.Key).ToList(), context.UserKeys.Select(u => u.Key).ToList()); Assert.AreEqual(response.CharityAction.Category, context.CharityActions.Single().Category); Assert.AreEqual(response.CharityAction.IBAN, context.CharityActions.Single().IBAN); Assert.AreEqual(response.CharityAction.Name, context.CharityActions.Single().Name); Assert.AreEqual(response.CharityAction.Description, context.CharityActions.Single().Description); Assert.AreEqual(response.CharityAction.CoverImage, context.CharityActions.Single().CoverImage); Assert.AreEqual(response.CharityAction.Logo, context.CharityActions.Single().Logo); Assert.IsTrue(response.IsSuccess); } } finally { CharityActionContext.CloseInMemoryConnection(); } }
protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity <Account>(account => { account.Property(e => e.username).IsRequired(); account.Property(e => e.password).IsRequired(); account.Property(e => e.isUser).IsRequired(); }); #region ArrayOfImages Image[] arrayOfImages = new Image[5]; arrayOfImages[0] = new Image { Id = Guid.NewGuid(), Path = "https://i.pinimg.com/originals/df/bd/df/dfbddf7c530ab5f4cd70154409651f9d.jpg" }; arrayOfImages[1] = new Image { Id = Guid.NewGuid(), Path = "http://bestdayevereducation.com/uploads/images/FreeVector-Spongebob-Squarepants-Vector.jpg" }; arrayOfImages[2] = new Image { Id = Guid.NewGuid(), Path = "https://arc-anglerfish-arc2-prod-elcomercio.s3.amazonaws.com/public/AVA6IKPJNBAS7JZ3CREUNY64K4.jpg" }; arrayOfImages[3] = new Image { Id = Guid.NewGuid(), Path = "https://upload.wikimedia.org/wikipedia/commons/thumb/8/80/Cartoon_Network_2010_logo.svg/2000px-Cartoon_Network_2010_logo.svg.png" }; arrayOfImages[4] = new Image { Id = Guid.NewGuid(), Path = "https://cdn.vox-cdn.com/thumbor/m6_h4h6uHuJeZCnWTCz7anTlVJA=/0x0:1920x1080/1200x800/filters:focal(807x387:1113x693)/cdn.vox-cdn.com/uploads/chorus_image/image/60720529/disneyplus.0.4.jpg" }; #endregion #region ArrayOfAccounts Account[] arrayOfAccounts = new Account[5]; using (var sha256 = SHA256.Create()) { // Send a sample text to hash. var pass1 = sha256.ComputeHash(Encoding.UTF8.GetBytes("samplepass1")); var pass2 = sha256.ComputeHash(Encoding.UTF8.GetBytes("samplepass2")); var pass3 = sha256.ComputeHash(Encoding.UTF8.GetBytes("samplepass3")); var pass4 = sha256.ComputeHash(Encoding.UTF8.GetBytes("samplepass4")); var pass5 = sha256.ComputeHash(Encoding.UTF8.GetBytes("samplepass5")); // Get the hashed string. var hash1 = BitConverter.ToString(pass1).Replace("-", "").ToLower(); var hash2 = BitConverter.ToString(pass2).Replace("-", "").ToLower(); var hash3 = BitConverter.ToString(pass3).Replace("-", "").ToLower(); var hash4 = BitConverter.ToString(pass4).Replace("-", "").ToLower(); var hash5 = BitConverter.ToString(pass5).Replace("-", "").ToLower(); // Print the string. // Console.WriteLine(hash); arrayOfAccounts[0] = new Account { Id = Guid.NewGuid(), username = "******", password = hash1, email = "*****@*****.**", isUser = true, imageId = arrayOfImages[0].Id }; arrayOfAccounts[1] = new Account { Id = Guid.NewGuid(), username = "******", password = hash2, email = "*****@*****.**", isUser = true, imageId = arrayOfImages[1].Id }; arrayOfAccounts[2] = new Account { Id = Guid.NewGuid(), username = "******", password = hash3, email = "*****@*****.**", isUser = true, imageId = arrayOfImages[2].Id }; arrayOfAccounts[3] = new Account { Id = Guid.NewGuid(), username = "******", password = hash4, email = "*****@*****.**", isUser = false, imageId = arrayOfImages[3].Id }; arrayOfAccounts[4] = new Account { Id = Guid.NewGuid(), username = "******", password = hash5, email = "*****@*****.**", isUser = false, imageId = arrayOfImages[4].Id }; } #endregion #region ArrayOfCards Card[] arrayOfCreditCard = new Card[5]; arrayOfCreditCard[0] = new Card { Id = Guid.NewGuid(), bankName = "Karntner Sparkasse", dateOfExpiry = new DateTime(2020, 5, 15), amount = 100, creditCardNumber = "1234567891011121" }; arrayOfCreditCard[1] = new Card { Id = Guid.NewGuid(), bankName = "Karntner Sparkasse", dateOfExpiry = new DateTime(2021, 7, 20), amount = 50, creditCardNumber = "3141516171819202" }; arrayOfCreditCard[2] = new Card { Id = Guid.NewGuid(), bankName = "Karntner Ladesbank Raiffeisen", dateOfExpiry = new DateTime(2020, 2, 20), amount = 150, creditCardNumber = "1222324252627282" }; arrayOfCreditCard[3] = new Card { Id = Guid.NewGuid(), bankName = "Austria Bank", dateOfExpiry = new DateTime(2021, 1, 15), amount = 200, creditCardNumber = "9303132333435363" }; arrayOfCreditCard[4] = new Card { Id = Guid.NewGuid(), bankName = "Austria Bank", dateOfExpiry = new DateTime(2020, 3, 14), amount = 55, creditCardNumber = "7383940414243444" }; #endregion #region ArrayOfUsers User[] arrayOfUsers = new User[3]; arrayOfUsers[0] = new User { Id = Guid.NewGuid(), firstName = "Foo", lastName = "Bar", gender = 'M', dateOfBirth = new DateTime(1997, 1, 5), creditCardId = arrayOfCreditCard[0].Id, UserAccount = arrayOfAccounts[0].Id }; arrayOfUsers[1] = new User { Id = Guid.NewGuid(), firstName = "John", lastName = "Doe", gender = 'F', dateOfBirth = new DateTime(1980, 11, 10), creditCardId = arrayOfCreditCard[1].Id, UserAccount = arrayOfAccounts[1].Id }; arrayOfUsers[2] = new User { Id = Guid.NewGuid(), firstName = "Nicholas", lastName = "Cage", gender = 'M', dateOfBirth = new DateTime(1970, 5, 15), creditCardId = arrayOfCreditCard[2].Id, UserAccount = arrayOfAccounts[2].Id }; #endregion #region ArrayOfOrganizations Organization[] arrayOfOrganizations = new Organization[2]; arrayOfOrganizations[0] = new Organization { Id = Guid.NewGuid(), dateOfFounding = new DateTime(2015, 5, 3), name = "CharityOrg1", description = "This is a sample organization for doing something which is good", UserAccount = arrayOfAccounts[3].Id, creditCardNumber = arrayOfCreditCard[3].Id }; arrayOfOrganizations[1] = new Organization { Id = Guid.NewGuid(), dateOfFounding = new DateTime(2019, 10, 10), name = "CharityOrg2", description = "This organization does charity actions which are great!", UserAccount = arrayOfAccounts[4].Id, creditCardNumber = arrayOfCreditCard[4].Id }; #endregion #region ArrayOfActions CharityAction[] arrayOfActions = new CharityAction[3]; arrayOfActions[0] = new CharityAction { Id = Guid.NewGuid(), actionType = false, description = "This is a generic action where you sign up to participate", name = "Race for cure", organizationId = arrayOfOrganizations[0].Id, creationDateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second), startDateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second), endDateTime = new DateTime(2020, 2, 5, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second) }; arrayOfActions[1] = new CharityAction { Id = Guid.NewGuid(), actionType = true, description = "This is a generic action where people donate stuff", name = "Fundraising for children without parents", organizationId = arrayOfOrganizations[0].Id, creationDateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second), startDateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second), endDateTime = new DateTime(2020, 2, 5, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second) }; arrayOfActions[2] = new CharityAction { Id = Guid.NewGuid(), actionType = true, description = "This is another action where people donate stuff", name = "Another fundraising", organizationId = arrayOfOrganizations[1].Id, creationDateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second), startDateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second), endDateTime = new DateTime(2020, 2, 5, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second) }; #endregion #region ArrayOfItems Item[] arrayOfItems = new Item[2]; arrayOfItems[0] = new Item { Id = Guid.NewGuid(), name = "Basketball", description = "A ball for playing basketball", value = 50, userDonatedId = arrayOfUsers[0].Id }; arrayOfItems[1] = new Item { Id = Guid.NewGuid(), name = "Makeup", description = "Some spare makeup I donate", value = 150, userDonatedId = arrayOfUsers[1].Id }; #endregion #region ArrayOfItemInAction ItemInAction[] arrayOfItemsInActions = new ItemInAction[3]; arrayOfItemsInActions[0] = new ItemInAction { Id = Guid.NewGuid(), actionId = arrayOfActions[1].Id, itemId = arrayOfItems[0].Id }; arrayOfItemsInActions[1] = new ItemInAction { Id = Guid.NewGuid(), actionId = arrayOfActions[1].Id, itemId = arrayOfItems[0].Id }; arrayOfItemsInActions[2] = new ItemInAction { Id = Guid.NewGuid(), actionId = arrayOfActions[2].Id, itemId = arrayOfItems[1].Id }; #endregion #region ArrayOfMessages Messages[] arrayOfMessages = new Messages[5]; arrayOfMessages[0] = new Messages { Id = Guid.NewGuid(), sendingTime = new DateTime(2019, 11, 20, 22, 24, 30), message = "May I participate in your action :)", userSenderId = arrayOfUsers[0].Id, organizationReceiverId = arrayOfOrganizations[0].Id }; arrayOfMessages[1] = new Messages { Id = Guid.NewGuid(), sendingTime = new DateTime(2019, 11, 20, 23, 25, 30), message = "Of course you can. All the best.", organizationSenderId = arrayOfOrganizations[0].Id, userReceiverId = arrayOfUsers[0].Id }; arrayOfMessages[2] = new Messages { Id = Guid.NewGuid(), sendingTime = new DateTime(2019, 10, 15, 20, 00, 00), message = "How are you my friend?", userSenderId = arrayOfUsers[1].Id, userReceiverId = arrayOfUsers[2].Id }; arrayOfMessages[3] = new Messages { Id = Guid.NewGuid(), sendingTime = new DateTime(2019, 10, 15, 21, 00, 00), message = "All is well, thank you, and you?", userSenderId = arrayOfUsers[2].Id, userReceiverId = arrayOfUsers[1].Id }; arrayOfMessages[4] = new Messages { Id = Guid.NewGuid(), sendingTime = new DateTime(2019, 10, 15, 22, 00, 00), message = "I am fine, thanks", userSenderId = arrayOfUsers[1].Id, userReceiverId = arrayOfUsers[2].Id }; #endregion #region ArrayOfPayments Payment[] arrayOfPayments = new Payment[3]; arrayOfPayments[0] = new Payment { Id = Guid.NewGuid(), amount = 100, organizationReceiverId = arrayOfOrganizations[0].Id, userSenderId = arrayOfUsers[0].Id }; arrayOfPayments[1] = new Payment { Id = Guid.NewGuid(), amount = 100, organizationReceiverId = arrayOfOrganizations[1].Id, userSenderId = arrayOfUsers[0].Id }; arrayOfPayments[2] = new Payment { Id = Guid.NewGuid(), amount = 100, organizationReceiverId = arrayOfOrganizations[0].Id, userSenderId = arrayOfUsers[1].Id }; #endregion #region ArrayOfProfilePosts ProfilePosts[] arrayOfProfilePosts = new ProfilePosts[3]; arrayOfProfilePosts[0] = new ProfilePosts { Id = Guid.NewGuid(), actionId = arrayOfActions[0].Id, userId = arrayOfUsers[0].Id, message = "I just did something in this action" }; arrayOfProfilePosts[1] = new ProfilePosts { Id = Guid.NewGuid(), actionId = arrayOfActions[1].Id, userId = arrayOfUsers[1].Id, message = "I did something too" }; arrayOfProfilePosts[2] = new ProfilePosts { Id = Guid.NewGuid(), actionId = arrayOfActions[2].Id, userId = arrayOfUsers[2].Id, message = "Normally, I did as well." }; #endregion #region ArrayOfReactionsToPosts ReactionsToPosts[] arrayOfReactionsToPosts = new ReactionsToPosts[3]; arrayOfReactionsToPosts[0] = new ReactionsToPosts { Id = Guid.NewGuid(), postId = arrayOfProfilePosts[0].Id, liked = true, commented = false, userReactedId = arrayOfUsers[2].Id }; arrayOfReactionsToPosts[1] = new ReactionsToPosts { Id = Guid.NewGuid(), postId = arrayOfProfilePosts[1].Id, liked = true, commented = true, userReactedId = arrayOfUsers[0].Id, commentText = "Glad you did that!" }; arrayOfReactionsToPosts[2] = new ReactionsToPosts { Id = Guid.NewGuid(), postId = arrayOfProfilePosts[2].Id, liked = true, commented = false, userReactedId = arrayOfUsers[1].Id }; #endregion #region ArrayOfUserParticipatingInAction UserParticipatingInAction[] arrayOfUsersParticipating = new UserParticipatingInAction[3]; arrayOfUsersParticipating[0] = new UserParticipatingInAction { Id = Guid.NewGuid(), actionId = arrayOfActions[0].Id, userId = arrayOfUsers[0].Id }; arrayOfUsersParticipating[1] = new UserParticipatingInAction { Id = Guid.NewGuid(), actionId = arrayOfActions[1].Id, userId = arrayOfUsers[1].Id }; arrayOfUsersParticipating[2] = new UserParticipatingInAction { Id = Guid.NewGuid(), actionId = arrayOfActions[2].Id, userId = arrayOfUsers[2].Id }; #endregion #region ImageSeed modelBuilder.Entity <Image>().HasData(arrayOfImages[0]); modelBuilder.Entity <Image>().HasData(arrayOfImages[1]); modelBuilder.Entity <Image>().HasData(arrayOfImages[2]); modelBuilder.Entity <Image>().HasData(arrayOfImages[3]); modelBuilder.Entity <Image>().HasData(arrayOfImages[4]); #endregion #region AccountSeed modelBuilder.Entity <Account>().HasData(arrayOfAccounts[0]); modelBuilder.Entity <Account>().HasData(arrayOfAccounts[1]); modelBuilder.Entity <Account>().HasData(arrayOfAccounts[2]); modelBuilder.Entity <Account>().HasData(arrayOfAccounts[3]); modelBuilder.Entity <Account>().HasData(arrayOfAccounts[4]); #endregion #region CardSeed modelBuilder.Entity <Card>().HasData(arrayOfCreditCard[0]); modelBuilder.Entity <Card>().HasData(arrayOfCreditCard[1]); modelBuilder.Entity <Card>().HasData(arrayOfCreditCard[2]); modelBuilder.Entity <Card>().HasData(arrayOfCreditCard[3]); modelBuilder.Entity <Card>().HasData(arrayOfCreditCard[4]); #endregion #region UserSeed modelBuilder.Entity <User>().HasData(arrayOfUsers[0]); modelBuilder.Entity <User>().HasData(arrayOfUsers[1]); modelBuilder.Entity <User>().HasData(arrayOfUsers[2]); #endregion #region OrganizationSeed modelBuilder.Entity <Organization>().HasData(arrayOfOrganizations[0]); modelBuilder.Entity <Organization>().HasData(arrayOfOrganizations[1]); #endregion #region ActionSeed modelBuilder.Entity <CharityAction>().HasData(arrayOfActions[0]); modelBuilder.Entity <CharityAction>().HasData(arrayOfActions[1]); modelBuilder.Entity <CharityAction>().HasData(arrayOfActions[2]); #endregion #region ItemSeed modelBuilder.Entity <Item>().HasData(arrayOfItems[0]); modelBuilder.Entity <Item>().HasData(arrayOfItems[1]); #endregion #region ItemInActionSeed modelBuilder.Entity <ItemInAction>().HasData(arrayOfItemsInActions[0]); modelBuilder.Entity <ItemInAction>().HasData(arrayOfItemsInActions[1]); modelBuilder.Entity <ItemInAction>().HasData(arrayOfItemsInActions[2]); #endregion #region MessagesSeed modelBuilder.Entity <Messages>().HasData(arrayOfMessages[0]); modelBuilder.Entity <Messages>().HasData(arrayOfMessages[1]); modelBuilder.Entity <Messages>().HasData(arrayOfMessages[2]); modelBuilder.Entity <Messages>().HasData(arrayOfMessages[3]); modelBuilder.Entity <Messages>().HasData(arrayOfMessages[4]); #endregion #region PaymentSeed modelBuilder.Entity <Payment>().HasData(arrayOfPayments[0]); modelBuilder.Entity <Payment>().HasData(arrayOfPayments[1]); modelBuilder.Entity <Payment>().HasData(arrayOfPayments[2]); #endregion #region ProfilePostsSeed modelBuilder.Entity <ProfilePosts>().HasData(arrayOfProfilePosts[0]); modelBuilder.Entity <ProfilePosts>().HasData(arrayOfProfilePosts[1]); modelBuilder.Entity <ProfilePosts>().HasData(arrayOfProfilePosts[2]); #endregion #region ReactionsToPostsSeed modelBuilder.Entity <ReactionsToPosts>().HasData(arrayOfReactionsToPosts[0]); modelBuilder.Entity <ReactionsToPosts>().HasData(arrayOfReactionsToPosts[1]); modelBuilder.Entity <ReactionsToPosts>().HasData(arrayOfReactionsToPosts[2]); #endregion #region UserParticipatingInActionSeed modelBuilder.Entity <UserParticipatingInAction>().HasData(arrayOfUsersParticipating[0]); modelBuilder.Entity <UserParticipatingInAction>().HasData(arrayOfUsersParticipating[1]); modelBuilder.Entity <UserParticipatingInAction>().HasData(arrayOfUsersParticipating[2]); #endregion }