Ejemplo n.º 1
0
        public IActionResult AddGallery(int?id)
        {
            GalleryViewModel model = new GalleryViewModel();

            model.CheckInId = id.Value;
            return(View(model));
        }
Ejemplo n.º 2
0
        public GalleryPage()
        {
            InitializeComponent();

            _galleryViewModel  = new GalleryViewModel();
            _settingsViewModel = new SettingsViewModel();
        }
Ejemplo n.º 3
0
        public ActionResult Edit(int id)
        {
            if (!ModelState.IsValid)
            {
                return(HttpNotFound());
            }

            var dbGallery = _galleryRepo.GetGalleryById(id);

            if (dbGallery == null)
            {
                return(HttpNotFound());
            }

            GetSignedUser();
            if (!_signedUser.CanManageAllContent() && !dbGallery.Account.Equals(_signedUser))
            {
                return(RedirectToAction("Index", "Home"));
            }

            var viewModel = new GalleryViewModel
            {
                Gallery              = dbGallery,
                ContentCategories    = _categoryRepo.GetActiveContentCategories(),
                ContentSubCategories = _categoryRepo.GetContentSubcategoriesByParentId(dbGallery.ContentCategory.Id)
            };

            viewModel.Gallery.Pictures = _galleryRepo.GetGalleryPictures(id);

            return(View(viewModel));
        }
Ejemplo n.º 4
0
        public ActionResult DeletePicture(Guid id)
        {
            var picToDelete = _galleryRepo.GetPictureById(id);

            if (picToDelete == null)
            {
                return(HttpNotFound());
            }

            var result = _galleryRepo.DeletePicture(id, User.Identity.Name, Server);

            if (result == DbRepoStatusCode.NotFound)
            {
                return(HttpNotFound());
            }

            if (result == DbRepoStatusCode.BadRequest)
            {
                return(RedirectToAction("Index", "Home"));
            }

            _fileUploadService.DeleteFile(Server, picToDelete.GalleryId.ToString(), picToDelete.FileName);

            var gallery = _galleryRepo.GetGalleryById(picToDelete.GalleryId);

            var viewModel = new GalleryViewModel
            {
                Gallery              = gallery,
                ContentCategories    = _categoryRepo.GetActiveContentCategories(),
                ContentSubCategories = _categoryRepo.GetContentSubcategoriesByParentId(gallery.ContentCategory.Id)
            };

            return(View($"Edit", viewModel));
        }
Ejemplo n.º 5
0
        public ActionResult PictureSaveChanges(Picture picture)
        {
            var result = _galleryRepo.SavePictureChanges(picture, User.Identity.Name);

            if (result == DbRepoStatusCode.NotFound)
            {
                return(HttpNotFound());
            }

            if (result == DbRepoStatusCode.BadRequest)
            {
                return(RedirectToAction("Index", "Home"));
            }

            var gallery = _galleryRepo.GetGalleryById(picture.GalleryId);

            var viewModel = new GalleryViewModel
            {
                Gallery              = gallery,
                ContentCategories    = _categoryRepo.GetActiveContentCategories(),
                ContentSubCategories = _categoryRepo.GetContentSubcategoriesByParentId(gallery.ContentCategory.Id)
            };

            return(View("Edit", viewModel));
        }
