Esempio n. 1
0
        public bool ExportImage(PhotoViewModel photoToExport)
        {
            if (!File.Exists(photoToExport.PhotoData.OriginalPhotoPath))
            {
                notificationService.ShowNotification(NotificationTypeEnum.Error, "Cannot save image, data is missing");
                return(false);
            }
            if (File.Exists(photoToExport.PhotoData.CurrentPhotoPath))
            {
                File.Delete(photoToExport.PhotoData.CurrentPhotoPath);
            }

            if (File.Exists(photoToExport.PhotoData.ImageDataXmlPath))
            {
                File.Delete(photoToExport.PhotoData.ImageDataXmlPath);
            }

            using (var fileStream = new FileStream(photoToExport.PhotoData.CurrentPhotoPath, FileMode.Create))
            {
                BitmapEncoder encoder = new PngBitmapEncoder();
                encoder.Frames.Add(BitmapFrame.Create(photoToExport.CurrentImage));
                encoder.Save(fileStream);
            }
            xmlManager.XmlSerialize(photoToExport.PhotoData, photoToExport.PhotoData.ImageDataXmlPath);
            notificationService.ShowNotification(NotificationTypeEnum.Information, "Saved photo!");
            return(true);
        }
Esempio n. 2
0
        public async Task <ActionResult> Edit(PhotoViewModel photo, HttpPostedFileBase photoPath)
        {
            var destination = Server.MapPath("~/GalleryImages/");

            if (photoPath != null && photoPath.ContentLength > 0)
            {
                var path = Path.Combine(destination, photoPath.FileName);
                photoPath.SaveAs(path);
                photo.PhotoPath = photoPath.FileName;

                photo.PhotoDate = DateTime.UtcNow;
                await RemoveOldFileIfExists(photo);
            }
            if (ModelState.IsValid)
            {
                await _photoAutomapper.FromBltoUiEditoUpdateAsync(photo);

                //ViewBag.AlbumId =
                //    new SelectList(_albumAutomapper.FromBltoUiGetAll().OrderBy(x => x.AlbumId == photo.PhotoId),
                //        "AlbumId", "AlbumName");
                return(Json(new { status = 1, Message = "Edit Photo Success" }));
            }

            return(Json(new { status = 1, Message = "Cannot Edit Photo" }));
        }
Esempio n. 3
0
        public IActionResult AddPhoto(PhotoViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            if (model.Image == null)
            {
                return(View());
            }
            var photo = new Photo {
                CityId = model.CityId, ImageType = model.Image.ContentType, PhotoInfo = model.PhotoInfo
            };

            if (model.Image != null)
            {
                byte[] imageData = null;
                // считываем переданный файл в массив байтов
                using (var binaryReader = new BinaryReader(model.Image.OpenReadStream()))
                {
                    imageData = binaryReader.ReadBytes((int)model.Image.Length);
                }
                // установка массива байтов
                photo.Image = imageData;
            }
            _photoRepositoty.Add(photo);
            return(RedirectToAction("More", "Cities", new { id = model.CityId }));
        }
        public async Task<ActionResult> Create(PhotoViewModel photoViewModel, HttpPostedFileBase file, FormCollection collection)
        {
            if (!this.ModelState.IsValid)
            {
                return this.View();
            }

            var photo = this.FromViewModel(photoViewModel);

            if (file != null)
            {
                // Save file stream to Blob Storage
                var blob = this.GetBlobContainer().GetBlockBlobReference(file.FileName);
                blob.Properties.ContentType = file.ContentType;
                await blob.UploadFromStreamAsync(file.InputStream);
                photo.BlobReference = file.FileName;
            }
            else
            {
                this.ModelState.AddModelError("File", new ArgumentNullException("file"));
                return this.View(photoViewModel);
            }

            // Save information to Table Storage
            var photoContext = this.GetPhotoContext();
            await photoContext.AddPhotoAsync(photo);

            // Send create notification
            var msg = new CloudQueueMessage("Photo Uploaded");
            await this.GetCloudQueue().AddMessageAsync(msg);

            return this.RedirectToAction("Index");
        }
