Exemplo n.º 1
0
        public IActionResult UpdateDistributor(Guid id, [FromBody] DistributorForUpdateDto distributor)
        {
            if (distributor == null)
            {
                return(BadRequest());
            }
            var distributorFromRepo = _distributor.GetDistributor(id);

            if (distributorFromRepo == null)
            {
                return(NotFound());
            }
            Mapper.Map(distributor, distributorFromRepo);
            _distributor.DistributorUpdate(distributorFromRepo);
            if (!_distributor.Save())
            {
                throw new Exception($"Deleting Installer with id {id} failed to Delete");
            }

            var InstallerToReturn = Mapper.Map <DistributorDto>(distributorFromRepo);

            //return CreatedAtRoute("GetInstaller", new { id = InstallerToReturn.Id }, InstallerToReturn);

            return(NoContent());
        }