public async Task <IActionResult> Create(ReceivePaymentCulturalExchangeViewModel receivePaymentVM) { try { if (ModelState.IsValid) { var culturalExchange = _culturalExchangeAppService.GetById(receivePaymentVM.CulturalExchangeId); receivePaymentVM.FileName = await _fileUploadAppService.Upload(_appSetttings.Value.UploadFilePath + culturalExchange.Id, null, receivePaymentVM.File); if (!string.IsNullOrWhiteSpace(receivePaymentVM.FileName) || !receivePaymentVM.ValidationResult.Any()) { _receivePaymentCulturalExchangeAppService.Add(receivePaymentVM); return(RedirectToAction("Index", "ReceivePaymentCulturalExchange")); } else { _fileUploadAppService.Delete(_appSetttings.Value.UploadFilePath, receivePaymentVM.FileName); } return(View(receivePaymentVM)); } return(Json(Conflict())); } catch (Exception ex) { _fileUploadAppService.Delete(_appSetttings.Value.UploadFilePath, receivePaymentVM.FileName); return(View(receivePaymentVM)); } }
public async Task <IActionResult> Create(PaymentCulturalExchangeViewModel paymentCulturalExchangeViewModel) { try { if (ModelState.IsValid) { var culturalExchange = _culturalExchangeAppService.GetById(paymentCulturalExchangeViewModel.CulturalExchangeId); paymentCulturalExchangeViewModel.FileName = await _fileUploadAppService.Upload( _appSetttings.Value.UploadFilePath + culturalExchange.Id, null, paymentCulturalExchangeViewModel.File); paymentCulturalExchangeViewModel = _paymentCulturalExchangeAppService.Add(paymentCulturalExchangeViewModel); if (!paymentCulturalExchangeViewModel.ValidationResult.Any()) { return(RedirectToAction("Index", "ReceivePaymentCulturalExchange")); } } return(Json(Conflict())); } catch (Exception ex) { _fileUploadAppService.Delete(_appSetttings.Value.UploadFilePath, paymentCulturalExchangeViewModel.FileName); return(Json(BadRequest())); } }
public async Task <IActionResult> CulturalExchangeDeleteFile(Guid id, string fileName, Guid culturalExchangeId) { try { if (id != Guid.Empty && !string.IsNullOrWhiteSpace(fileName)) { _culturalExchangeFileUploadAppService.Delete(id); _fileUploadAppService.Delete(_appSetttings.Value.UploadFilePath + culturalExchangeId, fileName); return(Json(Ok())); } return(Json(Conflict())); } catch (Exception ex) { return(Json(BadRequest())); } }