public ActionResult Create(CreateViewModel model) { if (ModelState.IsValid) { var ev = InstanceEventFactory.CreateEvent(Guid.NewGuid(), model.Name, model.JoinCode, model.StartDate, model.EndDate, this.GetAudit()); using (var db = Context.Create()) { db.StoredEvents.Add(StoredEvent.FromEvent(ev)); EventProcessor.Process(db, ev); db.SaveChanges(); return(RedirectToAction("Details", new { instanceId = ev.InstanceId.Value })); } } return(View(model)); }
public ActionResult Join(Guid instanceId, JoinViewModel model) { if (ModelState.IsValid) { var ev = InstanceEventFactory.JoinEvent(instanceId, this.GetAudit()); using (var db = Context.Create()) { var ins = db.Instances.Find(instanceId); if (ins.JoinCode.Trim() != model.JoinCode.Trim()) { ModelState.AddModelError("JoinCode", "The JoinCode was not correct"); return(View(model)); } db.StoredEvents.Add(StoredEvent.FromEvent(ev)); EventProcessor.Process(db, ev); db.SaveChanges(); return(RedirectToAction("Details", new { instanceId = ev.InstanceId.Value })); } } return(View(model)); }