예제 #1
0
        //sending thankyou letter to user
        public async Task <ActionResult> Sendletter(int iid, int tid)
        {
            int               id = iid;
            Testimonial       t  = db.Testimonials.Find(id);
            TestimonialStatus ts = db.TestimonialStatuss.Find(tid);
            string            Message;

            if (ts.TestimonialStatusName.Equals("Approved-Published"))
            {
                Message = "Thankyou " + t.UserFName + " " + t.UserLName + "Your Testimonial is being Published and can be seen on home page.";
            }
            else
            {
                Message = "Thankyou " + t.UserFName + " " + t.UserLName + "  Your Testimonial is being recieved and is under revewing process.";
            }

            var msg = new MimeMessage();

            msg.From.Add(new MailboxAddress("admin", "*****@*****.**"));
            msg.To.Add(new MailboxAddress(t.UserFName, t.Email));
            msg.Subject = "Testimonial";
            msg.Body    = new TextPart("html")
            {
                Text = Message
            };


            using (var client = new MailKit.Net.Smtp.SmtpClient())
            {
                client.Connect("smtp.gmail.com", 587, false);
                client.Authenticate("*****@*****.**", "mailtest1234");
                client.Send(msg);
                client.Disconnect(true);
            }

            var user = await GetCurrentUserAsync();

            var userstate = await GetUserDetails(user);

            if (userstate == 2)
            {
                return(RedirectToAction("List"));
            }
            else
            {
                return(RedirectToAction("index", "Home"));
            }
        }
예제 #2
0
        public async Task <ActionResult> Edit(int id, int?TestimonialStatusID)
        {
            var user = await GetCurrentUserAsync();

            var userstate = await GetUserDetails(user);

            if (userstate == 2)
            {
                if (db.Testimonials.Find(id) == null)
                {
                    //Show error message
                    return(NotFound());
                }
                string query = "update Testimonials set TestimonialStatusID = @TestimonialStatusID " +
                               "where TestimonialID = @id";

                SqlParameter[] myparams = new SqlParameter[2];
                myparams[0] = new SqlParameter("@TestimonialStatusID", TestimonialStatusID);
                myparams[1] = new SqlParameter("@id", id);

                db.Database.ExecuteSqlCommand(query, myparams);
                TestimonialStatus ts = db.TestimonialStatuss.Find(TestimonialStatusID);
                if (ts.TestimonialStatusName.Equals("Approved-Published"))
                {
                    return(RedirectToAction("Sendletter", new { iid = id, tid = TestimonialStatusID }));
                }
                else
                {
                    return(RedirectToAction("List"));
                }
            }
            else
            {
                return(RedirectToAction("index", "Home"));
            }
        }
예제 #3
0
 public static List <Testimonial> Get(TestimonialStatus status)
 {
     return(TableHelper.GetListFromRawQuery <Testimonial>(string.Format("SELECT * FROM Testimonials WHERE Status = {0}", (int)status)));
 }