private static void InitCharityEvents(CharityHubContext context) { if (context.CharityEvents.Any()) { return; } var charityAdam = context.Charities.First(x => x.Name == "Caritas"); var charityRychu = context.Charities.First(x => x.Name == "Panda"); var charityEvents = new CharityEvent[] { new CharityEvent() { Name = "Zbieranie jedzenia dla biednych rodziny w Warszawie", Charity = charityAdam, CreatedDate = new DateTime(2017, 11, 18), StartDate = new DateTime(2017, 11, 19), EndDate = new DateTime(2017, 11, 21), Description = "W Warszawie jest wiele ubogich rodzin u których nie starcza pieniędzy na jedzenie." + "Możemy im pomóc. Zapraszamy", EventCategory = EventCategory.HomelessHelp, }, new CharityEvent() { Name = "Zbieranie jedznia dla noclegowni", Charity = charityAdam, CreatedDate = new DateTime(2017, 11, 18), StartDate = new DateTime(2017, 11, 22), EndDate = new DateTime(2017, 11, 24), Description = "Noclegownia z Ursynowa ma ograniczony budżet. Jakość posiłków nie jeset tam najlepsza. Zbieramy podstawowe produkty takie jak mąka, cukier itp.", EventCategory = EventCategory.HomelessHelp, }, new CharityEvent() { Name = "Dzieci w domu dziecka potrzebują remontu łazienki", Charity = charityRychu, CreatedDate = new DateTime(2017, 11, 18), StartDate = new DateTime(2017, 11, 19), EndDate = new DateTime(2017, 11, 21), Description = "Dzieci w domu dziecka potrzebują remontu łazienki. Na remont potrzebne jest oko. 10.000zł. Jeżeli dużo osób pomoże to się uda :)", EventCategory = EventCategory.HospitalHelp, } }; foreach (var s in charityEvents) { context.CharityEvents.Add(s); } context.SaveChanges(); }
private CharityEvent ToCharityEvent() { if (!CharityIdentifier.HasValue) { throw new Exception($"Charity does not contain a value for {nameof(CharityIdentifier)}"); } var charityEvent = new CharityEvent { CharityIdentifier = CharityIdentifier.Value, CharityName = CharityName, ContactNumber = ContactNumber, ContactPerson = ContactPerson, EmailAddress = EmailAddress }; return(charityEvent); }