public RedirectToRouteResult Create(WidgetDetails model)
        {
            if (!ModelState.IsValid)
                return this.RedirectToAction(c => c.Create());

            var id = _dao.Create(model);

            return this.RedirectToAction(c => c.Index(id));
        }
        private void CreateWidget(WidgetDetails widget)
        {
            NavigateTo("/widgets/create");
            var form = new MvcFormHelper<WidgetDetails>(Browser);
            form.Set(m => m.Name, widget.Name);
            form.Set(m => m.Size, widget.Size);
            form.Submit(m => m.Name);

            //var errors = Browser.FindElements(By.ClassName("error"));
            //if (errors != null &&  errors.Any())
            //{
            //    Console.WriteLine("Widget creation failed with error(s):");
            //    errors.ToList().ForEach(e => Console.WriteLine(e.Text));
            //    return;
            //}

            var match = new Regex(@"^widgets/(?<id>\d+)$").Match(RelativeUrl().ToString());
            if (match.Success)
            {
                widget.Id = Convert.ToInt32(match.Groups["id"].Value);
                _widgets.Add(widget);
                Console.WriteLine("Widget {0} created", widget.Id);
            } else
            {
                Console.WriteLine("Widget creation failed.");
            }
        }
 public int Create(WidgetDetails newWidget)
 {
     _session.Store(newWidget);
     return newWidget.Id;
 }