public async Task <IActionResult> Edit(int id, [Bind("LessonActivityId,Student_Name,Mentor_Name,StartTime,EndTime,Description,Type")] LessonActivity lessonActivity)
        {
            if (id != lessonActivity.LessonActivityId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(lessonActivity);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LessonActivityExists(lessonActivity.LessonActivityId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(lessonActivity));
        }
        public async Task <IActionResult> Create([Bind("LessonActivityId,Student_Name,Mentor_Name,StartTime,EndTime,Description,Type")] LessonActivity lessonActivity)
        {
            if (ModelState.IsValid)
            {
                _context.Add(lessonActivity);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(lessonActivity));
        }
Пример #3
0
 public async Task Execute_2()
 {
     var mentorEmail      = new Mentor();
     var studentEmails    = new Student();
     var forms            = new LessonActivity();
     var apiKey           = Environment.GetEnvironmentVariable(ApiKeys.SendGridApiKey);
     var client           = new SendGridClient(apiKey);
     var from             = new EmailAddress(mentorEmail.Email, "Mentor Email");
     var subject          = forms.Description;
     var to               = new EmailAddress(studentEmails.Instructor_Email, "Parent Email");
     var plainTextContent = "This is an automated email";
     var htmlContent      = "<strong>automated email</strong>";
     var msg              = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);
     var response         = await client.SendEmailAsync(msg);
 }