예제 #1
0
        public async Task Modifier(string text)
        {
            var            config         = new MapperConfiguration(cfg => cfg.CreateMap <TacheReadDto, TacheUpdateDto>());
            var            mapper         = new Mapper(config);
            TacheUpdateDto tacheUpdateDto = mapper.Map <TacheUpdateDto>(_tacheReadDto);

            tacheUpdateDto.Description = text;

            await _repositoryTaches.Modifier(tacheUpdateDto);
        }
예제 #2
0
 public async Task Modifier(TacheUpdateDto tacheUpdateDto)
 {
     try
     {
         await ApiController.Update(tacheUpdateDto);
     }
     catch (Exception ex)
     {
         throw new Exception($"Impossible de mettre à jour la tâche : {tacheUpdateDto.Id} \n" + ex.Message);
     }
 }
예제 #3
0
        public ActionResult Update(int id, TacheUpdateDto tacheUpdateDto)
        {
            Tache tache = _repository.GetById(id);             // cherche l'objet dans la bdd

            if (tache == null)
            {
                return(NotFound());                // si il n'existe pas on quitte et envoie 404
            }
            _mapper.Map(tacheUpdateDto, tache);    // met commandUpdateDto dans commandModelFromRepo

            _repository.Update(tache);             // update l'objet

            _repository.SaveChanges();             // sauvegarde l'état de l'objet dans la bdd

            return(NoContent());
        }
예제 #4
0
        /**
         * <summary>Met à jour le locataire courant en passant au suivant</summary>
         * <param name="id">Id de la tâche concernée</param>
         * <param name="idLocataire">Id du locataire à mettre</param>
         */
        public async Task LocataireSuivant(int id, int idLocataire)
        {
            try
            {
                TacheReadDto tacheReadDto = await _tachesApi.GetById <TacheReadDto>(id);     // récupère les infos du locataire actuel

                tacheReadDto.DateFin     = tacheReadDto.DateFin.AddDays(tacheReadDto.Cycle); // met à jour la datte de fin
                tacheReadDto.LocataireId = idLocataire;                                      // met à jour le locataire courant

                //Initialize the mapper
                MapperConfiguration config = new MapperConfiguration(cfg =>
                                                                     cfg.CreateMap <TacheReadDto, TacheUpdateDto>()
                                                                     );
                Mapper         mapper         = new Mapper(config);
                TacheUpdateDto tacheUpdateDto = mapper.Map <TacheUpdateDto>(tacheReadDto);

                await _tachesApi.Update(tacheUpdateDto);                 // met à jour le locataire
            }
            catch (Exception ex)
            {
                throw new Exception("Impossible de modifier la tâche avec l'id " + id + "  : \n" + ex.Message);
            }
        }
예제 #5
0
        /// <summary>
        /// Met à jour la tâche et définit un nouveau locataire devant effectuer la tâche
        /// </summary>
        /// <param name="id">Id de la tâche</param>
        /// <param name="idLocataire">Id du locataire devant effectuer la tâche</param>
        public async Task ModifierLocataireCourant(int id, int idLocataire)
        {
            try
            {
                //todo optimiser avec un patch au lieu de put
                TacheReadDto tacheReadDto = await ApiController.GetById <TacheReadDto>(id);

                tacheReadDto.DateFin     = tacheReadDto.DateFin.AddDays(tacheReadDto.Cycle); // met à jour la datte de fin
                tacheReadDto.LocataireId = idLocataire;                                      // met à jour le locataire courant

                //Initialize the mapper
                MapperConfiguration config = new MapperConfiguration(cfg =>
                                                                     cfg.CreateMap <TacheReadDto, TacheUpdateDto>()
                                                                     );
                Mapper         mapper         = new Mapper(config);
                TacheUpdateDto tacheUpdateDto = mapper.Map <TacheUpdateDto>(tacheReadDto);

                await ApiController.Update(tacheUpdateDto);
            }
            catch (Exception ex)
            {
                throw new Exception("Impossible de modifier la tâche " + id + "  : \n" + ex.Message);
            }
        }
예제 #6
0
 public async Task UpdateAsync(TacheUpdateDto tache)
 {
     await _tachesApi.Update(tache);
 }