Exemple #1
0
        public SearchModule(IProvider provider)
        {
            _values = provider.GetAll();

            Get["/Search/{name?}"] = parameters =>
                                     Negotiate
                                     .WithView("Search")
                                     .WithModel((string)parameters.name);


            Get["/GetByName/{name}/{resultType?}"]
                = Get["/GetByName/{name?}/"] = parameters =>
                                               Negotiate
                                               .AsResponseType((string)parameters.resultType ?? ResponseType.JSON)
                                               .WithModel(_values.Search((string)parameters.name).ToArray());


            Post["/AddModelData/{name}/{lastname}/{cedula}"]
                  = Get["/AddModelData/{name}/{lastname}/{cedula}"]
                  = parameters =>
                    Negotiate
                    .WithModel(provider.Add(this.Bind <Model>()))
                    .AsJSON();
        }