예제 #1
0
        public async Task <ActionResult <PortfolioRes> > GetById(int id)
        {
            var data = await _service.GetById(id);

            var resource = _mapper.Map <Portfolio, PortfolioRes>(data);

            return(Ok(resource));
        }
예제 #2
0
        // GET: Portfolios/Details/5
        public IActionResult Details(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }

            Portfolio portfolio = _portfolioService.GetById(id);

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

            return(View(portfolio));
        }
예제 #3
0
        public ActionResult Portfolio(int?Id)
        {
            if (!Id.HasValue)
            {
                return(HomePage());
            }

            var portfolio = portfolioService.GetById(Id.Value);

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

            if (!portfolio.IsActive || portfolio.IsDelete)
            {
                return(NotActive());
            }

            string cookieKey = string.Format(CookieConstant.PORTFOLIO_VIEW, portfolio.Id);

            if (!CookieHelper.Exists(cookieKey))
            {
                CookieHelper.Set(cookieKey, WebHelper.IpAddress, 1);
                portfolio.ViewCount += 1;
                portfolioService.Update(portfolio);
            }

            var model = new PortfolioDetailModel
            {
                Id           = portfolio.Id,
                Title        = portfolio.Title,
                Content      = portfolio.Description,
                PicturePath  = mediaStorageService.GetPictureUrl(portfolio.PictureId),
                Url          = urlService.GetUrl(portfolio.Id, nameof(Portfolio)),
                User         = portfolio.User,
                CreateDate   = portfolio.CreateDateUtc,
                UpdateDate   = portfolio.UpdateDateUtc,
                ViewCount    = portfolio.ViewCount,
                CategoryName = portfolio.Category.Name,
                CategoryUrl  = portfolio.Category.Url,
                Pictures     = portfolio.Pictures
            };

            model.RelatedPortfolios = portfolioService.GetRelatedPortfolios(portfolio.CategoryId, portfolio.Id)
                                      .Select(x => new PortfolioModel
            {
                Id = x.Id,
            }).ToList();

            return(View(this.GetViewName(portfolio), model));
        }
예제 #4
0
        public ActionResult Edit(int?id)
        {
            if (!id.HasValue)
            {
                return(RedirectToAction("List"));
            }

            var portfolio = portfolioService.GetById(id.Value);

            if (portfolio == null)
            {
                this.NotifyError("Item not found.");
                return(RedirectToAction("List"));
            }

            var model = new PortfolioModel
            {
                Id                   = portfolio.Id,
                Title                = portfolio.Title,
                CategoryId           = portfolio.CategoryId,
                Content              = portfolio.Description,
                ViewCount            = portfolio.ViewCount,
                ViewName             = portfolio.ViewName,
                IsDelete             = portfolio.IsDelete,
                CreateDate           = portfolio.CreateDateUtc,
                UpdateDate           = portfolio.UpdateDateUtc,
                IsActive             = portfolio.IsActive,
                PortfolioFormat      = GetPortfolioFormat(portfolio.Format),
                PortfolioFormatValue = portfolio.FormatValue,
                PictureId            = portfolio.PictureId,
                Categories           = portfolioCategoryService.GetActives(),
                Url                  = urlService.GetUrl(portfolio.Id, nameof(Portfolio)),
                AvailableViewNames   = this.GetViewNames(nameof(Portfolio))
            };

            return(View(model));
        }
예제 #5
0
        public async Task <IActionResult> Get(int id)
        {
            var result = await _portfolioService.GetById(id);

            return(Ok(result));
        }