コード例 #1
0
        // GET: api/Contact/5
        public HttpResponseMessage Get(int id)
        {
            var contact = _contactServices.GetById(id);

            return(contact != null
                ? Request.CreateResponse(HttpStatusCode.OK, contact)
                : Request.CreateErrorResponse(HttpStatusCode.NotFound, "No Contact found for this id"));
        }
コード例 #2
0
        // GET: Admin/Contacts/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Contact contact = _contact.GetById(id);

            if (contact == null)
            {
                return(HttpNotFound());
            }
            return(View(contact));
        }