Ejemplo n.º 6
0
        public async Task <GalleryViewModel> FetchImagesAsync()
        {
            GalleryViewModel galleryViewModel = new GalleryViewModel();

            galleryViewModel.images = new List <ImageViewModel>();
            try
            {
                BlobContainerClient client = new BlobContainerClient(
                    _configuration.GetValue <string>("Azure:StorageAccount:ConnectionString"),
                    _configuration.GetValue <string>("Azure:StorageAccount:TriggerContainer")
                    );

                await foreach (var blob in client.GetBlobsAsync())
                {
                    string path = client.GetBlockBlobClient(blob.Name).Uri.AbsoluteUri.ToString();
                    string name = _ef.Images.Where(x => x.Path == path).Select(x => x.ImageName).FirstOrDefault();
                    galleryViewModel.images.Add(new ImageViewModel()
                    {
                        ImageName = name, Path = path
                    });
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw;
            }
            return(galleryViewModel);
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Put(string id, [FromBody] GalleryViewModel item)
        {
            await _documentClient.ReplaceDocumentAsync(UriFactory.CreateDocumentUri(databaseId, collectionId, id),
                                                       item);

            return(Ok());
        }
Ejemplo n.º 8
0
        public Reply GetGallery([FromUri] GalleryViewModel model)
        {
            Reply oR = new Reply();

            oR.result = 0;

            try
            {
                using (cursomvcapiEntities db = new cursomvcapiEntities())
                {
                    List <ListGalleryViewModel> lst = (from a in db.Storage
                                                       where a.id_identificador == model.id
                                                       select new ListGalleryViewModel
                    {
                        id = a.id_galeria,
                        foto = a.foto,
                        name = a.foto_name
                    }).ToList();



                    oR.data   = lst;
                    oR.result = 1;
                }
            }
            catch (Exception exp)
            {
                oR.message = "ocurrio un error en el servidor";
            }

            return(oR);
        }
Ejemplo n.º 9
0
        public async Task <ActionResult> Delete(GalleryViewModel model)
        {
            try
            {
                if (!await APIProvider.Authorization(_userSession.BearerToken, ARS.Delete))
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.FuntionType.Article, APIConstant.ACTION_DELETE);
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(PartialView("_Delete", model));
                }
            }
            catch (HttpException ex)
            {
                Logger.LogError(ex);
                int statusCode = ex.GetHttpCode();
                if (statusCode == 401)
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(FuntionType.Department, APIConstant.ACTION_ACCESS);
                    return(new HttpUnauthorizedResult());
                }

                throw ex;
            }
        }
Ejemplo n.º 10
0
        public async Task <ActionResult> Delete(string id)
        {
            try
            {
                var model = new GalleryViewModel();
                model.Id = id;

                //Call API Provider
                string strUrl = APIProvider.APIGenerator(controllerName, APIConstant.ACTION_DELETE);
                var    result = await APIProvider.Authorize_DynamicTransaction <GalleryViewModel, bool>(model, _userSession.BearerToken, strUrl, APIConstant.API_Resource_CMS, ARS.Get);

                if (result)
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.SUCCESS, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_DELETE, ApplicationGenerator.TypeResult.SUCCESS));
                }
                else
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_DELETE, ApplicationGenerator.TypeResult.FAIL));
                }

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);
                return(RedirectToAction("Index"));
            }
        }
Ejemplo n.º 11
0
        public ActionResult Preview(Guid id, string type)
        {
            var model = new GalleryViewModel();


            LoadLanguage(model);

            if (type == typeof(Photo).FullName)
            {
                model.Photo = Session.Query <Photo>().Where(x => x.Id == id).FirstOrDefault();

                if (model.Photo == null)
                {
                    return(Redirect("/"));
                }
            }
            else if (type == typeof(Video).FullName)
            {
                model.Video = Session.Query <Video>().Where(x => x.Id == id).FirstOrDefault();

                if (model.Video == null)
                {
                    return(Redirect("/"));
                }
            }

            return(View(model));
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending += OnSuspending;

            GalleryViewModel.Instance(new ImageCreator());
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Gallery gallery = _context.Galleries.Find(id);


            var images =
                from image in _context.Images
                join imgGallery in _context.ImageGalleries on image.ImageId equals imgGallery.ImageId
                join galleries in _context.Galleries on imgGallery.GalleryId equals galleries.GalleryId
                where imgGallery.GalleryId == id
                orderby imgGallery.Order
                select image;

            var imgGalleries = _context.ImageGalleries.Where(d => d.GalleryId == id).OrderBy(d => d.Order).ToList();

            var model = new GalleryViewModel()
            {
                Images         = images.ToList(),
                Gallery        = gallery,
                ImageGalleries = imgGalleries
            };

            if (gallery == null)
            {
                return(HttpNotFound());
            }
            return(View(model));
        }
