Exemple #1
0
        public async Task InsertSubBusinessLine(SubBusinessLineDTO newSubBusinessLine)
        {
            SubBusinessLine dbRecord = _mapper.Map <SubBusinessLine>(newSubBusinessLine);

            await _unitOfWork.SubBusinessLineRepository.Add(dbRecord);

            await _unitOfWork.SaveAdministrationSwitchChangesAsync();
        }
Exemple #2
0
        public async Task <SubBusinessLineDTO> GetSubBusinessLine(int id)
        {
            SubBusinessLine dbRecord = await _unitOfWork.SubBusinessLineRepository.GetById(id);

            SubBusinessLineDTO result = _mapper.Map <SubBusinessLineDTO>(dbRecord);

            return(result);
        }
Exemple #3
0
        public async Task <IActionResult> Put(SubBusinessLineDTO SubBusinessLine)
        {
            var isUpdated = await _subBusinessLineService.UpdateSubBusinessLine(SubBusinessLine);

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

            return(Ok(response));
        }
Exemple #4
0
        public async Task <IActionResult> GetSubBusinessLine(int id)
        {
            SubBusinessLineDTO SubBusinessLine = await _subBusinessLineService.GetSubBusinessLine(id);

            var response = new ApiResponse <SubBusinessLineDTO>(SubBusinessLine);

            return(Ok(response));
        }
Exemple #5
0
        public async Task <bool> UpdateSubBusinessLine(SubBusinessLineDTO updatedSubBusinessLineDTO)
        {
            SubBusinessLine existingRecord = await _unitOfWork.SubBusinessLineRepository.GetById(updatedSubBusinessLineDTO.Id);

            if (existingRecord == null)
            {
                throw new KeyNotFoundException();
            }

            var updatedRecord = _mapper.Map <SubBusinessLine>(updatedSubBusinessLineDTO);

            _unitOfWork.SubBusinessLineRepository.Update(existingRecord, updatedRecord);

            await _unitOfWork.SaveAdministrationSwitchChangesAsync();

            return(true);
        }
Exemple #6
0
        public async Task <IActionResult> Post(SubBusinessLineDTO SubBusinessLine)
        {
            await _subBusinessLineService.InsertSubBusinessLine(SubBusinessLine);

            return(Ok());
        }