Ejemplo n.º 1
0
        public IHttpActionResult GetUser([FromUri] int id)
        {
            Exception     ex   = null;
            UserViewModel user = null;

            try {
                var requestUri = Request.RequestUri;
                user = new UserViewModel(_dataConnector.GetUser(id));

                user.AddLink(new Link(requestUri, HttpMethod.Get, RelValues.Self, ActionValues.Refresh, "auth/user/" + user.UserId));
                user.AddLink(new Link(requestUri, HttpMethod.Put, RelValues.Self, ActionValues.Update, "auth/user/" + user.UserId));
                user.AddLink(new Link(requestUri, HttpMethod.Delete, RelValues.Self, ActionValues.Delete, "auth/user/" + user.UserId));
            } catch (Exception e) {
                ex = e;
            }

            return(GetHttpActionResult(user, ex));
        }
Ejemplo n.º 2
0
        public IHttpActionResult GetUser([FromUri] int id)
        {
            Exception     ex     = null;
            UserViewModel result = null;

            try {
                var user = _dataProvider.GetEntity <User>(id);
                result = new UserViewModel(user);

                result.AddLink(new Link(Request.RequestUri, HttpMethod.Get, RelValues.Self, ActionValues.Refresh, "Users/" + id));
                result.AddLink(new Link(Request.RequestUri, HttpMethod.Put, RelValues.Self, ActionValues.Save, "Users/" + id));
                result.AddLink(new Link(Request.RequestUri, HttpMethod.Delete, RelValues.Self, ActionValues.Delete, "Users/" + id));
            } catch (Exception e) {
                ex = e;
            }

            return(GetHttpActionResult(result, ex));
        }