Esempio n. 5
0
 public JsonNetResult Edit(PhotoViewModel vm)
 {
     if (ModelState.IsValid)
     {
         Photo  photo  = this.photoTasks.GetPhoto(vm.Id);
         Person person = this.personTasks.GetPerson(vm.PersonId);
         if (photo != null)
         {
             Photo existing = this.photoTasks.GetPhoto(vm.PhotoName);
             if (existing != null && existing.Id != vm.Id)
             {
                 ModelState.AddModelError("PhotoName", "Photo name already exists.");
             }
             else
             {
                 photo.PhotoName = vm.PhotoName;
                 photo.FileURL   = vm.FileURL;
                 photo.Notes     = vm.Notes;
                 photo           = this.photoTasks.SavePersonPhoto(person, photo);
                 return(JsonNet(string.Empty));
             }
         }
         else
         {
             Response.StatusCode = (int)HttpStatusCode.NotFound;
             return(JsonNet("Person photo not found."));
         }
     }
     return(JsonNet(this.GetErrorsForJson()));
 }
        public ActionResult MyAlbums(string owner)
        {
            AlbumViewModel albumViewModel = new AlbumViewModel();
            PhotoViewModel photoViewModel = new PhotoViewModel();

            albumViewModel.Owner = owner.ToLowerInvariant();
            photoViewModel.Owner = owner.ToLowerInvariant();

            var albums = this.repository.GetAlbumsByOwner(owner.ToLowerInvariant());

            // if there are more than 1 album with photos for this user
            // then return a view of the albums for them
            if (albums.Where(a => a.HasPhotos).Count() > 1)
            {
                albumViewModel.Albums = albums;
                return(View("Index", albumViewModel));
            }

            // if there is only 1 album, just return photos for it
            if (albums.Where(a => a.HasPhotos).Count() == 1)
            {
                photoViewModel.Photos = this.repository.GetPhotosByAlbum(owner, albums.First().AlbumId);
                return(View("Get", photoViewModel));
            }

            // there are no albums for this user
            return(View("Get", new PhotoViewModel()));
        }
Esempio n. 7
0
        // GET: Photo
        public ActionResult Photo(int?id)
        {
            PhotoViewModel pvm = new PhotoViewModel();

            pvm.Photos = db.Photos.ToList().FindAll(p => p.DiveId == id);
            return(View(pvm));
        }
Esempio n. 8
0
        public IActionResult Insert(PhotoViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View("Create", model));
            }

            var path = $"wwwroot\\uploads\\{model.Photo.FileName}";

            using (var stream = new FileStream(path, FileMode.Create))
            {
                model.Photo.CopyTo(stream);
            }

            var photo = new Photo
            {
                AlbumId   = model.AlbumId,
                PhotoLink = $"/uploads/{model.Photo.FileName}"
            };

            _photoService.Create(photo);

            return(RedirectToAction("Index", new {
                id = model.AlbumId
            }));
        }
Esempio n. 9
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);

            ViewBag.ControllerName = (String)RouteData.Values["controller"];
            ViewBag.ActionName     = RouteData.Values["action"].ToString().ToLower();

            ViewBag.HttpKeys = Request.QueryString.AllKeys;
            ViewBag.Query    = Request.QueryString;

            filter = getFilter(page_size);

            model = new PhotoViewModel()
            {
                Account        = AccountInfo,
                Settings       = SettingsInfo,
                UserResolution = UserResolutionInfo,
                ControllerName = ControllerName,
                ActionName     = ActionName
            };

            //Справочник всех доступных категорий
            MaterialsGroup[] GroupsValues = _cmsRepository.getAllMaterialGroups();
            ViewBag.AllGroups = GroupsValues;

            #region Метатеги
            ViewBag.Title       = UserResolutionInfo.Title;
            ViewBag.Description = "";
            ViewBag.KeyWords    = "";
            #endregion
        }
        /// <summary>
        /// Updates the photo.
        /// </summary>
        /// <param name="assessment">The assessment.</param>
        /// <returns></returns>
        public Response <PhotoViewModel> UpdatePhoto(PhotoViewModel assessment)
        {
            string apiUrl   = baseRoute + "updatePhoto";
            var    response = communicationManager.Put <PhotoModel, Response <PhotoModel> >(assessment.ToModel(), apiUrl);

            return(response.ToViewModel());
        }
Esempio n. 11
0
        public ActionResult AddPhoto(PhotoViewModel viewModel, HttpPostedFileBase uploadImage, string photoName, int page = 1)
        {
            if (ModelState.IsValid)
            {
                if (uploadImage == null)
                {
                    ModelState.AddModelError("", "A photo is not selected.");
                    return(View(viewModel));
                }

                byte[] imageData = null;
                using (var binaryReader = new BinaryReader(uploadImage.InputStream))
                {
                    imageData = binaryReader.ReadBytes(uploadImage.ContentLength);
                }

                viewModel.Image        = imageData;
                viewModel.CreationDate = DateTime.Now;
                viewModel.UserId       = userService.GetUserEntityByLogin(User.Identity.Name).Id;
                photoService.CreateEntity(viewModel.ToBllPhoto());

                return(RedirectToAction("Photos", new { page = page, photoName = photoName }));
            }
            return(View(viewModel));
        }
