Ejemplo n.º 1
0
        public async Task <IActionResult> Save(int requestId, DonationRequest request, IList <IFormFile> files)
        {
            var f           = files;
            var newImageUrl = await _imageSaveService.SaveImage(Request);

            var newPdfUrl = await _pdfSaveService.SavePdf(Request);

            if (!string.IsNullOrEmpty(newImageUrl))
            {
                request.ImageUrl = newImageUrl;
            }
            if (!string.IsNullOrEmpty(newPdfUrl))
            {
                request.BudgetPdfUrl = newPdfUrl;
            }

            if (requestId == 0)
            {
                await _requestRepository.Insert(request);
            }
            else
            {
                request.Donations = await _donationRepository.SearchFor(r => r.DonationRequestId == requestId).ToListAsync();

                await _requestRepository.Update(request);
            }

            return(RedirectToAction("Edit", new { requestId = request.Id }));
        }
        public async Task <IActionResult> Save(GalleryItem galleryItem)
        {
            var imageName = await _imageSaveService.SaveImage(Request);

            galleryItem.ImageName = imageName;

            if (!string.IsNullOrEmpty(galleryItem.ImageName) || !string.IsNullOrEmpty(galleryItem.ItemUrl) || !string.IsNullOrEmpty(galleryItem.EmbeddedHtml))
            {
                if (galleryItem.Id == 0)
                {
                    await _galleryItemRepository.Insert(galleryItem);
                }
                else
                {
                    await _galleryItemRepository.Update(galleryItem);
                }
            }

            ViewData["DonationRequestId"] = galleryItem.DonationRequestId;
            var galleryItems = await _galleryItemRepository.GetAll().ToListAsync();

            return(View("Edit", galleryItems));
        }