示例#1
0
        /// <summary>  Updates the code camp.</summary>
        /// <param name="moniker">The moniker.</param>
        /// <param name="codeCampModel">The code camp model.</param>
        /// <returns>updated document camp model</returns>
        /// <exception cref="ArgumentNullException">codeCampModel</exception>
        /// <exception cref="InvalidOperationException">Cannot find a code camp by given moniker</exception>
        public async Task <CodeCampModel> UpdateCodeCamp(string moniker, CodeCampModel codeCampModel)
        {
            if (codeCampModel == null)
            {
                throw new ArgumentNullException(nameof(codeCampModel));
            }

            var camp = await this.CodeCampIfExists(moniker);

            if (camp == null)
            {
                throw new InvalidOperationException("Cannot find a code camp by given moniker");
            }

            _mapper.Map(codeCampModel, camp);

            await _repository.SaveAsync();

            return(_mapper.Map <CodeCampModel>(camp));
        }