Ejemplo n.º 14
0
        public IHttpActionResult AddGallery([FromUri] GalleryViewModel model)
        {
            string foldercrate = HttpContext.Current.Server.MapPath("~/images/");

            if (!Directory.Exists(foldercrate))
            {
                Directory.CreateDirectory(foldercrate);
            }

            if (HttpContext.Current.Request.Files.AllKeys.Any())
            {
                var fileupload = HttpContext.Current.Request.Files["Imgpathsave"];
                if (fileupload != null)
                {
                    var saveimages = Path.Combine(HttpContext.Current.Server.MapPath("~/images/"), fileupload.FileName);
                    fileupload.SaveAs(saveimages);

                    cursomvcapiEntities cm = new cursomvcapiEntities();
                    cm.Storage.Add(new Storage
                    {
                        foto             = saveimages.ToString(),
                        foto_name        = fileupload.FileName.ToString(),
                        id_identificador = model.id
                    });
                    cm.SaveChanges();
                }
            }
            return(Ok());
        }
Ejemplo n.º 15
0
 public GalleryView(GalleryViewModel galleryViewModel)
 {
     InitializeComponent();
     DataContext = galleryViewModel;
     ViewModel   = galleryViewModel;
     Logging.Analytics.TrackScreenView("Gallery");
 }
        public async Task <Guid> SaveParticipantGalleryVideo(string sessionToken, GalleryViewModel model)
        {
            var data1 = 0;

            using (var db = new ConquerorHubEntities())
            {
                var result = new CH_ParticipantsGallery()
                {
                    Id          = model.GalleryData.Id,
                    ImageData   = model.GalleryData.ImageData,
                    Caption     = model.GalleryData.Caption,
                    UserId      = model.GalleryData.UserId,
                    PostId      = model.GalleryData.PostId,
                    VideoData   = model.GalleryData.VideoData,
                    ContentType = model.GalleryData.ContentType,
                    DateAndTime = DateTime.UtcNow,
                    FileName    = Path.GetFileName(model.GalleryData.UploadedPost.FileName)
                };


                try
                {
                    db.CH_ParticipantsGallery.Add(result);

                    data1 = db.SaveChanges();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                return(await Task.FromResult(Guid.NewGuid()));
            }
        }
Ejemplo n.º 17
0
        public async Task <IActionResult> Index([FromForm] GalleryViewModel model)
        {
            var user = GetUser();

            if (model == null)
            {
                model = new GalleryViewModel()
                {
                    User = user, RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier
                };
            }

            if (!string.IsNullOrEmpty(user))
            {
                var client = new ImageGalleryClient(new HttpClient(), ImageGalleryServiceUrl);
                var list   = await client.GetNextImageListAsync(user, model.Continuation);

                if (list != null)
                {
                    model.Images       = list.Names;
                    model.Continuation = list.ContinuationId;
                }
            }

            var result = View(model);

            result.ViewData["User"] = user;
            return(result);
        }
Ejemplo n.º 18
0
        public IActionResult CreateGallery(int id, GalleryViewModel viewModel)
        {
            if (viewModel.Img != null)
            {
                if (Path.GetExtension(viewModel.Img.FileName) != ".jpg")
                {
                    ModelState.AddModelError("Img", "فایل با پسوند jpg بارگزاری شود");
                }
                else
                {
                    string filePath = "";
                    viewModel.ImgName = CodeGenerators.FileCode() + Path.GetExtension(viewModel.Img.FileName);
                    filePath          = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/images/galleries/", viewModel.ImgName);

                    using (var stream = new FileStream(filePath, FileMode.Create))
                    {
                        viewModel.Img.CopyTo(stream);
                    }

                    ProductGallery productGallery = new ProductGallery()
                    {
                        ProductId = id,
                        Img       = viewModel.ImgName
                    };

                    _store.AddGallery(productGallery);
                }
            }

            ViewBag.MyId = id;
            return(View());
        }
Ejemplo n.º 19
0
 public static void Init(MainViewModel mainViewModel, HomeViewModel homeViewModel,
                         LoginViewModel loginViewModel, RegisterViewModel registerViewModel, SettingViewModel settingViewModel,
                         GalleryViewModel galleryViewModel, TaskManagerViewModel taskManagerViewModel, ManagerPassViewModel managerPassViewModel)
 {
     instance = new ViewModelContainer(mainViewModel, homeViewModel, loginViewModel, registerViewModel, settingViewModel,
                                       galleryViewModel, taskManagerViewModel, managerPassViewModel);
 }
        public ActionResult ParticipantVideoGallery(GalleryViewModel model)
        {
            byte[] bytes1;
            using (BinaryReader br = new BinaryReader(model.GalleryData.UploadedPost.InputStream))
            {
                bytes1 = br.ReadBytes(model.GalleryData.UploadedPost.ContentLength);
            }
            try {
                model.GalleryData.PostId = Guid.NewGuid();
                model.GalleryData.UserId = User.Identity.GetUserId();
                model.GalleryData.Id     = Guid.NewGuid();
                var    filename  = Path.GetFileName(model.GalleryData.UploadedPost.FileName);
                string extension = filename.Split('.').Last();
                model.GalleryData.VideoData   = bytes1;
                model.GalleryData.ContentType = extension;

                OrganiserBasicDetailsServices organizerBasicdetail = new OrganiserBasicDetailsServices();
                var result = organizerBasicdetail.SaveParticipantGalleryVideo(SessionToken, model);
            }
            catch (Exception ex)
            {
                return(View("~/Views/Errorpage/Errorpage.cshtml"));
            }

            return(RedirectToAction("ParticipantVideoGallery", "Participants"));
        }
Ejemplo n.º 21
0
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var gallery = await _context.Galleries.FindAsync(id);

            if (gallery == null)
            {
                return(NotFound());
            }

            var images =
                from image in _context.Images
                join imgGallery in _context.ImageGalleries on image.ImageId equals imgGallery.ImageId
                join galleries in _context.Galleries on imgGallery.GalleryId equals galleries.GalleryId
                where imgGallery.GalleryId == id
                orderby imgGallery.Order
                select image;

            var imgGalleries = _context.ImageGalleries.Where(d => d.GalleryId == id).OrderBy(d => d.Order).ToList();

            var model = new GalleryViewModel()
            {
                Images         = images.ToList(),
                Gallery        = gallery,
                ImageGalleries = imgGalleries
            };

            return(View(model));
        }
