public ActionResult RaportAProblem(string problem)
        {
            try
            {
                User user  = db.Users.Where(u => u.username == User.Identity.Name && u.company == CompanyName).FirstOrDefault();
                User admin = db.Users.Where(u => u.type == 0 && u.company == CompanyName).FirstOrDefault();

                CustomEmailService custom = new CustomEmailService();

                string sub  = "Problem raported";
                string body = "Hello " + admin.username + "\n" + user.username + " raported a problem. You have the informations below \n" + problem;

                EmailMessage mess = new EmailMessage()
                {
                    recieverAddress = "*****@*****.**",
                    recieverName    = "Boo",
                    subject         = sub,
                    body            = body
                };
                {
                    custom.SendEmail(mess);
                }
                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                ViewBag.Error = "Some Error " + e.Message;
            }

            return(View());
        }
        /// <summary>
        /// Will create and send automated email based on users email and
        /// selection of paintngs.This will be executed after successful purchase
        /// </summary>
        /// <param name="recieverEmail"></param>
        /// <param name="paintingIDs"></param>
        public static void SendEmail(string recieverEmail, List <string> paintingIDs)
        {
            CustomEmailService mail = new CustomEmailService();

            mail.to = new MailAddress(recieverEmail);
            mail.CreateAttachments(paintingIDs);
            mail.SendMail();
        }
        public IActionResult AssignReviewer(int id, IList <string> reviewersEmails)
        {
            // id = ArticleId
            if (id == 0)
            {
                TempData["title"]       = "Error Occured";
                TempData["description"] = "Error Description";
                return(RedirectToAction("error", "home"));
            }
            else if (reviewersEmails.Count == 0)
            {
                TempData["err"] = "Atleast Select One User To Review";
                return(RedirectToAction("article", new { id = id }));
            }
            else if (reviewersEmails.Count != reviewersEmails.Distinct().Count())
            {
                TempData["err"] = "Email Repeated Twice";
                return(RedirectToAction("article", new { id = id }));
            }

            IList <Invitation> alreadyInvitedList = dbContext.invitations.Include(ar => ar.User).Where(a => a.ArticleId == id).ToList();

            foreach (string email in reviewersEmails)
            {
                if (alreadyInvitedList.SingleOrDefault(a => a.User.Email.Equals(email)) == null)
                {
                    Invitation invitation = new Invitation()
                    {
                        ArticleId             = id,
                        UserId                = dbContext.Users.SingleOrDefault(u => u.Email == email).Id,
                        status                = "pending",
                        readByAssociateEditor = false,
                        readByAuthor          = false
                    };
                    dbContext.invitations.Add(invitation);

                    CustomEmailService emailService = new CustomEmailService();
                    emailService.sendEmail(
                        "*****@*****.**",
                        "zkpagebuyerandseller",
                        email,
                        "Invitaion To Review An Article",
                        "You're invited To Review An Article Please Login To BJMS Portal For Detail"
                        );
                }
            }

            foreach (Invitation invitation1 in alreadyInvitedList)
            {
                if (!reviewersEmails.Contains(invitation1.User.Email))
                {
                    dbContext.invitations.Remove(invitation1);
                }
            }
            dbContext.SaveChanges();

            return(RedirectToAction("index"));
        }
 public void sendEmailToAuthors(List <string> emails)
 {
     foreach (var email in emails)
     {
         CustomEmailService emailService = new CustomEmailService();
         emailService.sendEmail(
             "*****@*****.**",
             "zkpagebuyerandseller",
             email,
             "your registered",
             "Success"
             );
     }
 }
예제 #5
0
 public AccountController()
 {
     DbContext          = new ApplicationDbContext();
     CustomEmailService = new CustomEmailService();
 }