Esempio n. 1
0
        public async Task <IActionResult> Create([Bind(PKey.SPram)] Suggestion suggestion)
        {
            var currentUserName = HttpContext.User.Claims.First(x => x.Type == ClaimTypes.Name).Value;
            var currentAccount  = await aCContext.Accounts.FirstOrDefaultAsync(a => a.UserName == currentUserName);

            if (ModelState.IsValid)
            {
                suggestion.Guid       = Guid.NewGuid();
                suggestion.CreateTime = DateTime.Now;
                suggestion.UpdateTime = DateTime.Now;
                suggestion.SendTime   = DateTime.Now;
                suggestion.SendEmail  = currentAccount.Email;
                context.Add(suggestion);
                await context.SaveChangesAsync();

                return(View(suggestion));
            }
            return(View(suggestion));
        }
Esempio n. 2
0
        public async Task <IActionResult> Create([Bind("SuggId,SuggName,SuggEmail,SuggSubject,SuggMessage,UserName,UserIP,UserDate")] Suggestion suggestion)
        {
            UserDetails();

            //  assining values from inputs
            SenderName    = suggestion.SuggName;
            SenderSubject = suggestion.SuggSubject;
            SenderEmail   = ViewBag.EmailAddress;
            SenderMessage = suggestion.SuggMessage;
            //ReceiverName = _emailOptions.SenderName;
            ReceiverEmail = SD.ServiceUserEmailName;

            //  calling SendEmail email function
            SendEmail(SenderName, SenderEmail, ReceiverName, SenderMessage, SenderSubject);

            var message = new MimeMessage();
            var builder = new BodyBuilder();

            // reference value from EmailOptions.json
            //string host = SD.SMTPClient;
            //int port = SD.SMTPPort;
            //bool boole = SD.SMTPBool;
            //string authEmail = SD.AdminEmail;
            //string authPass = SD.AdminPass;

            message.From.Add(new MailboxAddress(SenderName, SenderEmail));

            if (ModelState.IsValid)
            {
                _context.Add(suggestion);
                addToast();
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Create)));
            }

            return(View(suggestion));
        }
Esempio n. 3
0
 public Suggestion CreateSuggetion(Suggestion newSuggestion)
 {
     _suggestionContext.Add(newSuggestion);
     _suggestionContext.SaveChanges();
     return(newSuggestion);
 }