コード例 #1
0
ファイル: ArticleController.cs プロジェクト: snicoper/BlogNet
        public async Task <IActionResult> Recommend(string slug)
        {
            if (string.IsNullOrEmpty(slug))
            {
                return(NotFound());
            }

            var article = _articleRepository.GetBySlug(slug);

            if (article is null)
            {
                return(NotFound());
            }

            var email = string.Empty;

            if (User.Identity.IsAuthenticated)
            {
                var user = await _userManager.FindByNameAsync(User.Identity.Name);

                email = user.Email;
            }

            var model = new RecommendViewModel
            {
                Slug  = article.Slug,
                Title = article.Title,
                From  = email
            };

            return(View(model));
        }
コード例 #2
0
        public RecommendView()
        {
            InitializeComponent();
            ViewModel = new RecommendViewModel();


            this.WhenActivated(d =>
            {
                this.OneWayBind(ViewModel, vm => vm.Username, v => v.username.Text).DisposeWith(d);
                this.BindCommand(ViewModel, vm => vm.CloseCommand, v => v.close).DisposeWith(d);
            });
        }
コード例 #3
0
        public ActionResult Recommend()
        {
            var recommend = new RecommendViewModel();

            ViewBag.genres = new List <SelectListItem>();
            var genresFromDB = MovieRepository.GetAllGenres();

            foreach (string genre in genresFromDB)
            {
                var selectListItem = new SelectListItem();
                selectListItem.Text  = genre;
                selectListItem.Value = genre;
                ViewBag.genres.Add(selectListItem);
            }
            return(View(recommend));
        }
コード例 #4
0
ファイル: ArticleController.cs プロジェクト: snicoper/BlogNet
        public async Task <IActionResult> Recommend(
            [FromServices] IEmailService emailService,
            string slug,
            RecommendViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var article = _articleRepository.GetBySlug(model.Slug);

            if (article is null)
            {
                return(NotFound());
            }

            var siteName   = _configuration["Site:SiteName"];
            var emailModel = new EmailRecommendViewModel
            {
                SiteName = siteName,
                Title    = article.Title,
                CallBack = Url.Action(nameof(Details), "Article", new { article.Slug }, HttpContext.Request.Scheme),
                From     = model.From
            };

            emailService.Subject = $"Recomendación de articulo en {siteName}";
            emailService.From    = new MailAddress(model.From);
            emailService.To      = new List <MailAddress> {
                new MailAddress(model.To)
            };
            await emailService.SendEmailAsync("ArticleRecommend", emailModel);

            this.AddMessage("success", "Recomendación enviada con éxito");
            return(RedirectToAction(nameof(Details), new { model.Slug }));
        }
コード例 #5
0
 public ClientRecommend()
 {
     InitializeComponent();
     DataContext = new RecommendViewModel();
 }
コード例 #6
0
 public RecommendView(RecommendViewModel viewModel)
 {
     InitializeComponent();
     this.DataContext = viewModel;
 }
コード例 #7
0
 public RecommendWindow()
 {
     InitializeComponent();
     DataContext = new RecommendViewModel();
 }