👷♂️
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static void RegisterRoutes(RouteCollection routes) { | |
| var config = GlobalConfiguration.Configuration; | |
| config.Filters.Add(new RavenActionFilterAttribute()); | |
| routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); | |
| config.Routes.MapHttpRoute( | |
| name: "API Default", | |
| routeTemplate: "api/{controller}/{id}", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class UnitsController : RavenController { | |
| public List<Unit> Get() { | |
| return this.Session.Query<Unit>().ToList(); | |
| } | |
| public HttpResponseMessage<Unit> Post(Unit unit) { | |
| if(null != unit) { | |
| Session.Store(unit); | |
| return new HttpResponseMessage<Unit>(unit, HttpStatusCode.OK); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protected void Application_Start() { | |
| initializeDocumentStore(); | |
| AreaRegistration.RegisterAllAreas(); | |
| RegisterGlobalFilters(GlobalFilters.Filters); | |
| RegisterRoutes(RouteTable.Routes); | |
| BundleTable.Bundles.RegisterTemplateBundles(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public abstract class RavenApiController : ApiController { | |
| public static IDocumentStore DocumentStore { get; set; } | |
| public IDocumentSession Session { get; set; } | |
| public override Task<System.Net.Http.HttpResponseMessage> ExecuteAsync(HttpControllerContext controllerContext, CancellationToken cancellationToken) { | |
| Session = (IDocumentSession)HttpContext.Current.Items["CurrentRequestRavenSession"]; | |
| return base.ExecuteAsync(controllerContext, cancellationToken); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class UnitsController : RavenApiController { | |
| public List<Unit> Get() { | |
| return this.Session.Query<Unit>().ToList(); | |
| } | |
| public HttpResponseMessage<Unit> Post(Unit unit) { | |
| if(null != unit) { | |
| Session.Store(unit); | |
| return new HttpResponseMessage<Unit>(unit, HttpStatusCode.OK); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| routes.MapHttpRoute("contacts", "api/contacts/{id}", new { controller = "Contacts", id = RouteParameter.Optional }); | |
| routes.MapHttpRoute("addresses", "api/contacts/{contactId}/addresses/{addressId}", new { controller = "Addresses", addressId = RouteParameter.Optional}); | |
| public class AddressesController : ApiController { | |
| public List<Address> Get(int contactId) { | |
| return new List<Address>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class LowercaseContractResolver : DefaultContractResolver { | |
| protected override string ResolvePropertyName(string propertyName) { | |
| return propertyName.ToLower(); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var config = GlobalConfiguration.Configuration; | |
| var settings = new JsonSerializerSettings(); | |
| settings.ContractResolver = new LowercaseContractResolver(); | |
| config.Formatters.JsonFormatter.SerializerSettings = settings; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var config = GlobalConfiguration.Configuration; | |
| var settings = new JsonSerializerSettings(); | |
| settings.ContractResolver = new LowercaseContractResolver(); | |
| config.Formatters.Remove(config.Formatters.JsonFormatter); | |
| config.Formatters.Add(new JsonNetFormatter(settings)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <input type="text" size="16" class="span1"><button type="button" class="btn"><i class="icon-plus-sign"></i> </button> | |
| is wrong and will look like this | |
| http://img37.imageshack.us/img37/88/capturedcran20120201221.png | |
| (also read this: https://github.com/twitter/bootstrap/issues/1543) | |
| Do this instead: | |
| <form class="form-inline"> | |
| <div class="control-group"> | |
| <div class="controls"> |