public HttpResponseMessage Post(int personId, PersonUrlApiModel model)
        {
            if (model == null)
                return Request.CreateResponse(HttpStatusCode.BadRequest, "Please set Content-Type header to application/x-www-form-urlencoded.");

            var command = new CreateExternalUrl(User, personId)
            {
                Description = model.Description,
                Value = model.Value,
            };
            var validation = _validation.Validate(command);
            if (!validation.IsValid)
            {
                var firstMessage = validation.Errors.Select(x => x.ErrorMessage).First();
                return Request.CreateResponse(HttpStatusCode.BadRequest, firstMessage);
            }

            _commands.Execute(command);

            var response = Request.CreateResponse(HttpStatusCode.Created, "External link was created successfully.");
            var url = Url.Link(null, new
            {
                controller = "PersonUrls",
                action = "GetSingle",
                personId = personId,
                urlId = command.Created.Id
            });
            Debug.Assert(url != null);
            response.Headers.Location = new Uri(url);
            return response;
            //return Request.CreateResponse(HttpStatusCode.Created, "External link was created successfully.");
        }
 public HttpResponseMessage GetSingle(int personId, int urlId)
 {
     var entity = _queries.Execute(new ExternalUrlBy(urlId));
     var model = new PersonUrlApiModel
     {
         UrlId = entity.Id,
         PersonId = entity.PersonId,
         Description = entity.Description,
         Value = entity.Value,
     };
     return Request.CreateResponse(HttpStatusCode.OK, model);
 }
        public HttpResponseMessage Put(int personId, int urlId, PersonUrlApiModel model)
        {
            if (model == null)
                return Request.CreateResponse(HttpStatusCode.BadRequest, "Please set Content-Type header to application/x-www-form-urlencoded.");

            var command = new UpdateExternalUrl(User, urlId)
            {
                Description = model.Description,
                Value = model.Value,
            };
            var validation = _validation.Validate(command);
            if (!validation.IsValid)
            {
                var firstMessage = validation.Errors.Select(x => x.ErrorMessage).First();
                return Request.CreateResponse(HttpStatusCode.BadRequest, firstMessage);
            }

            _commands.Execute(command);
            return Request.CreateResponse(HttpStatusCode.NoContent, "External link was updated successfully.");
        }