public HttpResponseMessage Validate(int establishmentId, int establishmentUrlId, EstablishmentUrlApiModel model)
        {
            //System.Threading.Thread.Sleep(2000); // test api latency

            model.OwnerId = establishmentId;
            model.Id = establishmentUrlId;

            ValidationResult validationResult;
            string propertyName;
            if (model.OwnerId < 1 || model.Id < 1)
            {
                var command = new CreateEstablishmentUrl(User);
                Mapper.Map(model, command);
                validationResult = _createValidator.Validate(command);
                propertyName = command.PropertyName(y => y.Value);
            }
            else
            {
                var command = new UpdateEstablishmentUrl(User);
                Mapper.Map(model, command);
                validationResult = _updateValidator.Validate(command);
                propertyName = command.PropertyName(y => y.Value);
            }

            Func<ValidationFailure, bool> forValue = x => x.PropertyName == propertyName;
            if (validationResult.Errors.Any(forValue))
                return Request.CreateResponse(HttpStatusCode.BadRequest,
                    validationResult.Errors.First(forValue).ErrorMessage, "text/plain");

            return Request.CreateResponse(HttpStatusCode.OK);
        }
        public HttpResponseMessage Put(int establishmentId, int establishmentUrlId, EstablishmentUrlApiModel model)
        {
            //System.Threading.Thread.Sleep(2000); // test api latency

            if (!FindResources(establishmentId, establishmentUrlId))
                throw new HttpResponseException(HttpStatusCode.NotFound);
            model.OwnerId = establishmentId;
            model.Id = establishmentUrlId;

            var command = new UpdateEstablishmentUrl(User);
            Mapper.Map(model, command);

            try
            {
                _updateHandler.Handle(command);
            }
            catch (ValidationException ex)
            {
                var badRequest = Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message, "text/plain");
                return badRequest;
            }

            var response = Request.CreateResponse(HttpStatusCode.OK, "Establishment URL was successfully updated.");
            return response;
        }