public async Task <IActionResult> CreatePost(int id, EvaluationCreationDto evaluationCreation) { if (!ModelState.IsValid) { return(View(evaluationCreation)); } var boutique = await _repository.Boutique.GetBoutiqueByIdAsync(id); if (boutique == null) { _logger.LogError($"la boutique avec id: {id} n'existe pas dans la base"); return(NotFound()); } evaluationCreation.BoutiqueId = id; var user = await _userManager.FindByEmailAsync(User.Identity.Name); evaluationCreation.UserId = user.Id; evaluationCreation.NoteGlobale = evaluationCreation.NoteProprete + evaluationCreation.NoteEquipe + evaluationCreation.NoteAgencement + evaluationCreation.NoteComportement; _logger.LogDebug($"action create : objet evaluation boutiqueId: {evaluationCreation.BoutiqueId} evaluation user id {evaluationCreation.UserId}"); var evaluation = _mapper.Map <Evaluation>(evaluationCreation); _repository.Evaluation.Create(evaluation); await _repository.SaveAsync(); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Create(int id) { var boutique = await _repository.Boutique.GetBoutiqueByIdAsync(id); if (boutique == null) { _logger.LogError($"la boutique avec id: {id} n'existe pas dans la base"); return(NotFound()); } var user = await _userManager.FindByEmailAsync(User.Identity.Name); //_logger.LogDebug($"user id: {user.Id}"); var evaluation = new EvaluationCreationDto { BoutiqueId = id, UserId = user.Id, EvaluationDate = DateTime.Now }; //_logger.LogDebug($" httpGet boutiqueId : {evaluation.BoutiqueId}"); var evaluationToReturn = _mapper.Map <EvaluationCreationDto>(evaluation); return(View(evaluationToReturn)); }