Esempio n. 1
0
        // Update an existing category
        // PUT /api/category
        public HttpResponseMessage Put(Category category)
        {
            category.User = new User { Id = CurrentUserId };
            Uow.Categories.Update(category);
            Uow.Commit();

            return new HttpResponseMessage(HttpStatusCode.NoContent);
        }
Esempio n. 2
0
        // Create a new Category
        // POST /api/category
        public HttpResponseMessage Post(Category category)
        {
            category.User = new User { Id = CurrentUserId };
            Uow.Categories.Add(category);
            Uow.Commit();

            var response = Request.CreateResponse(HttpStatusCode.Created, category);

            // Compose location header that tells how to get this session
            // e.g. ~/api/category/3
            response.Headers.Location =
                new Uri(Url.Link(RouteConfig.ControllerAndId, new { id = category.Id }));

            return response;
        }