示例#1
0
        public async Task <IActionResult> Edit(int id, [Bind("StartDate,Duration,Password,HostVideoEnabled,ParticipantVideoEnabled,MaxParticipants,Description,Name,BannerUrl,UserId,Price,Id,Modified")] WebinarMeeting webinarMeeting)
        {
            if (id != webinarMeeting.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(webinarMeeting);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!WebinarMeetingExists(webinarMeeting.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserId"] = new SelectList(_context.User, "Id", "FirstName", webinarMeeting.UserId);
            return(View(webinarMeeting));
        }
示例#2
0
        public async Task <IActionResult> Create([Bind("StartDate,Duration,Password,HostVideoEnabled,ParticipantVideoEnabled,MaxParticipants,Description,Name,BannerUrl,UserId,Price,Id,Modified")] WebinarMeeting webinarMeeting)
        {
            if (ModelState.IsValid)
            {
                _context.Add(webinarMeeting);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserId"] = new SelectList(_context.User, "Id", "FirstName", webinarMeeting.UserId);
            return(View(webinarMeeting));
        }
示例#3
0
        public async Task PostMessage(WebinarMeeting webinar, EmailAddress email, string link)
        {
            var apiKey = _configuration.GetSection("SENDGRID_API_KEY").Value;

            Console.WriteLine(apiKey);
            var client = new SendGridClient(apiKey);

            var from = new EmailAddress("*****@*****.**", "Webistar Invitation");
            List <EmailAddress> tos = new List <EmailAddress>
            {
                new EmailAddress("*****@*****.**", "Dennys"),
                new EmailAddress("*****@*****.**", "Dennys"),
                new EmailAddress("*****@*****.**", "Shanela"),
                new EmailAddress("*****@*****.**", "Mónica")
            };

            var subject        = "Hello world email from Sendgrid ";
            var assembly       = this.GetType().Assembly;
            var resourceStream = assembly.GetManifestResourceStream("asp_net_core.Data.email-inlined.html");
            var htmlContent    = "";
            var listR          = Assembly.GetExecutingAssembly().GetManifestResourceNames();

            foreach (var tz in listR)
            {
                Console.WriteLine(tz);
            }
            var builder = new StringBuilder();

            using (var reader = new StreamReader(resourceStream, Encoding.UTF8))
            {
                builder.Append(await reader.ReadToEndAsync());
            }

            builder.Replace("{{WebinarName}}", webinar.Name);
            builder.Replace("{{Link}}", link);
            builder.Replace("{{Name}}", email.Name);
            htmlContent = builder.ToString();

            // var displayRecipients = false; // set this to true if you want recipients to see each others mail id
            var msg      = MailHelper.CreateSingleEmailToMultipleRecipients(from, tos, subject, "plain text", htmlContent, false);
            var response = await client.SendEmailAsync(msg);

            //   Console.WriteLine("response body="+response.Body.;
            Console.WriteLine(response.StatusCode);
            var escuelaContext = _context.WebinarMeeting.Include(w => w.User);
            //   return View("Index", await escuelaContext.ToListAsync());
        }