Esempio n. 12
0
 void loadPhotos()
 {
     lp           = PhotoORM.listePhotos();
     myDataObject = new PhotoViewModel();
     //LIEN AVEC la VIEW
     listePhotos.ItemsSource = lp; // bind de la liste avec la source, permettant le binding.
 }
Esempio n. 13
0
        public static PhotoViewModel getPhoto(int idPhoto)
        {
            PhotoDAO       pDAO = PhotoDAO.getPhoto(idPhoto);
            PhotoViewModel p    = new PhotoViewModel(pDAO.id_photo, pDAO.id_produit);

            return(p);
        }
Esempio n. 14
0
        public ActionResult ViewPhoto(string uniqueUserName, string photoName)
        {
            string userId = User.Identity.GetUserId();

            string currentUserName = string.Empty;

            if (!string.IsNullOrEmpty(userId))
            {
                currentUserName = _userService.GetUniqueUserNameById(userId);
            }

            var request = new RequestEntity
            {
                UniqueUserName  = uniqueUserName,
                PhotoName       = photoName,
                CurrentUserName = currentUserName
            };

            var response = _photoService.GetPhoto(request);

            PhotoViewModel photo = MapperHelper.GetValue <Photo, PhotoViewModel>(response);

            if (photo == null)
            {
                var errMsg = string.Format(Errors.PhotoNotFound, photoName, uniqueUserName);
                _logger.Error(errMsg);
                return(View("Error", errMsg));
            }

            ViewBag.CurrentUniqueUserName = currentUserName;

            ViewBag.ResultMessage = TempData["ResultMessage"];

            return(View(photo));
        }
Esempio n. 15
0
        public async Task <IHttpActionResult> Add()
        {
            // Check if the request contains multipart/form-data.
            if (!Request.Content.IsMimeMultipartContent("form-data"))
            {
                return(BadRequest("Unsupported media type"));
            }
            try
            {
                var provider = new CustomMultipartFormDataStreamProvider(workingFolder);
                //await Request.Content.ReadAsMultipartAsync(provider);
                await Task.Run(async() => await Request.Content.ReadAsMultipartAsync(provider));

                var file     = provider.FileData.FirstOrDefault();
                var fileInfo = new FileInfo(file.LocalFileName);
                var photo    = new PhotoViewModel
                {
                    Name     = fileInfo.Name,
                    Created  = fileInfo.CreationTime,
                    Modified = fileInfo.LastWriteTime,
                    Size     = fileInfo.Length / 1024
                };

                photo.Path = string.IsNullOrEmpty(photo.Name) ? null : @"../../../Resources/images/" + photo.Name;


                return(Ok(new { Message = "Photos uploaded ok", Photo = photo }));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.GetBaseException().Message));
            }
        }
        public IHttpActionResult GetPhotoById(int photoId, string username)
        {
            var currentUserId = this.UserIdProvider.GetUserId();
            var currentUser   = this.Data.Users.Find(currentUserId);
            var wantedUser    = this.Data
                                .Users
                                .All()
                                .FirstOrDefault(u => u.UserName == username);

            if (wantedUser == null)
            {
                return(this.NotFound());
            }

            if (!this.HasAuthorizationForDetailedInfo(wantedUser, currentUserId))
            {
                return(this.Unauthorized());
            }

            var photo = this.Data.Photos
                        .All()
                        .Where(p => p.Id == photoId)
                        .Select(PhotoViewModel.Create(currentUser))
                        .FirstOrDefault();

            if (photo == null)
            {
                return(this.NotFound());
            }

            return(this.Ok(photo));
        }
