/// <summary> /// Adds the new code camp. /// </summary> /// <param name="codeCampModel">The code camp model.</param> /// <returns>created code camp model</returns> /// <exception cref="ArgumentNullException">codeCampModel</exception> /// <exception cref="InvalidOperationException">Moniker should be unique</exception> public async Task <CodeCampModel> AddNewCodeCamp(CodeCampModel codeCampModel) { if (codeCampModel == null) { throw new ArgumentNullException(nameof(codeCampModel)); } if (await this.CodeCampExists(codeCampModel.Moniker)) { throw new InvalidOperationException("Moniker should be unique"); } var codeCamp = _mapper.Map <CodeCamp>(codeCampModel); _repository.Insert(codeCamp); await _repository.SaveAsync(); return(await GetCodeCamp(codeCampModel.Moniker)); }