Beispiel #1
0
        /// <summary>
        /// Gets respondent by their id.
        /// </summary>
        /// <param name="id">
        /// The id.
        /// </param>
        /// <returns>
        /// The <see cref="CommonResultGeneric{T}"/>.
        /// </returns>
        public CommonResultGeneric <RespondentDto> GetById(int id)
        {
            var respondent = this.respondentsRepository.GetById(id);

            if (respondent == null)
            {
                return(CommonResultGeneric <RespondentDto> .Failure <RespondentDto>(
                           "Problems occured while fetchin respondent by given id"));
            }

            return(CommonResultGeneric <RespondentDto> .Success(respondent));
        }
Beispiel #2
0
        /// <summary>
        /// Adds new respondent to database
        /// </summary>
        /// <param name="newEntry">
        /// The new entry.
        /// </param>
        /// <returns>
        /// The <see cref="CommonResultGeneric{T}"/>.
        /// </returns>
        public CommonResultGeneric <RespondentDto> Add(RespondentDto newEntry)
        {
            var respondent = this.respondentsRepository.Add(newEntry);

            if (respondent.Id == 0)
            {
                return(CommonResultGeneric <RespondentDto> .Failure <RespondentDto>(
                           "Some problems occured while adding new rewspondent"));
            }

            return(CommonResultGeneric <RespondentDto> .Success(respondent));
        }