Esempio n. 1
0
        public ActionResult <SuggestionReadDto> Create(SuggestionCreateDto suggestionCreateDto)
        {
            Suggestion model = _mapper.Map <Suggestion>(suggestionCreateDto); // trouve le model à utiliser

            _repository.Create(model);                                        // crée la command en ram
            _repository.SaveChanges();                                        // sauvegarde les changements dans la bdd

            SuggestionReadDto suggestionReadDto = _mapper.Map <SuggestionReadDto>(model);

            if (suggestionReadDto.LocataireId != null)
            {
                suggestionReadDto.Locataire = InstanceLocataire.GetById((int)suggestionReadDto.LocataireId);
            }
            else
            {
                return(BadRequest());
            }

            return(Ok(suggestionReadDto));
        }
Esempio n. 2
0
 public Task <SuggestionReadDto> PostAsync(SuggestionCreateDto suggestion)
 {
     return(_suggestionsApi.Post <SuggestionCreateDto, SuggestionReadDto>(suggestion));
 }