Ejemplo n.º 22
0
        public IActionResult Index(string tag, int page = 1)
        {
            var viewModel = new GalleryViewModel();

            viewModel.Tags = new List <string>(this.tagsService.GetAllNames());

            int count;

            if (tag == null || tag == "all")
            {
                viewModel.Images = this.imagesService.GetAllImagesInGallery <ImageInGalleryViewModel>(page);
                count            = this.imagesService.GetCountAllImagesInGallery();
            }
            else
            {
                viewModel.Images = this.imagesService.GetAllImagesByTagInGallery <ImageInGalleryViewModel>(page, tag);
                count            = this.imagesService.GetCountAllImagesByTagInGallery(tag);
            }

            viewModel.Page = new Page
            {
                CurrPage   = page,
                CurrTag    = tag ?? "all",
                TotalPages = (int)Math.Ceiling(count / 6.0),
            };

            return(this.View(viewModel));
        }
Ejemplo n.º 23
0
        public ActionResult UploadPictures(Gallery gallery)
        {
            ModelState.Clear();

            var result = _galleryRepo.SaveNewPictures(gallery, User.Identity.Name, Request, Server);

            if (result == DbRepoStatusCode.NotFound)
            {
                return(HttpNotFound());
            }

            if (result == DbRepoStatusCode.BadRequest)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            if (result == DbRepoStatusCode.PartialSuccess)
            {
                ModelState.AddModelError("", $"One or more files upload failed due to filename conflict");
            }

            var viewModel = new GalleryViewModel
            {
                Gallery              = _galleryRepo.GetGalleryById(gallery.Id),
                ContentCategories    = _categoryRepo.GetActiveContentCategories(),
                ContentSubCategories = _categoryRepo.GetContentSubcategoriesByParentId(gallery.ContentCategory.Id)
            };

            return(View("Edit", viewModel));
        }
