예제 #1
0
        private void ValidateUserListWithSearch(UserListRequestModel request)
        {
            if (request.IsNotSpecified())
            {
                throw new WebApiException(HttpStatusCode.BadRequest, UserErrorMessage.MissingUsersInformation);
            }
            if (request.SortByColumn.IsNotSpecified())
            {
                throw new WebApiException(HttpStatusCode.BadRequest, UserErrorMessage.MissingUsersInformation);
            }
            if (request.SortingDirection.IsNotSpecified())
            {
                throw new WebApiException(HttpStatusCode.BadRequest, UserErrorMessage.MissingUsersInformation);
            }
            if (request.OffsetStart < 0)
            {
                throw new WebApiException(HttpStatusCode.BadRequest, UserErrorMessage.MissingUsersInformation);
            }
            if (request.OffsetEnd.IsNotSpecified())
            {
                throw new WebApiException(HttpStatusCode.BadRequest, UserErrorMessage.MissingUsersInformation);
            }
            if (request.CurrentPage < 0)
            {
                throw new WebApiException(HttpStatusCode.BadRequest, UserErrorMessage.MissingUsersInformation);
            }
            if (request.SortingDirection != "asc" && request.SortingDirection != "desc")
            {
                throw new WebApiException(HttpStatusCode.BadRequest, UserErrorMessage.MissingUsersInformation);
            }

            // todo: kke: implement this logic!
            //List<string> allowedSortByColumns = new List<string> { "AuctionName", "AuctionStartingPrice", "AuctionStartDate", "AuctionEndDate" };
            //if (allowedSortByColumns.Contains(request.SortByColumn) == false) { throw new WebApiException(HttpStatusCode.BadRequest, AuctionErrorMessages.MissingAuctionsInformation); }
        }