Beispiel #1
0
        public async Task <IActionResult> Create(string sender, string receiver, string subject, string message)
        {
            Email email = new Email {
                Sender = sender, Receiver = receiver, Subject = subject, Message = message
            };

            if (ModelState.IsValid)
            {
                email.Status = "Delivered @ " + DateTime.Now.ToString("HH:mm") + " on " + DateTime.Today.ToString("dd-MM-yyyy");
                _context.Add(email);
                await _context.SaveChangesAsync();

                HttpContext.Session.SetString("receiver", "");
                HttpContext.Session.SetString("subject", "");
                HttpContext.Session.SetString("message", "");
                ModelState.Clear();
                return(View());
            }
            return(View(email));
        }
        //POST: Announcements/MakeAnnouncement
        public async Task <IActionResult> MakeAnnouncement(string announcementText)
        {
            var prof = await _context.Professor.SingleOrDefaultAsync(m => m.Username == HttpContext.Session.GetString("username"));

            ViewData["ClassOne"] = prof.ClassOne;
            string       classCode    = prof.ClassOne;
            Announcement announcement = new Announcement {
                AnnouncementText = announcementText, ClassCode = classCode, ProfUsername = prof.Username
            };

            _context.Announcement.Add(announcement);
            await _context.SaveChangesAsync();

            return(View());
        }