Example #1
0
        public ActionResult AddComment(Guid id)
        {
            var photo = photoRepo.GetPhoto(id);
            var p     = PhotoModelMapper.ModelToEntity(photo);

            return(PartialView("AddComment", p));
        }
Example #2
0
        public ActionResult ShowPhoto(Guid id)
        {
            var showphotos = photorepo.GetPhoto(id);
            var showphot   = PhotoModelMapping.ModelToEntity(showphotos);

            return(PartialView(showphot));
        }
Example #3
0
        public async void NextAction(ITelegramBotClient _bot, MessageEventArgs args)
        {
            Random          rnd    = new Random();
            var             app    = _users.GetById(rnd.Next(0, _users.Count()));
            PhotoRepository pr     = new PhotoRepository();
            var             photos = pr.GetPhotosByUser(app);
            var             fs     = new MemoryStream();

            fs.Read(pr.GetPhoto(app.photos[0]));
            await _bot.SendPhotoAsync(args.Message.Chat.Id, fs);

            //AppUser temp = _users.GetById(index);
            //File file = new File(temp.photos[0].GetPhysicalName);
            //await _bot.SendPhotoAsync(args.Message.Chat.Id,);

            index++;
        }
        public ActionResult GetPhoto(int id)
        {
            byte[] imageData = _repository.GetPhoto(id, PhotoType.Full);

            return(File(imageData, "image/jpg"));
        }
Example #5
0
        public ActionResult Details(int Id)
        {
            PhotoDetailsViewModel model = EFMapper.EntityToModel(photoRepo.GetPhoto(Id));

            using (PhotoExplorerEntities cx = new PhotoExplorerEntities())
            {
                foreach (var user in cx.Users)
                {
                    foreach (var album in user.Albums)
                    {
                        foreach (var photo in album.Photos)
                        {
                            if (photo.Id == Id)
                            {
                                model.User = user;
                                break;
                            }
                        }
                    }
                }
            }

            #region notused
            ////todo: retrieve this photos uploader
            //#region retrieve photo to show
            //PhotoDetailsViewModel model = null;

            //using (PhotoExplorerEntities cx = new PhotoExplorerEntities())
            //{
            //    PhotoEntityModel entity = cx.Photos
            //        .Where(p => p.Id == Id)
            //        .FirstOrDefault();

            //    ///todo: make this more effective..
            //    #region retrieve uploader of photoentity
            //    UserEntityModel photoOwnerEntity = null;
            //    foreach (var user in cx.Users)
            //    {
            //        foreach (var album in user.Albums)
            //        {
            //            foreach (var photo in album.Photos)
            //            {
            //                if (photo.Id == Id)
            //                {
            //                    photoOwnerEntity = user;
            //                    break;
            //                }
            //            }
            //        }
            //    }
            //    #endregion


            //    model = new PhotoDetailsViewModel()
            //    {
            //        Id = entity.Id,
            //        Name = entity.Name,
            //        FileName = entity.FileName,
            //        DateCreated = entity.DateCreated,
            //        DateChanged = entity.DateChanged,
            //        Album = entity.Album,
            //        Comments = entity.Comments, //due to us already having the model collection initialized in the photodetailsviewmodel class, we only have to transfer the collection VALUES from the entity collection to the model collection.
            //        Description = entity.Description,
            //        User = photoOwnerEntity,
            //    };
            //}
            //#endregion
            #endregion

            return(View("Details", model));
        }