Exemplo n.º 1
0
        public async Task <ActionResult> Index()
        {
            try
            {
                var helpInfoTiles = await this.helpDataProvider.GetHelpTilesAsync();

                this.telemetryClient.TrackTrace("help info tiles are found");

                if (helpInfoTiles.Count > 0)
                {
                    tileOrder = helpInfoTiles.Max(d => d.TileOrder);
                }

                var viewModel = new UsefulLinksViewModel
                {
                    TileImageUrls = await this.helpDataProvider.GetImageFilesAsync(),
                    HelpInfoTiles = helpInfoTiles.OrderBy(c => c.TileOrder).ToList()
                };

                return(this.View(viewModel));
            }
            catch (Exception ex)
            {
                this.telemetryClient.TrackTrace($"Error processing message: {ex.Message}", SeverityLevel.Error);
                this.telemetryClient.TrackException(ex);
                return(this.View("Error"));
            }
        }
Exemplo n.º 2
0
        public ActionResult Index()
        {
            var isAdminMode = Session["IsAdminMode"] != null && Session["IsAdminMode"].ToString() == "true";
            var usefulInfos = _usefulLinkRepository.GetAll().OrderByDescending(x => x.PublishDate);
            var model       = new UsefulLinksViewModel
            {
                Items = usefulInfos != null?Mapper.Map <List <InfoViewModel> >(usefulInfos) : new List <InfoViewModel>(),
                            IsAdminMode = isAdminMode
            };

            return(View("~/Views/UsefulInfo/Index.cshtml", model));
        }
Exemplo n.º 3
0
        public ActionResult GetInfo()
        {
            var isAdminMode = Session["IsAdminMode"] != null && Session["IsAdminMode"].ToString() == "true";
            var usefulInfos = _usefulLinkRepository.GetAll()?.OrderByDescending(x => x.PublishDate);
            var model       = new UsefulLinksViewModel
            {
                Items = usefulInfos != null?Mapper.Map <List <InfoViewModel> >(usefulInfos) : new List <InfoViewModel>(),
                            IsAdminMode = isAdminMode
            };

            return(new JsonResult
            {
                Data = model,
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Exemplo n.º 4
0
        public async Task <ActionResult <UsefulLinks> > Post([FromBody] UsefulLinksViewModel model)
        {
            ClaimsPrincipal currentUser     = this.User;
            var             currentUserName = currentUser.FindFirst(ClaimTypes.NameIdentifier).Value;
            AppUser         user            = await _userManager.FindByNameAsync(currentUserName);

            var link = new UsefulLinks
            {
                Url          = model.Url,
                Description  = model.Description,
                CatId        = model.CatId,
                CreateDate   = DateTime.Now,
                CreateUserId = user.Id
            };

            await _appDbContext.UsefulLinks.AddAsync(link);

            await _appDbContext.SaveChangesAsync();

            return(new OkObjectResult("Useful Link created"));
        }