{"id":23119753,"url":"https://github.com/alisabzevari/liteapi","last_synced_at":"2025-04-04T02:41:51.931Z","repository":{"id":33015897,"uuid":"36649834","full_name":"alisabzevari/LiteApi","owner":"alisabzevari","description":"ASP.NET WebAPI Controller to easily write Restfulish message based Api Controllers","archived":false,"fork":false,"pushed_at":"2015-06-09T06:34:30.000Z","size":220,"stargazers_count":5,"open_issues_count":8,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-09T14:25:09.875Z","etag":null,"topics":["aspnet-web-api"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alisabzevari.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-01T09:07:55.000Z","updated_at":"2019-08-26T12:26:02.000Z","dependencies_parsed_at":"2022-07-12T22:20:33.423Z","dependency_job_id":null,"html_url":"https://github.com/alisabzevari/LiteApi","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alisabzevari%2FLiteApi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alisabzevari%2FLiteApi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alisabzevari%2FLiteApi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alisabzevari%2FLiteApi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alisabzevari","download_url":"https://codeload.github.com/alisabzevari/LiteApi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247112715,"owners_count":20885605,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aspnet-web-api"],"created_at":"2024-12-17T05:41:02.415Z","updated_at":"2025-04-04T02:41:51.913Z","avatar_url":"https://github.com/alisabzevari.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LiteApi\nLiteApi is an ApiController that simplifies creating RESTfulish apis. It helps service designer to use ASP.NET WebApi for writing message based services. It inspired by ServiceStack's AutoQuery.\n\n**Caution:** This project is in early stages of development.\n\n## How to use\nTo use LiteApi, you must define 3 types and then inherit your controller from `LiteApiController`. These types are:\n\n1. Dto\n2. Entity\n3. QueryDescriptor\n\nAll of these types can be simple classes and no need to inherit them from specific classes. LiteApiController maps Entity to Dto with `AutoMapper`. Users of controller see Dto but LiteApiController works with entity when it needs to work with persistence layer.\n\nQueryDescriptor defines how users of controller can query collection of entity. \n\n###Example:\n\nSuppose that your entity is:\n```csharp\npublic class Person\n    {\n        public int Id { get; set; }\n        public string FirstName { get; set; }\n        public string LastName { get; set; }\n        public bool IsAdmin { get; set; }\n}\n```\n\nAnd your Dto is:\n```csharp\npublic class PersonDto\n    {\n        public int Id { get; set; }\n        public string FirstName { get; set; }\n        public string LastName { get; set; }\n    }\n```\n\nAnd your QueryDesriptor is:\n```csharp\npublic class PersonDtoQueryDescriptor\n    {\n        public string FirstName { get; set; }\n        public int? Id_Gt { get; set; }\n        public int? Id_Ge { get; set; }\n        public int? Id_Lt { get; set; }\n        public int? Id_Le { get; set; }\n        public int? Id_Ne { get; set; }\n        public string[] OrderBy { get; set; }\n        public string[] OrderByDesc { get; set; }\n        public int? Take { get; set; }\n        public int? Skip { get; set; }\n    }\n```\n\nYou just need to define your ApiController as:\n```csharp\npublic class PersonController : LiteApiController\u003cint, PersonDto, Person, PersonDtoQueryDescriptor\u003e\n    {\n        public PersonController()\n            : base(new InMemoryCollectionPersistenceService\u003cPerson\u003e(Person.Seed()))\n        { }\n        public PersonController(IPersistenceService collection)\n            : base(collection)\n        { }\n    }\n```\n**Note:** `InMemoryCollectionPersistenceService\u003cPerson\u003e` is an implementation of `IPersistenceService` that connects your api to your DAO class. You can write your own IPersistenceService. There is an implementation for `ICollection\u003cT\u003e` and NHibernate PersistenceService implemented out of the box.\n\nAfter that you can work with your api:\n\nRequest | Meaning\n--------|--------\n`GET http://localhost/api/Person/1` | Get Person with Id = 1\n`GET http://localhost/api/Person?Take=10\u0026Skip=2` | Get 2nd 10 Persons\n`GET http://localhost/api/Person?Id_Gt=3` | Get Persons with Id Greater Than 3\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falisabzevari%2Fliteapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falisabzevari%2Fliteapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falisabzevari%2Fliteapi/lists"}