Ejemplo n.º 1
0
        public ActionResult <CompanyCreateDto> UpdateCompany(Guid id, CompanyUpdateDto companyUpdateDto)
        {
            var companyModelFromRepo = _repository.GetCompanyById(id);

            if (companyModelFromRepo != null)
            {
                //Dbcontext tracks changes mapped with the DTO class
                _mapper.Map(companyUpdateDto, companyModelFromRepo);

                _repository.UpdateCompany(companyModelFromRepo);
                _repository.SaveChanges();

                return(NoContent());
            }
            return(NotFound());
        }