Example #1
0
        //Update an existing entry
        //PUT /api/entry/1
        public HttpResponseMessage Put(Entry entry)
        {
            Uow.Entries.Update(entry);
            Uow.Commit();

            return new HttpResponseMessage(HttpStatusCode.NoContent);
        }
Example #2
0
        //Create new Entry
        //POST /api/entry
        public HttpResponseMessage Post(Entry entry)
        {
            entry.User = new User { Id = CurrentUserId };
            entry.CreateDate = DateTime.Now;
            Uow.Entries.Add(entry);
            Uow.Commit();

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

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

            return response;
        }