Esempio n. 17
0
        public async Task <IActionResult> Detect(PhotoViewModel model)
        {
            if (model?.File == null)
            {
                TempData["photoError"] = "Para visualizar os detalhes da foto, é necessário escolhê-la primeiro.";

                return(View(nameof(Index)));
            }
            else
            {
                if (model.File.Length > 4e+6)
                {
                    TempData["photoError"] = "O tamanho máximo permitido da imagem é 4MB!";

                    return(View(nameof(Index)));
                }

                var restrictImage = await _cognitiveService.IsRestrictImageAsync(model);

                if (restrictImage)
                {
                    TempData["photoError"] = "Essa imagem possui conteúdo inapropriado (Adulto/Violência). " +
                                             "Por favor, selecione outra imagem e tente novamente!";

                    return(View(nameof(Index)));
                }
                else
                {
                    var analyzeResult = await _cognitiveService.AnalyzeImageAsync(model);

                    return(View(analyzeResult));
                }
            }
        }
        public async Task <Analyze> AnalyzeImageAsync(PhotoViewModel photoViewModel)
        {
            var bytes = await photoViewModel.File.GetRawBytes();

            var queryString = HttpUtility.ParseQueryString(string.Empty);

            queryString["visualFeatures"] = "Description,Faces";
            queryString["language"]       = "pt";

            using (var content = new ByteArrayContent(bytes))
            {
                content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
                var response = await _httpClient.PostAsync($"/vision/v2.1/analyze?{queryString}", content);

                if (response.IsSuccessStatusCode)
                {
                    var result = await response.Content.ReadAsJsonAsync <Analyze>(true);

                    result.Base64Image = await photoViewModel.File.ConvertToBase64();

                    return(result);
                }
                else
                {
                    return(null);
                }
            }
        }
Esempio n. 19
0
        private void ShowImages(ChildWindowEventArg args)
        {
            var childWindow = new ChildWindow
            {
                Content     = args.View,
                DataContext = args.ViewModel
            };

            PhotoViewModel photoViewModel = args.ViewModel as PhotoViewModel;
            Action         hideWindows    = () => childWindow.Hide();

            if (photoViewModel != null)
            {
                photoViewModel.HideWindow = () => hideWindows();
            }

            Action <object, KeyEventArgs> childWindowKeyUp =
                (sender, e) =>
            {
                if (e.Key == Key.Escape)
                {
                    hideWindows();
                }
            };

            childWindow.KeyUp += (sender, e) => childWindowKeyUp(sender, e);
            Action <ChildWindowScaleEventArgs> scaleCildWindow =
                x => childWindow.WindowState = x.FullScale ? WindowState.Maximized : WindowState.Normal;
            Func <ChildWindowScaleEventArgs, bool> canScaleCildWindow = x => x != null;

            Messenger?.Register(CommandName.SetPhotoWindowState, scaleCildWindow, canScaleCildWindow);
            childWindow.ShowDialog();
            Messenger?.Unregister(CommandName.SetPhotoWindowState);
            childWindow.Close();
        }
Esempio n. 20
0
        public ActionResult Index(long photoID)
        {
            PhotoViewModel model = new PhotoViewModel();

            model.Photo = PhotoRepository.Single(p => p.ID == photoID, p => p.Site, p => p.Tags);

            if (model.Photo == null)
            {
                return(new HttpNotFoundResult(string.Format("Photo {0} was not found", photoID)));
            }

            model.Photo.AvailableTags = PhotoService.GetUnusedTagNames(photoID);

            model.PhotoDate  = model.Photo.Captured.ToString("MMM dd, yyyy");
            model.PhotoTime  = model.Photo.Captured.ToString("h:mm:ss tt");
            model.SiteCoords = string.Format("{0}, {1}", model.Photo.Site.Latitude, model.Photo.Site.Longitude);

            model.DroughtMonitorData         = LoadDMData(DMDataType.COUNTY, model.Photo.Captured, model.Photo.Site.CountyFips);
            model.DroughtMonitorData.PhotoID = photoID;

            model.WaterData         = LoadWaterData(model.Photo.Site.Latitude, model.Photo.Site.Longitude, model.Photo.Captured);
            model.WaterData.PhotoID = photoID;

            model.UserCollections = LoadUserCollections(photoID);

            return(View(model));
        }
        public async Task <ActionResult> PostAsync([FromForm] PhotoViewModel viewModel)
        {
            if (viewModel.Image.Length != 0)
            {
                var photo = new Photo()
                {
                    Description = viewModel.Description, Name = viewModel.Name
                };

                using (var ms = new MemoryStream())
                {
                    viewModel.Image.CopyTo(ms);
                    var fileBytes = ms.ToArray();

                    photo.Image     = fileBytes;
                    photo.Thumbnail = new ThumbnailCreator().CreateThumbnailBytes(20, fileBytes, Format.Jpeg);
                };

                await _database.AddAsync(photo);

                await SendEmail();

                return(Created(string.Empty, new { photo.Id }));
            }
            else
            {
                throw new ArgumentException();
            }
        }
