public async Task <IActionResult> Contents(int page = 0)
        {
            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
            }
            if (page < 0)
            {
                page = 0;
            }
            var totalCount = _dbContext.Contents.Count(c => c.EaUserId == user.Id);

            if (page > totalCount / 6)
            {
                page = totalCount / 6;
            }
            var model = new ContentsViewModel
            {
                Contents   = _dbContext.Contents.Skip(page * 6).Take(6).Where(c => c.EaUserId == user.Id).ToList(),
                LocPage    = page,
                TotalCount = totalCount
            };

            return(View("UserContents", model));
        }
Exemple #2
0
        private ContentsViewModel GetContentsViewModel()
        {
            var items          = _contentsRepo.GetAllItems().ToList();
            var usedCategories = items.GroupBy(i => i.Category).Select(grouped => new UsedCategoryViewModel
            {
                CategoryId    = grouped.Key.Id,
                CategoryName  = grouped.Key.Name,
                CategoryTotal = grouped.Sum(i => i.Price).ToString("C2", CultureInfo.CurrentCulture),
                Items         = grouped.Select(i => new ItemViewModel
                {
                    Id    = i.Id,
                    Name  = i.Name,
                    Price = i.Price.ToString("C2", CultureInfo.CurrentCulture)
                })
            });
            var model = new ContentsViewModel
            {
                Categories = _contentsRepo.GetAllCategories()
                             .Select(c => new CategoryViewModel {
                    Id = c.Id, Name = c.Name
                }),
                UsedCategories = usedCategories.OrderBy(c => c.CategoryId),
                Total          = items.Sum(i => i.Price).ToString("C2", CultureInfo.CurrentCulture)
            };

            return(model);
        }
Exemple #3
0
        // GET: Beacons/Edit/5
        //[Authorize]
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Beacon            beacon            = db.Beacons.Find(id);
            ContentsViewModel contentsViewModel = new ContentsViewModel();

            contentsViewModel.Contents      = PopulateContentDropDown();
            contentsViewModel.Notifications = PopulateNotificationDropDown();

            if (beacon.Notification != null)
            {
                contentsViewModel.SelectedNotificationID = beacon.Notification.ID.ToString();
            }

            if (beacon.Content != null)
            {
                contentsViewModel.SelectedContentID = beacon.Content.ID.ToString();
            }

            contentsViewModel.BeaconID = beacon.Id;

            if (contentsViewModel == null)
            {
                return(HttpNotFound());
            }
            return(View(contentsViewModel));
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            _model           = new ContentsViewModel(this.GetProgressIndicator(), Dispatcher);
            this.DataContext = _model;

            _model.LoadPath("/");
        }
        public virtual ActionResult Index(int page = 1)
        {
            if (!IsModulActive(ContentType))
            {
                return(HttpNotFound("Not Found"));
            }

            ContentsViewModel resultModel = ContentService2.GetContentIndexPage(page, ContentType);

            return(View(resultModel));
        }
Exemple #6
0
        public ActionResult Index(string id)
        {
            var rctx        = ProtoCmsRuntimeContext.Current;
            var contentType = FindContentType(id);

            CheckUserHasPermissionToListContent(contentType, rctx);
            var mdl = new ContentsViewModel {
                ContentType = contentType
            };

            return(View(mdl));
        }
Exemple #7
0
        public ActionResult Contents(string contentTypeFullName, CultureInfo culture = null)
        {
            var viewModel = new ContentsViewModel();

            if (!contentTypeFullName.IsNullOrEmpty())
            {
                viewModel.Contents    = _reflectionContentManager.LoadContentsByContentType(contentTypeFullName, 10);
                viewModel.ContentType = _reflectionContentManager.LoadContentType(contentTypeFullName);
                viewModel.Culture     = culture ?? _cultureManager.GetDefaultCulture(); //TODO : Faire la différence entre ContentManagementCulture & UICulture!!!
            }

            return(View(viewModel));
        }
Exemple #8
0
        public ContentsViewModel GetContentIndexPage(int page, String contentType)
        {
            var resultModel = new ContentsViewModel();

            resultModel.SStore = MyStore;
            var m = ContentRepository.GetContentsCategoryId(MyStore.Id, null, contentType, true, page, 24);

            resultModel.SContents    = new PagedList <Content>(m.items, m.page - 1, m.pageSize, m.totalItemCount);
            resultModel.SCategories  = CategoryRepository.GetCategoriesByStoreId(MyStore.Id, contentType, true);
            resultModel.Type         = contentType;
            resultModel.SNavigations = NavigationRepository.GetStoreActiveNavigations(this.MyStore.Id);
            resultModel.SSettings    = this.GetStoreSettings();

            return(resultModel);
        }
        public async Task <IViewComponentResult> InvokeAsync(Guid ProductId, Guid clientId, Guid policyId)
        {
            var contents = await _context.Contents
                           .Include(a => a.Policy)
                           .Include(a => a.ResidenceType)
                           .Include(a => a.WallType)
                           .Include(a => a.RoofType)
                           .AsNoTracking()
                           .Where(a => a.PolicyID == policyId)
                           .OrderBy(c => c.Location).ToListAsync();

            ContentsViewModel viewModel = new ContentsViewModel
            {
                ProductID = ProductId,
                ClientID  = clientId,
                PolicyID  = policyId,
                Contents  = contents
            };

            return(View(viewModel));
        }
Exemple #10
0
        public ActionResult Edit([Bind(Include = "BeaconID,SelectedContentID,SelectedNotificationID")] ContentsViewModel contentsViewModel)
        {
            int NotificationId = Convert.ToInt32(contentsViewModel.SelectedNotificationID);

            contentsViewModel.Contents      = PopulateContentDropDown();
            contentsViewModel.Notifications = PopulateNotificationDropDown();
            Beacon       beacon       = db.Beacons.Find(contentsViewModel.BeaconID);
            Content      content      = db.Contents.Find(Guid.Parse(contentsViewModel.SelectedContentID));
            Notification notification = db.Notifications.Find(NotificationId);

            beacon.Content      = content;
            beacon.Notification = notification;

            if (ModelState.IsValid)
            {
                db.Entry(beacon).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(contentsViewModel));
        }
Exemple #11
0
 public ContentsPage()
 {
     InitializeComponent();
     BindingContext = viewModel = new ContentsViewModel();
 }