Пример #1
0
        public ActionResult Index()
        {
            List <Site> sites = new List <Site>();

            try
            {
                sites = this._provider.GetAll();
                ShowSitesViewModel model = new ShowSitesViewModel(sites);
                return(View(model));
            }
            catch (Exception e)
            {
                return(View());
            }
        }
        public ActionResult GetAll(int id)
        {
            var sites = this.siteService.GetForOrganisation(id).
                        ToList().ConvertAll(
                x => new SiteViewModel
            {
                Id   = x.Id,
                Name = x.Name
            });

            var viewModel = new ShowSitesViewModel
            {
                OrganisationId = id,
                Sites          = sites
            };

            return(View(viewModel));
        }
        public ActionResult GetAllPartial()
        {
            var id    = this.userService.GetById(this.User.Identity.GetUserId()).Site.OrganisationId;
            var sites = this.siteService.GetForOrganisation(id).
                        ToList().ConvertAll(
                x => new SiteViewModel
            {
                Id   = x.Id,
                Name = x.Name
            });

            var viewModel = new ShowSitesViewModel
            {
                OrganisationId = id,
                Sites          = sites
            };

            return(PartialView(viewModel));
        }
Пример #4
0
        public ShowSitesViewModel GetSitesVerifyByIdUser(string idUser, int page = 1, string sort = "URL", string sortdir = "ASC")
        {
            int pageSize         = 4;
            ShowSitesViewModel m = new ShowSitesViewModel();
            SiteRepository     siteRepository = new SiteRepository();
            List <SiteEntity>  sitesAvailable = siteRepository.GetAll().Where(x => x.IsActive.Value).ToList();

            m.PageSize    = pageSize;
            m.TotalRecord = (from r in sitesAvailable where r.AspNetUsers_Id.Equals(idUser) && r.Verified == true select r).Count();
            m.NoOfPages   = (m.TotalRecord / m.PageSize) + ((m.TotalRecord % m.PageSize) > 0 ? 1 : 0);
            var ListSitesVerify = (from site in sitesAvailable
                                   orderby(sort + " " + sortdir)
                                   where site.AspNetUsers_Id.Equals(idUser) &&
                                   site.Verified == true
                                   select site).Skip((page - 1) * m.PageSize).Take(m.PageSize).ToList();

            m.ListSitesVerify = ListSitesVerify;
            return(m);
        }
        public ActionResult ChooseSites()
        {
            var sites = this.siteService.GetAll();

            if (!this.IsMegaAdmin())
            {
                var userOrganisation = this.userService.GetUserOrganisationId(this.User.Identity.GetUserId());
                sites = sites.Where(x => x.OrganisationId == userOrganisation).ToList();
            }

            var convertedSites = sites.ToList().ConvertAll(
                x => new SiteViewModel
            {
                Id   = x.Id,
                Name = x.Name
            });

            var viewModel = new ShowSitesViewModel
            {
                Sites = convertedSites
            };

            return(PartialView(viewModel));
        }