public IActionResult edit(long testimonial_id) { try { var testimonial = _testimonialRepo.getById(testimonial_id); TestimonialDto dto = _mapper.Map <TestimonialDto>(testimonial); return(View(dto)); } catch (Exception ex) { AlertHelper.setMessage(this, ex.Message, messageType.error); return(RedirectToAction("index")); } }
public void delete(long testimonial_id) { try { _transactionManager.beginTransaction(); var testimonial = _testimonialRepo.getById(testimonial_id); if (testimonial == null) { throw new ItemNotFoundException($"Testimonial with id {testimonial_id} doesnot exist."); } string oldImage = testimonial.image_name; _testimonialRepo.delete(testimonial); deleteImage(oldImage); _transactionManager.commitTransaction(); } catch (Exception) { _transactionManager.rollbackTransaction(); throw; } }