Esempio n. 22
0
        public PhotoPage(int albumId)
        {
            InitializeComponent();

            this.viewModel      = new PhotoViewModel(albumId);
            this.BindingContext = this.viewModel;
        }
        public ActionResult Create(HttpPostedFileBase uploadImage, string tags, string name)
        {
            if (ModelState.IsValid && uploadImage != null)
            {
                byte[] imageData = null;

                using (var binaryReader = new BinaryReader(uploadImage.InputStream))
                {
                    imageData = binaryReader.ReadBytes(uploadImage.ContentLength);
                }

                PhotoViewModel photo = new PhotoViewModel()
                {
                    Date     = DateTime.Now,
                    Picture  = imageData,
                    Name     = name,
                    Tags     = new List <TagViewModel>(TagParser(tags)),
                    Ratings  = new List <RatingViewModel>(),
                    UserName = User.Identity.Name
                };
                try
                {
                    _photoService.Create(photo.ToBLLPhoto());
                }
                catch
                {
                    return(RedirectToAction("Error", "Error"));
                }
                RedirectToAction("Index");
            }
            return(View());
        }
Esempio n. 24
0
        public ActionResult Add(PhotoViewModel photoView, HttpPostedFileBase file, int[] tags)
        {
            Photo photo          = new Photo();
            var   supportedTypes = new string[] { "jpg", "jpeg", "png" };
            var   type           = System.IO.Path.GetExtension(file.FileName).ToLower().Replace(".", "");

            if (supportedTypes.Contains(type))
            {
                string delimiter = Guid.NewGuid().ToString();
                string path      = @"\UploadedFile\" + delimiter + "_" + file.FileName;
                photo.Head = photoView.Head;
                foreach (var tag in tags)
                {
                    Tag addedTag = db.Tags.FirstOrDefault(x => x.Id == tag);
                    photo.Tags.Add(addedTag);
                }
                photo.Description = photoView.Description;
                photo.Path        = path;
                photo.DateTime    = DateTime.Now;
                db.Photos.Add(photo);
                db.SaveChanges();
                file.SaveAs(Server.MapPath("~") + path);
                return(RedirectToAction("Index"));
            }
            if (ModelState.IsValid)
            {
                db.Entry(photo).State = System.Data.Entity.EntityState.Added;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View());
        }
