public async Task <IActionResult> Edit(int id, [Bind("ID,RoomNumber,Children,Adults,Date")] RoomCheckedIn roomCheckedIn) { if (id != roomCheckedIn.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(roomCheckedIn); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RoomCheckedInExists(roomCheckedIn.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(roomCheckedIn)); }
public async Task PersistAndReadEvents() { var domainEvent1 = new RoomCheckedAsOk(new RoomId("whatever")); var horodateEvent1 = Horodate; await CreateEventStore(horodateEvent1).Append(domainEvent1); var domainEvent2 = new RoomDamageReported(new RoomId("dude"), "drawings on walls"); var horodateEvent2 = Horodate.AddSeconds(1); await CreateEventStore(horodateEvent2).Append(domainEvent2); var domainEvent3 = new RoomCheckedAsOk(new RoomId("dady cool")); var horodateEvent3 = Horodate.AddSeconds(-1); await CreateEventStore(horodateEvent3).Append(domainEvent3); var domainEvent4 = new GuestCheckedOut(new RoomId("anyway")); var horodateEvent4 = Horodate.AddSeconds(-2); await CreateEventStore(horodateEvent4).Append(domainEvent4); var domainEvent5 = new RoomCheckedIn(new RoomId("anyway")); await CreateEventStore(Horodate.AddSeconds(5)).Append(domainEvent5); var domainEvent6 = new RoomCheckedIn(new RoomId("anyway")); await CreateEventStore(Horodate.AddSeconds(6)).Append(domainEvent6); var history = await CreateEventStore().GetAggregateHistory(); Check.That(history).ContainsExactly(domainEvent4, domainEvent3, domainEvent1, domainEvent2, domainEvent5, domainEvent6); }
public async Task <IActionResult> Create([Bind("RoomNumber,Date,Children,Adults")] RoomCheckedIn roomCheckedIn) { roomCheckedIn.Date = DateTime.Today; _context.Add(roomCheckedIn); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); //return View(roomCheckedIn); }
public async Task <IActionResult> Create([Bind("ID,RoomNumber,Children,Adults,Date")] RoomCheckedIn roomCheckedIn) { if (ModelState.IsValid) { _context.Add(roomCheckedIn); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(roomCheckedIn)); }