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 <JsonResult> PostModalCulturalExchangeUploadFile(CulturalExchangeFileUploadViewModel fileUploadViewModel) { try { if (ModelState.IsValid) { var culturalExchange = _culturalExchangeAppService.GetById(fileUploadViewModel.CulturalExchangeId); fileUploadViewModel.FileName = await _fileUploadAppService.Upload(_appSetttings.Value.UploadFilePath + culturalExchange.Id, null, fileUploadViewModel.File); if (!string.IsNullOrWhiteSpace(fileUploadViewModel.FileName)) { _culturalExchangeFileUploadAppService.Add(fileUploadViewModel); return(Json(Ok())); } } return(Json(Conflict())); } catch (Exception ex) { _fileUploadAppService.Delete(_appSetttings.Value.UploadFilePath, fileUploadViewModel.FileName); return(Json(BadRequest())); } }
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())); } }