Ejemplo n.º 24
0
        public ActionResult Gallery()
        {
            GalleryViewModel gallery = new GalleryViewModel();

            gallery._gallery = db.Galleries.ToList();
            return(View(gallery));
        }
Ejemplo n.º 25
0
        public void Activate()
        {
            Window window = NUIApplication.GetDefaultWindow();

            var myViewModelSource = new GalleryViewModel(itemCount);

            selMode = ItemSelectionMode.SingleSelection;
            DefaultTitleItem myTitle = new DefaultTitleItem();

            myTitle.Text = "Linear Sample Count[" + itemCount + "]";
            //Set Width Specification as MatchParent to fit the Item width with parent View.
            myTitle.WidthSpecification = LayoutParamPolicies.MatchParent;

            colView = new CollectionView()
            {
                ItemsSource   = myViewModelSource,
                ItemsLayouter = new LinearLayouter(),
                ItemTemplate  = new DataTemplate(() =>
                {
                    var rand = new Random();
                    RecyclerViewItem item    = new RecyclerViewItem();
                    item.WidthSpecification  = LayoutParamPolicies.MatchParent;
                    item.HeightSpecification = 100;
                    item.BackgroundColor     = new Color((float)rand.NextDouble(), (float)rand.NextDouble(), (float)rand.NextDouble(), 1);

                    /*
                     * DefaultLinearItem item = new DefaultLinearItem();
                     * //Set Width Specification as MatchParent to fit the Item width with parent View.
                     * item.WidthSpecification = LayoutParamPolicies.MatchParent;
                     * //Decorate Label
                     * item.Label.SetBinding(TextLabel.TextProperty, "ViewLabel");
                     * item.Label.HorizontalAlignment = HorizontalAlignment.Begin;
                     * //Decorate Icon
                     * item.Icon.SetBinding(ImageView.ResourceUrlProperty, "ImageUrl");
                     * item.Icon.WidthSpecification = 80;
                     * item.Icon.HeightSpecification = 80;
                     * //Decorate Extra RadioButton.
                     * //[NOTE] This is sample of RadioButton usage in CollectionView.
                     * // RadioButton change their selection by IsSelectedProperty bindings with
                     * // SelectionChanged event with SingleSelection ItemSelectionMode of CollectionView.
                     * // be aware of there are no RadioButtonGroup.
                     * item.Extra = new RadioButton();
                     * //FIXME : SetBinding in RadioButton crashed as Sensitive Property is disposed.
                     * //item.Extra.SetBinding(RadioButton.IsSelectedProperty, "Selected");
                     * item.Extra.WidthSpecification = 80;
                     * item.Extra.HeightSpecification = 80;
                     */

                    return(item);
                }),
                Header              = myTitle,
                ScrollingDirection  = ScrollableBase.Direction.Vertical,
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.MatchParent,
                SelectionMode       = selMode
            };
            colView.SelectionChanged += SelectionEvt;

            window.Add(colView);
        }
        //dependency injection container
        protected override void OnStartup(StartupEventArgs e)
        {
            // dependenies
            FrameSourceService frameSourceService = new FrameSourceService();
            InvokerService     invokerService     = new InvokerService();
            AuthService        authService        = new AuthService();

            // viewModels
            MainViewModel        mainViewModel        = new MainViewModel(frameSourceService, invokerService);
            HomeViewModel        homeViewModel        = new HomeViewModel(frameSourceService, invokerService);
            LoginViewModel       loginViewModel       = new LoginViewModel(frameSourceService, invokerService, authService);
            RegisterViewModel    registerViewModel    = new RegisterViewModel(frameSourceService, invokerService, authService);
            SettingViewModel     settingViewModel     = new SettingViewModel(frameSourceService, invokerService, authService);
            GalleryViewModel     galleryViewModel     = new GalleryViewModel(frameSourceService, invokerService, authService);
            TaskManagerViewModel taskManagerViewModel = new TaskManagerViewModel(frameSourceService, invokerService, authService);
            ManagerPassViewModel managerPassViewModel = new ManagerPassViewModel(frameSourceService, invokerService, authService);

            // singleton
            ViewModelContainer.Init(mainViewModel, homeViewModel, loginViewModel, registerViewModel,
                                    settingViewModel, galleryViewModel, taskManagerViewModel, managerPassViewModel);

            invokerService.Invoke <MainViewModel>(new InitializationViewModel());

            base.OnStartup(e);
        }
