public async Task Should_Create_Event() { //Arrange var eventTitle = Guid.NewGuid().ToString(); //Act await _eventAppService.Create(new CreateEventInput { Title = eventTitle, Description = "A description", Date = Clock.Now.AddDays(2) }); //Assert UsingDbContext(context => { context.Events.FirstOrDefault(e => e.Title == eventTitle).ShouldNotBe(null); }); }
public async Task <ActionResult> Register(EventDto model)//string eventType, DateTime? startDay, DateTime? endDate) { if (!User.Identity.IsAuthenticated) { ModelState.AddModelError("", "You are not authenticated, so cannot create event"); return(View()); } //Add event and current user as participant bool eventCreated = await _eventService.Create(model, User.Identity.Name);//RegisterUser(model, User); //add to DB if (eventCreated) { return(RedirectToAction("Calendar", "Home")); //return RedirectToAction("CalendarUpdate", new {@updatedEventData = model }); } ModelState.AddModelError("", "Error in creating event"); return(View("ErrorEventCreate"));// sweetalert }