Exemplo n.º 1
0
        private void TestDB()
        {
            IDataStore ds = StateManager.Instance.DataStore;

            if (ds.GetCategory(1) == null)
            {
                Category cat = ds.AddCategory("Movies");

                Tag t1 = ds.AddTag(cat.ID, "Prime");
                Tag t2 = ds.AddTag(cat.ID, "Watched");

                Item item = new Item(cat, "Test Show");

                item.Tags = new List <Tag>()
                {
                    t1, t2
                };
                ds.UpsertItem(item);

                Item item2 = new Item(cat, "Test2");

                item2.Tags = new List <Tag>();
                item2.Tags.Add(ds.GetTag(1));
                ds.UpsertItem(item2);
            }

            var items = ds.GetItemsForTag(1);

            string s = "";
        }
        //insert categoryObj
        public HttpResponseMessage Post(Category categoryObj)
        {
            if (ModelState.IsValid)
            {
                dataStore.AddCategory(categoryObj);

                HttpResponseMessage response = Request.CreateResponse(
                    HttpStatusCode.Created, categoryObj);
                response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = categoryObj.Id }));
                return(response);
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }
        }