public static List <NerdDinner.Entities.Dinners> CreateTestDinners() { List <NerdDinner.Entities.Dinners> dinners = new List <NerdDinner.Entities.Dinners>(); for (int i = 0; i < 101; i++) { NerdDinner.Entities.Dinners sampleDinner = new NerdDinner.Entities.Dinners() { DinnerID = i, Title = "Sample Dinner", HostedBy = "SomeUser", Address = "Some Address", Country = "USA", ContactPhone = "425-555-1212", Description = "Some description", EventDate = DateTime.Now.AddDays(i), Latitude = 99, Longitude = -99 }; IList <NerdDinner.Entities.RSVP> rsvps = new List <NerdDinner.Entities.RSVP>(); rsvps.Add(new NerdDinner.Entities.RSVP() { AttendeeName = "SomeUser" }); rsvps[0].dinner = sampleDinner; sampleDinner.RSVPs = rsvps; dinners.Add(sampleDinner); } return(dinners); }
public void Save(NerdDinner.Entities.Dinners dinner) { foreach (NerdDinner.Entities.Dinners d in dinnerList) { if (!d.IsValid) { throw new ApplicationException("Rule violations"); } } }
public void CreateAction_Should_Fail_Give_Empty_Dinner() { // Arrange var controller = CreateDinnersControllerAs("scottgu"); NerdDinner.Entities.Dinners dinner = new NerdDinner.Entities.Dinners(); // Act ViewResult result = (ViewResult)controller.Create(dinner); // Assert Assert.IsInstanceOfType(result, typeof(ViewResult)); Assert.IsTrue(result.ViewData.ModelState.IsValid == false); Assert.AreEqual(6, result.ViewData.ModelState.Sum(p => p.Value.Errors.Count), "Expected Errors"); }
public static NerdDinner.Entities.Dinners CreateDinner() { NerdDinner.Entities.Dinners dinner = new NerdDinner.Entities.Dinners(); dinner.Title = "New Test Dinner"; dinner.EventDate = DateTime.Now.AddDays(7); dinner.Address = "5 Main Street"; dinner.Description = "Desc"; dinner.ContactPhone = "503-555-1212"; dinner.HostedBy = "scottgu"; dinner.Latitude = 45; dinner.Longitude = 45; dinner.Country = "USA"; return(dinner); }
public ActionResult Register(int id) { NerdDinner.Entities.Dinners dinner = dinnerRepository.GetDinner(id); if (!dinner.IsUserRegistered(User.Identity.Name)) { NerdDinner.Entities.RSVP rsvp = new NerdDinner.Entities.RSVP(); rsvp.dinner = dinner; rsvp.AttendeeName = User.Identity.Name; dinner.RSVPs.Add(rsvp); dinnerRepository.Save(dinner); } return(Content("Thanks - we'll see you there!")); }
public void Delete(NerdDinner.Entities.Dinners dinner) { dinnerList.Remove(dinner); }
public void Add(NerdDinner.Entities.Dinners dinner) { dinnerList.Add(dinner); }