Exemple #1
0
 public async Task <ActionResult <CompetenceViewModel> > Post(CompetenceViewModel model)
 {
     try
     {
         Competence result = mapper.Map <Competence>(model);
         repository.Add(result);
         if (await repository.SaveChangesAsync())
         {
             return(Created($"/api/camps/{result.CompetenceId}", mapper.Map <CompetenceViewModel>(result)));
         }
     }
     catch (Exception)
     {
         return(this.StatusCode(StatusCodes.Status500InternalServerError, "Error in database"));
     }
     return(BadRequest());
 }