Ejemplo n.º 27
0
 private static async Task GetItemDataForGallery(GalleryViewModel gallery, string surl)
 {
     foreach (var galleryItemInfo in gallery.Items)
     {
         galleryItemInfo.GoodItemData = await GetItemData(surl, galleryItemInfo.ItemId);
     }
 }
Ejemplo n.º 28
0
        public IHttpActionResult AddImg([FromUri] GalleryViewModel model)
        {
            string foldercrate = HttpContext.Current.Server.MapPath("~/images/");

            if (!Directory.Exists(foldercrate))
            {
                Directory.CreateDirectory(foldercrate);
            }

            if (HttpContext.Current.Request.Files.AllKeys.Any())
            {
                var fileupload = HttpContext.Current.Request.Files["Imgpathsave"];
                if (fileupload != null)
                {
                    var saveimages = Path.Combine(HttpContext.Current.Server.MapPath("~/images/"), fileupload.FileName);
                    fileupload.SaveAs(saveimages);

                    cursomvcapiEntities cm = new cursomvcapiEntities();

                    var query = (from a in cm.Contenido
                                 where a.id == model.id
                                 select a).FirstOrDefault();
                    query.picture      = saveimages.ToString();
                    query.name_picture = fileupload.FileName.ToString();
                    cm.SaveChanges();
                }
            }
            return(Ok());
        }
Ejemplo n.º 29
0
        public ActionResult Create(GalleryViewModel model)
        {
            var pic = new PictureViewModel();

            pic.GalleryID = model.id;
            return(View(pic));
        }
        public ActionResult Edit(GalleryViewModel gallery, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                var photoUrl = Upload(file);
                gallery.PhotoUrl = photoUrl.Substring(1, photoUrl.Length - 2);

                var client   = GlobalWebApiClient.GetClient();
                var response = client.PutAsJsonAsync("api/galleries/update/", gallery).Result;
                try
                {
                    if (response.IsSuccessStatusCode)
                    {
                        gallery = response.Content.ReadAsAsync <GalleryViewModel>().Result;
                        TempData["SuccessMessage"] = "Gallery updated successfully";
                        return(RedirectToAction("Details", gallery));
                    }
                }
                catch (Exception ex)
                {
                    var result = ex.Message;
                }
            }
            else
            {
                ModelState.AddModelError(string.Empty, "Server Error. Please contact administrator.");
            }
            return(View(gallery));
        }
Ejemplo n.º 31
0
        public ActionResult Gallery(int id, int? pictureId)
        {
            var contest = this.Data.Contests.Find(id);
            if (contest == null)
            {
                HttpResponseMessage message = new HttpResponseMessage(HttpStatusCode.NotFound);
                message.Content = new StringContent(Messages.ContestNotFound);
                throw new System.Web.Http.HttpResponseException(message);
            }

            if (contest.Pictures.Count() == 0)
            {
                return this.View(new GalleryViewModel() { CurrentPicture = null });
            }

            if (pictureId == null)
            {
                pictureId = contest.Pictures.FirstOrDefault().Id;
            }

            var picture = contest.Pictures.FirstOrDefault(p => p.Id == pictureId);
            if (picture == null)
            {
                HttpResponseMessage message = new HttpResponseMessage(HttpStatusCode.Unauthorized);
                message.Content = new StringContent(Messages.NoSuchPictureInContest);
                throw new System.Web.Http.HttpResponseException(message);
            }
            var pictureModel = Mapper.Map<DetailsPictureViewModel>(picture);

            var user = this.Data.Users.Find(this.User.Identity.GetUserId());

            pictureModel.CanBeDeleted = PictureUtills.IsAuthor(user, picture) || this.User.IsInRole("Administrator");
            pictureModel.CanBeRemoved = pictureModel.CanBeDeleted;
            pictureModel.CanBeVoted = PictureUtills.CanVoteForPicture(user, picture, contest);
            pictureModel.ContestId = id;
            pictureModel.VotesCount = picture.Votes.Where(v => v.ContestId == id).Count();

            var idList = contest.Pictures.OrderBy(p => p.Id).Select(p => p.Id).ToList();
            int? previousPictureId = null;
            int? nextPictureId = null;

            int currentPictureIndex = 0;
            for (int i = 0; i < idList.Count; i++)
            {
                if (idList[i] == pictureId)
                {
                    currentPictureIndex = i;
                    previousPictureId = i == 0 ? (int?)null : idList[i - 1];
                    nextPictureId = i == idList.Count - 1 ? (int?)null : idList[i + 1];
                    break;
                }
            }

            var galleryModel = new GalleryViewModel()
            {
                ContestId = contest.Id,
                PicturesCount = idList.Count,
                CurrentPictureIndex = currentPictureIndex,
                PreviousPictureId = previousPictureId,
                NextPictureId = nextPictureId,
                CurrentPicture = pictureModel,
            };

            return this.View(galleryModel);
        }
