Пример #1
0
        public static void ValidateCreateConcert(Concert concert)
        {
            if (concert == null)
            {
                throw new ClientRequestException(HttpStatusCode.BadRequest, "Failed to parse Concert.");
            }

            if (!concert.ValidateConcert())
            {
                throw new ClientRequestException(HttpStatusCode.BadRequest, "Concert or one of its properties is null or incorrect.");
            }
        }
Пример #2
0
        public CreateUpdateConcertResponse CreateConcert([FromUri] bool tweetConcert, [FromBody] Concert concert)
        {
            var requestId = Guid.NewGuid().ToString("N");

            RequestValidator.ValidateWebRequestHeaders(Request);

            if (concert == null)
            {
                throw new ClientRequestException(HttpStatusCode.BadRequest, "Failed to parse Concert.");
            }

            if (!concert.ValidateConcert())
            {
                throw new ClientRequestException(HttpStatusCode.BadRequest, "One or more Concert property is null or incorrect.");
            }

            var responseModel = _concertService.CreateConcert(requestId, concert);

            responseModel.TweetUrl = tweetConcert
                ? _tweetService.TweetConcert(concert)
                : string.Empty;

            return(responseModel);
        }