コード例 #1
0
        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));
        }
コード例 #2
0
        public void AddPhotoForGallery(PhotoForGalleryDTO photoDto)
        {
            var photo = new PhotoForGallery()
            {
                RealEstateId = photoDto.RealEstateId,
                UrlImage     = photoDto.UrlImage,
            };

            _testStoreContext.PhotoForGalleries.Add(photo);
        }
コード例 #3
0
 public void AddPhotoForGallery(PhotoForGalleryDTO photoDto)
 {
     _descriptionRepository.AddPhotoForGallery(photoDto);
 }