internal FluentEngineSubContext(ApiItemModel <TItem> itemModel) { Identifiers = new FluentIdentifierProvider <TItem>(itemModel.Identifiers); Fields = new FluentFieldProvider <TItem>(itemModel.Fields); AuthorizationChecker = new AllowAllAuthorizationChecker <TItem>(); // TODO }
public HttpResponseMessage Delete(ApiItemModel item) { if (_itemManager.Delete(item)) { return(new HttpResponseMessage(HttpStatusCode.OK)); } return(new HttpResponseMessage(HttpStatusCode.BadRequest)); }
public HttpResponseMessage Post(ApiItemModel item) { if (_itemManager.Record(item)) { return(new HttpResponseMessage(HttpStatusCode.OK)); } return(new HttpResponseMessage(HttpStatusCode.BadRequest)); }
public ItemModel MapItemApiModel(ApiItemModel item) { return(new ItemModel() { ID = item.ID, Name = item.Name, Brand = item.Brand, PolicyCoverageDetailID = item.PolicyCoverageDetailID, Value = item.Value }); }
private ApiItemModel <TItem> CreateNewItemModel <TItem>() where TItem : class, new() { var itemModel = new ApiItemModel <TItem>(Model.DataSource); Model.Items.Add(itemModel); Model.Roots.Add(itemModel); itemModel.RootName = PluralConventionUtility.Pluralize(typeof(TItem).Name); return(itemModel); }
public ApiItemModel Get(ApiItemModel item) { // ApiItemModel item = new ApiItemModel // { // ID = (int)ID, // Brand = "Honda", // Name = "Civic", // Value = 11500, // PolicyCoverageDetailID = 001 // }; // return item; return(_itemManager.Find <ApiItemModel>(e => e.ID == item.ID)); }
public ApiItemModel Search(int id) { IItemManager ItemManager = UnityResolver.Resolve <IItemManager>(); Item item = ItemManager.SerchItem(id); ApiItemModel aitem = new ApiItemModel { Id = item.Id, ResourceType = item.ResourceType, ResourceDescription = item.ResourceDescription, AdditionalInfo = item.AdditionalInfo }; return(aitem); }
public void ApiCacheServiceRetrieveByTypeRetrievesItem() { //Arrange var serviceToTest = BuildApiCacheService(); var itemToCache = new ApiItemModel() { Description = "a test item" }; //Act serviceToTest.AddOrUpdate(new Uri("http://somewhere.com/aresource"), itemToCache); var result = serviceToTest.Retrieve <ApiItemModel>(itemToCache.GetType(), new Uri("http://somewhere.com/aresource")); //Assert Assert.Equal(1, serviceToTest.Count); Assert.Equal(itemToCache.Description, result !.Description); }
public void ApiCacheServiceRetrieveRetrievesItem() { //Arrange var serviceToTest = BuildApiCacheService(); var itemToCache = new ApiItemModel() { Description = "a test item" }; //Act serviceToTest.AddOrUpdate(new Uri("http://somewhere.com/aresource").ToString(), itemToCache); var result = serviceToTest.Retrieve <ApiItemModel>(new Uri("http://somewhere.com/aresource").ToString()); //Assert Assert.Equal(0, serviceToTest.Count); Assert.Null(result); }
public IApiItemBuilder <TNavItem> IsItem <TNavItem>() where TNavItem : class, TField, new() { var itemModel = new ApiItemModel <TNavItem>(null); // can be null because GetRootCollection never called for navigation properties IEngineSubContext <TNavItem> subContext = new FluentEngineSubContext <TNavItem>(itemModel); var castedExpression = _expression as Expression <Func <TItem, TNavItem> >; // should cast fine due to generic constraint var navTools = new SubWriterTools <TItem, TNavItem, TNavItem>(castedExpression, itemModel.Events, _setter); _fieldModel.Reader = new SubItemFieldReader <TItem, TNavItem>(castedExpression, subContext); _fieldModel.Collator = new NotSupportedFieldCollator <TItem>("sub items"); _fieldModel.ResourceGetter = new SubItemResourceGetter <TItem, TNavItem>(navTools, subContext); _fieldModel.Writer = new SubItemFieldWriter <TItem, TNavItem>(navTools, subContext); var itemBuilder = new EngineItemBuilder <TNavItem>(itemModel); return(itemBuilder); }
public bool update(ApiItemModel item) { return(true); }
public bool Add(ApiItemModel item) { return(true); }
internal EngineItemBuilder(ApiItemModel <TItem> model) { _model = model; }
public RestCollectionSource(IDataSource dataSource, ApiItemModel <TItem> itemModel) { _dataSource = dataSource; _events = itemModel.Events; _subContext = new FluentEngineSubContext <TItem>(itemModel); }