Ejemplo n.º 32
0
		private GlobalViewModel()
		{
			Presenter = new UPnPPresenter
							{
								TitlesExcludedFromImageReplacement = Settings.Default.Excluded_Folder_Names,
								ImageWidth = 160,
								ImageHeight = 100,
								EnableDetailsPage = true
							};

			DebugMessage = string.Empty;
			Presenter.ParseBegin += OnParseBegin;
			Presenter.ParseEnd += OnParseEnd;

			GalleryViewModel = new GalleryViewModel();
			GalleryViewModel.ExecuteInUIThread += OnExecuteInUIThread;
			PlaybackViewModel = new PlaybackViewModel();
			PlaybackViewModel.ExecuteInUIThread += OnExecuteInUIThread;

			NavigationCommandList = new ObservableCollection<RoutedCommand>
			                        	{
			                        		AppNavigationCommands.BuyNowCommand,
											AppNavigationCommands.GoToSettingsCommand,
											AppNavigationCommands.GoToSupportCommand,
			                        	};

			Downloads = new ObservableCollection<Download>();
			Favorites = new ObservableCollection<Favorite>();
			PlaylistPaths = new ObservableCollection<PlaylistPath>();

			DataModel = new UtilityDataModel(UtilityDataModel.ConnectionString);
			DataModel.SavedChanges += (sender, args) => RefreshData();

			foreach (var download in DataModel.Downloads)
			{
				Downloads.Add(download);
			}

			foreach (var favorite in DataModel.Favorites)
			{
				Favorites.Add(favorite);
			}

			foreach (var playlistPath in PlaylistPaths)
			{
				PlaylistPaths.Add(playlistPath);
			}

			Launcher.Fire(() =>
							{
								while (!Done)
								{
									Thread.Sleep(3000);
									RefreshData();
								}
							});

			_commandSink = new CommandSink();

			#region currently not used

			_commandSink.RegisterCommand(_copyUrlCommand, CanExecuteCopyUrlCommand, ExecuteCopyUrlCommand);
			_commandSink.RegisterCommand(GoBackCommand, CanExecuteGoBackCommand, ExecuteGoBackCommand);
			_commandSink.RegisterCommand(GoHomeCommand, CanExecuteGoHomeCommand, ExecuteGoHomeCommand);
			_commandSink.RegisterCommand(GalleryCommand, CanExecuteGalleryCommand, ExecuteGalleryCommand);
			_commandSink.RegisterCommand(PlaybackCommand, CanExecutePlaybackCommand, ExecutePlaybackCommand);
			_commandSink.RegisterCommand(_goToPageCommand, CanExecuteGoToPageCommand, ExecuteGoToPageCommand);

			#endregion

			//_commandSink.RegisterCommand(AppNavigationCommands.GoToFavoritesCommand, CanExecuteGoToFavoritesCommand, ExecuteGoToFavoritesCommand);
			//_commandSink.RegisterCommand(AppNavigationCommands.GoToDownloadsCommand, CanExecuteGoToDownloadsCommand, ExecuteGoToDownloadsCommand);
			_commandSink.RegisterCommand(AppNavigationCommands.GoToSupportCommand, CanExecuteGoToSupportCommand, ExecuteGoToSupportCommand);
			_commandSink.RegisterCommand(AppNavigationCommands.GoToSettingsCommand, CanExecuteGoToSettingsCommand, ExecuteGoToSettingsCommand);
			_commandSink.RegisterCommand(AppNavigationCommands.BuyNowCommand, CanExecuteBuyNowCommand, ExecuteBuyNowCommand);

			_commandSink.RegisterCommand(AppNavigationCommands.FavoriteCommand, CanExecuteFavoriteCommand, ExecuteFavoriteCommand);
			_commandSink.RegisterCommand(AppNavigationCommands.DownloadCommand, CanExecuteDownloadCommand, ExecuteDownloadCommand);
			_commandSink.RegisterCommand(AppNavigationCommands.PlaylistCommand, CanExecutePlaylistCommand, ExecutePlaylistCommand);

			ReplacementPlaybackExtension = DefaultReplacementPlaybackExtension;
			ReplacePlaybackExtension = Settings.Default.ForceWmvPlayback;
			ShowNavigationZone = Settings.Default.ShowNavigationZone;
			ShowFeedbackZone = Settings.Default.ShowFeedbackZone;
			ShowTitleZone = Settings.Default.ShowTitleZone;
		}
