public IActionResult Edit(int id, [Bind("Id,Name,Siren,City,Address,TelNumber,WebSite")] EntrepriseDto entrepriseDto)
        {
            if (id != entrepriseDto.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _entrepriseService.UpdateEntreprise(entrepriseDto);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EntrepriseExists(entrepriseDto.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(entrepriseDto));
        }
 public async Task <IActionResult> Create(EntrepriseDto entrepriseDto)
 {
     if (ModelState.IsValid)
     {
         _entrepriseService.InsertEntreprise(entrepriseDto);
         return(RedirectToAction(nameof(Index)));
     }
     return(View(entrepriseDto));
 }
        /// <summary>
        /// The function that will call the entreprise repository to update our object
        /// </summary>
        /// <param name="entrepriseDto">The entreprise dto</param>
        public void UpdateEntreprise(EntrepriseDto entrepriseDto)
        {
            var config     = new MapperConfiguration(cfg => cfg.CreateMap <EntrepriseDto, Entreprise>());
            var mapper     = config.CreateMapper();
            var entreprise = mapper.Map <Entreprise>(entrepriseDto);

            entreprise.LastUpdate = DateTime.Now;
            _entrepriseRepository.Update(entreprise);
        }
 /// <summary>
 /// The function that will call the entreprise repository to delete our object
 /// </summary>
 /// <param name="entrepriseDto">The entreprise dto</param>
 public void DeleteEntreprise(EntrepriseDto entrepriseDto)
 {
     _entrepriseRepository.Delete(entrepriseDto.Id);
 }