Exemple #1
0
        public async Task <IActionResult> Put(ChannelEnterpriseDTO channelEnterprise)
        {
            var isUpdated = await _channelEnterpriseService.UpdateChannelEnterprise(channelEnterprise);

            var response = new ApiResponse <bool>(isUpdated);

            return(Ok(response));
        }
        public async Task InsertChannelEnterprise(ChannelEnterpriseDTO newChannelEnterprise)
        {
            ChannelEnterprise dbRecord = _mapper.Map <ChannelEnterprise>(newChannelEnterprise);

            await _unitOfWork.ChannelEnterpriseRepository.Add(dbRecord);

            await _unitOfWork.SaveAdministrationSwitchChangesAsync();
        }
Exemple #3
0
        public async Task <IActionResult> Post(ChannelEnterpriseDTO channelEnterprise)
        {
            await _channelEnterpriseService.InsertChannelEnterprise(channelEnterprise);

            var response = new ApiResponse <bool>(true);

            return(Ok(response));
        }
        public async Task <bool> UpdateChannelEnterprise(ChannelEnterpriseDTO channelEnterpriseDTO)
        {
            ChannelEnterprise existingRecord = await _unitOfWork.ChannelEnterpriseRepository.GetById(channelEnterpriseDTO.Id);

            if (existingRecord == null)
            {
                throw new ValidationException("Registro no existe para el ID proporcionado.");
            }


            var updatedRecord = _mapper.Map <ChannelEnterprise>(channelEnterpriseDTO);

            _unitOfWork.ChannelEnterpriseRepository.Update(existingRecord, updatedRecord);

            await _unitOfWork.SaveAdministrationSwitchChangesAsync();

            return(true);
        }