public void delete(long file_upload_id) { try { _transactionManager.beginTransaction(); var fileUpload = _fileUploadRepo.getById(file_upload_id); if (fileUpload == null) { throw new ItemNotFoundException($"File with id {file_upload_id} doesn't exist."); } string oldImage = fileUpload.file_name; _fileUploadRepo.delete(fileUpload); deleteImage(oldImage); _transactionManager.commitTransaction(); } catch (Exception) { _transactionManager.rollbackTransaction(); throw; } }
public IActionResult edit(long file_upload_id) { try { CMS.Core.Entity.FileUpload fileUpload = _fileUploadRepo.getById(file_upload_id); FileUploadModel fileUploadModel = _mapper.Map <FileUploadModel>(fileUpload); return(View(fileUploadModel)); } catch (Exception ex) { AlertHelper.setMessage(this, ex.Message, messageType.error); return(RedirectToAction("index")); } }