Ejemplo n.º 1
0
        public HttpResponseMessage FecthPhoneById(string id)
        {
            var item = repository.Get(id);

            if (item == null)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound,
                                                   string.Format("Phone with id = {0} not found.", id)));
            }
            return(Request.CreateResponse(HttpStatusCode.OK, item));
        }
        //GET: api/Phones/samsung-gem
        public IHttpActionResult Get(string id)
        {
            var item = repository.Get(id);

            if (item == null)
            {
                //var err = new HttpError(string.Format("Phone with id = {0} not found.", id));
                return(NotFound());
            }
            else
            {
                return(Ok(item));
            }
        }