Esempio n. 25
0
        public void Add(PhotoViewModel model)
        {
            try
            {
                var photo = new Photo
                {
                    PropertyId   = model.PropertyId,
                    BuildingId   = model.BuildingId,
                    BuildingSeq  = model.BuildingSeq,
                    ImageData    = model.ImageData,
                    ImageName    = model.ImageName,
                    ImageSize    = model.ImageSize,
                    DateTaken    = model.DateTaken,
                    UploadedDate = model.UploadedDate,
                    UploadedBy   = model.UploadedBy,
                    UserId       = model.UserId,
                    MasterPhoto  = model.MasterPhoto,
                    FrontPhoto   = model.FrontPhoto,
                    PublicPhoto  = model.PublicPhoto,
                    Status       = model.Status, // Active, Archived, Deleted, Incomplete, Processing
                    Active       = model.Active
                };

                _context.Photos.Add(photo);

                _context.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            // return GetNewFiles(fileNames);
        }
        public ActionResult Upload(PhotoViewModel addGallery, HttpPostedFileBase file)
        {
            if (string.IsNullOrWhiteSpace(addGallery.PhotoName))
            {
                ModelState.AddModelError("error", "Namnet får inte vara tomt!");
                return(View(addGallery));
            }
            if (file == null || file.ContentLength == 0)
            {
                ModelState.AddModelError("error", "En fil vill jag gärna att du laddar upp!");

                // Vi skickar med model tillbaka så att vi kan få Name förifyllt!
                return(PartialView(addGallery));
            }
            var destination = Server.MapPath("~/GalleryFolder/");

            if (!Directory.Exists(destination))
            {
                Directory.CreateDirectory(destination);
            }
            file.SaveAs(Path.Combine(destination, file.FileName));
            var photo = new Photo
            {
                PhotoId     = Guid.NewGuid(),
                PhotoPath   = file.FileName,
                PhotoName   = addGallery.PhotoName,
                Description = addGallery.Description
            };

            PhotoRepository.Add(photo);
            return(RedirectToAction("List"));
        }
Esempio n. 27
0
 public JsonNetResult Add(PhotoViewModel vm)
 {
     if (ModelState.IsValid)
     {
         if (this.photoTasks.GetPhoto(vm.PhotoName) == null)
         {
             Person person = this.personTasks.GetPerson(vm.PersonId);
             if (person != null)
             {
                 Photo photo = vm.Id > 0 ? this.photoTasks.GetPhoto(vm.Id) : new Photo();
                 if (photo.FileData != null)
                 {
                     photo.PhotoName = vm.PhotoName;
                     photo.FileURL   = vm.FileURL;
                     photo.Notes     = vm.Notes;
                     photo           = this.photoTasks.SavePersonPhoto(person, photo);
                     return(JsonNet(string.Empty));
                 }
                 else
                 {
                     ModelState.AddModelError("FileData", "No photo was uploaded.");
                 }
             }
             else
             {
                 ModelState.AddModelError("Person", "Person not found.");
             }
         }
         else
         {
             ModelState.AddModelError("PhotoName", "Photo name already exists.");
         }
     }
     return(JsonNet(this.GetErrorsForJson()));
 }
Esempio n. 28
0
        //public IActionResult Create(string Title, string Description)

        public IActionResult Create(PhotoViewModel viewModel)
        {
            //azon a controller/action-on ami modelt fogad kötelező a validálás és eredményének ellenőrzése
            //méghozzá a ModellState állapotának ellenőrzése, itt jelenik meg a validálás végeredménye
            if (!ModelState.IsValid)
            {
                //A View-t fel kell készíteni a hibainformációk megjelenítésére
                return(View(viewModel));
            }

            var model = mapper.Map <PhotoModel>(viewModel);

            //Több profil betöltése
            //var autoMapperCfg = new AutoMapper.MapperConfiguration(
            //        cfg => {
            //            cfg.AddProfile(new PhotoProfile());
            //            cfg.AddProfile(new PhotoProfile());
            //            cfg.AddProfile(new PhotoProfile());
            //            cfg.AddProfile(new PhotoProfile());
            //        });



            //viewModel.ContentType = viewModel.PictureFormBrowser.ContentType;
            repository.AddPhoto(model);

            //a kép elmentése után térjen vissza az index oldalra
            return(RedirectToAction("Index"));
        }
        /// <summary>
        /// Adds the photo.
        /// </summary>
        /// <param name="photo">The photo.</param>
        /// <returns></returns>
        public Response <PhotoViewModel> AddPhoto(PhotoViewModel photo)
        {
            string apiUrl   = baseRoute + "addPhoto";
            var    response = communicationManager.Post <PhotoModel, Response <PhotoModel> >(photo.ToModel(), apiUrl);

            return(response.ToViewModel());
        }
        public ActionResult CreatePhoto(PhotoViewModel photo, IEnumerable <HttpPostedFileBase> files, string Id)
        {
            if (!ModelState.IsValid)
            {
                return(View(photo));
            }
            if (files.Count() == 0 || files.FirstOrDefault() == null)
            {
                ViewBag.error = "Please choose a file";
                return(View(photo));
            }

            PhotoViewModel model = new PhotoViewModel();

            foreach (var file in files)
            {
                if (file != null && file.ContentLength > 0)
                {
                    model.Image = Images.GetImageNewSize(file);
                }

                model.Description = photo.Description;
                model.CreatedOn   = DateTime.Now;
                model.CategoryId  = Convert.ToInt32(Id);
                model.UserId      = userService.GetUserByEmail(User.Identity.Name).UserId;
                photoService.CreatePhoto(model.ToBllPhoto());
            }

            return(RedirectToAction("GetPhotoForUser"));
        }
Esempio n. 31
0
 public PhotoView(PhotoViewModel viewModel)
 {
     InitializeComponent();
     this.photoViewModel = viewModel;
     this.DataContext = viewModel;
 }
Esempio n. 32
0
 public Parameter(ObservableCollection<PhotoViewModel> photos, PhotoViewModel selection)
 {
     Photos = new ReadOnlyObservableCollection<PhotoViewModel>(photos);
     Selection = selection;
 }
Esempio n. 33
0
 // GET: Photo
 public ActionResult Photo(int? id)
 {
     PhotoViewModel pvm = new PhotoViewModel();
     pvm.Photos = db.Photos.ToList().FindAll(p => p.DiveId == id);
     return View(pvm);
 }