public async Task <IActionResult> Edit(ContentEntityViewModel vm, int Id, IFormFile mainVideo , IFormFile mainImage, List <IFormFile> galleryImage, string mainImageName, IFormFile headerImage, string headerImageName) { //بررسی فایل ها if (mainVideo != null) { var mainVideoAddress = await FileUploadHelper.UploadFile(mainVideo); if (mainVideoAddress.Item1.Succeed) { vm.MainVideo = mainVideoAddress.Item2; } } if (headerImage != null) { var headerImageAddress = await FileUploadHelper.UploadFile(headerImage); if (headerImageAddress.Item1.Succeed) { vm.HeaderImage = headerImageAddress.Item2; } } if (mainImage != null) { var mainImageAddress = await FileUploadHelper.UploadFile(mainImage); if (mainImageAddress.Item1.Succeed) { vm.MainImage = mainImageAddress.Item2; } } if (mainImageName != null) { vm.MainImage = mainImageName; } if (galleryImage.Count > 0) { var GalleryList = await FileUploadHelper.UploadFile(galleryImage); _GalleryService.Create(GalleryList.Item2, Id); } var result = await _ContentManagementRepository.Edit(Id, vm); TempData.AddResult(result); return(RedirectToAction(nameof(Index), new { vm.Showlocation, vm.MainPageContentType })); }
public ServiceResult <int> Add(ContentEntityViewModel newEntity) { var entity = Mapper.Map <ContentEntityViewModel, ContentEntity>(newEntity); table.Add(entity); if (_context.SaveChanges() > 0) { return(ServiceResult <int> .Okay(data : entity.Id)); } return(ServiceResult <int> .Error("خطایی در هنگام ثبت اطلاعات رخ داده است.لطفا دوباره تلاش کنید.")); }
public async Task <IActionResult> Create(ContentEntityViewModel vm, IFormFile mainVideo, IFormFile mainImage, List <IFormFile> galleryImage, IFormFile headerImage) { //بررسی فایل ها if (headerImage != null) { var headerImageAddress = await FileUploadHelper.UploadFile(headerImage); if (headerImageAddress.Item1.Succeed) { vm.HeaderImage = headerImageAddress.Item2; } } if (mainVideo != null) { var mainVideoAddress = await FileUploadHelper.UploadFile(mainVideo); if (mainVideoAddress.Item1.Succeed) { vm.MainVideo = mainVideoAddress.Item2; } } if (mainImage != null) { var mainImageAddress = await FileUploadHelper.UploadFile(mainImage); if (mainImageAddress.Item1.Succeed) { vm.MainImage = mainImageAddress.Item2; } } vm.CreatedDate = DateTime.Now; var result = _ContentManagementRepository.Add(vm); if (result.Succeed && galleryImage.Count > 0) { var GalleryList = await FileUploadHelper.UploadFile(galleryImage); _GalleryService.Create(GalleryList.Item2, result.Data); } TempData.AddResult(result); return(RedirectToAction(nameof(Index), new { vm.Showlocation, vm.MainPageContentType })); }