Ejemplo n.º 33
0
		private void Initialization()
		{
			SetupLogging();
			if (Helper.InDesignerMode)
			{
				DebugMessage = "Mockup Mode";
				Presenter = new MockPresenter(Page.ePageType.AVItemCollectionGallery, Settings.Default.Excluded_Folder_Names);
			}
			else
			{
				Presenter = new UPnPPresenter
								{
									TitlesExcludedFromImageReplacement = Settings.Default.Excluded_Folder_Names,
									ImageWidth = Settings.Default.DefaultImageWidth,
									ImageHeight = Settings.Default.DefaultImageHeight,
									EnableDetailsPage = true,
								};
				DebugMessage = string.Empty;
			}
			Presenter.ParseBegin += OnParseBegin;
			Presenter.ParseEnd += OnParseEnd;

			GalleryViewModel = new GalleryViewModel(_commandSink);
			GalleryViewModel.ExecuteInUIThread += OnExecuteInUIThread;
			PlaybackViewModel = new PlaybackViewModel(_commandSink);
			PlaybackViewModel.ExecuteInUIThread += OnExecuteInUIThread;

			CommandsEnabled = true;

			NavigationCommandList = new ObservableCollection<RoutedCommand>
			                        	{
			                        		AppNavigationCommands.BuyNowCommand,
			                        		AppNavigationCommands.GoToSettingsCommand,
			                        		AppNavigationCommands.GoToSupportCommand,
			                        	};

			//Downloads = new ObservableCollection<Download>();
			//Favorites = new ObservableCollection<Favorite>();
			//PlaylistPaths = new ObservableCollection<PlaylistPath>();

			DataModel = UtilityDataModel.NewContext();
			DataModel.SavedChanges += (sender, args) => RefreshData(null);

			if (!Helper.InDesignerMode)
			{
				StartDataRefresher();
			}

			ReplacementPlaybackExtension = DefaultReplacementPlaybackExtension;
			ReplacePlaybackExtension = Settings.Default.ForceWmvPlayback;
			ShowNavigationZone = Settings.Default.ShowNavigationZone;
			ShowFeedbackZone = Settings.Default.ShowFeedbackZone;
			ShowTitleZone = Settings.Default.ShowTitleZone;

			_commandSink = new CommandSink();
			RegisterCommands();
			CommandsReceived = new ObservableCollection<RoutedCommand>();
			Presenter.PropertyChanged += (o, e) =>
											{
												if (e.PropertyName == "ActivePageType")
												{
													_activePageType = Presenter.ActivePageType;
													OnPropertyChanged("ActivePageType");
												}
											};
		}