public async Task InsertSubBusinessLine(SubBusinessLineDTO newSubBusinessLine) { SubBusinessLine dbRecord = _mapper.Map <SubBusinessLine>(newSubBusinessLine); await _unitOfWork.SubBusinessLineRepository.Add(dbRecord); await _unitOfWork.SaveAdministrationSwitchChangesAsync(); }
public async Task <SubBusinessLineDTO> GetSubBusinessLine(int id) { SubBusinessLine dbRecord = await _unitOfWork.SubBusinessLineRepository.GetById(id); SubBusinessLineDTO result = _mapper.Map <SubBusinessLineDTO>(dbRecord); return(result); }
public async Task <IActionResult> Put(SubBusinessLineDTO SubBusinessLine) { var isUpdated = await _subBusinessLineService.UpdateSubBusinessLine(SubBusinessLine); var response = new ApiResponse <bool>(isUpdated); return(Ok(response)); }
public async Task <IActionResult> GetSubBusinessLine(int id) { SubBusinessLineDTO SubBusinessLine = await _subBusinessLineService.GetSubBusinessLine(id); var response = new ApiResponse <SubBusinessLineDTO>(SubBusinessLine); return(Ok(response)); }
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); }
public async Task <IActionResult> Post(SubBusinessLineDTO SubBusinessLine) { await _subBusinessLineService.InsertSubBusinessLine(SubBusinessLine); return(Ok()); }