public PartialViewResult UploadPhoto(int id) { foreach (string file in Request.Files) { var upload = Request.Files[file]; if (upload != null) { // получаем имя файла string fileName = "/Content/Gallery/" + id + "_" + upload.FileName; //сохраняем путь в табличке в базе данных var photo = new PhotoForGalleryDTO() { RealEstateId = id, UrlImage = fileName, }; _descriptionService.AddPhotoForGallery(photo); // сохраняем файл в папку Files в проекте upload.SaveAs(Server.MapPath(fileName)); } } _descriptionService.Save(); List <PhotoForGalleryDTO> photos = _descriptionService.GetPhotoForGalleryById(id).ToList(); return(PartialView("PhotosList", photos)); }
public void AddPhotoForGallery(PhotoForGalleryDTO photoDto) { var photo = new PhotoForGallery() { RealEstateId = photoDto.RealEstateId, UrlImage = photoDto.UrlImage, }; _testStoreContext.PhotoForGalleries.Add(photo); }
public void AddPhotoForGallery(PhotoForGalleryDTO photoDto) { _descriptionRepository.AddPhotoForGallery(photoDto); }