Beispiel #1
0
        public IHttpActionResult Get()
        {
            //TODO: Need to remove it when we add authentication feature
            var results = _orderService.GetOpenOrders("testuser")
                          .ToList()
                          .Select(o => TheModelFactory.CreateOrderModel(Url, "Orders", o));

            return(Ok(results));
        }
Beispiel #2
0
        public IHttpActionResult BorrowBook(int bookId)
        {
            //TODO: Need to remove it when we add authentication feature
            Order order = _orderService.BorrowBook(bookId, "testuser");

            _unitOfWork.Commit();

            var result = TheModelFactory.CreateOrderModel(Url, "Orders", order);

            string location = string.Empty;

            foreach (var link in result.Links)
            {
                if (link.Rel.Equals(RelConstant.SELF))
                {
                    location = link.Href;
                }
            }

            return(Created(location, result));
        }