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)); }
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); }); }
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)); }
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 })); }
public ClientRecommend() { InitializeComponent(); DataContext = new RecommendViewModel(); }
public RecommendView(RecommendViewModel viewModel) { InitializeComponent(); this.DataContext = viewModel; }
public RecommendWindow() { InitializeComponent(); DataContext = new RecommendViewModel(); }