Exemplo n.º 1
0
        // GET: DreamProducts/Delete/5
        public ActionResult Delete()
        {
            var pid = (string)Session["id"];
            var id  = Convert.ToInt16(pid);

            DreamProducts dreamProducts = db.dreamProducts.Find(id);

            return(View(dreamProducts));
        }
Exemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "Id,ProdName,Type,Description")] DreamProducts dreamProducts)
 {
     if (ModelState.IsValid)
     {
         db.Entry(dreamProducts).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(dreamProducts));
 }
Exemplo n.º 3
0
        // GET: DreamProducts/Details/5
        public ActionResult Details(int?id)
        {
            DreamProducts dreamProducts = db.dreamProducts.Find(id);

            Session["id"]   = dreamProducts.Id.ToString();
            Session["name"] = dreamProducts.ProdName;
            Session["type"] = dreamProducts.Type;
            Session["desc"] = dreamProducts.Description;

            return(View(dreamProducts));
        }
Exemplo n.º 4
0
        // GET: DreamProducts/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DreamProducts dreamProducts = db.dreamProducts.Find(id);

            if (dreamProducts == null)
            {
                return(HttpNotFound());
            }
            return(View(dreamProducts));
        }
Exemplo n.º 5
0
        public ActionResult DeleteConfirmed()
        {
            var pid = (string)Session["id"];
            var id  = Convert.ToInt16(pid);

            DreamProducts dreamProducts = db.dreamProducts.Find(id);

            var user = db.Users.ToList().Find(x => x.UserName == dreamProducts.UserName);

            try
            {
                var senderEmail   = new MailAddress("*****@*****.**", "Elenas Delicacies");
                var recieveremail = new MailAddress(user.UserName, "Reciever");
                var password      = "******";

                int    date     = DateTime.Now.Year;
                string thisyear = Convert.ToString(date);

                var sub  = "Decision for Dream Product Idea";
                var body = "Dear " + user.fullname + " , Your Dream Product idea (" + dreamProducts.ProdName + ") has been rejected." + "<br />" + "We thank you for your idea though and hope to get new ideas from you in the future!" + "<br />" + "Regards" + "<br />" + "Elenas Delicacies";

                var smtp = new SmtpClient
                {
                    Host                  = "smtp.gmail.com",
                    Port                  = 587,
                    EnableSsl             = true,
                    DeliveryMethod        = SmtpDeliveryMethod.Network,
                    UseDefaultCredentials = false,
                    Credentials           = new NetworkCredential(senderEmail.Address, password)
                };

                using (var msg = new MailMessage(senderEmail, recieveremail)
                {
                    Subject = sub,
                    Body = body
                }
                       )
                {
                    smtp.Send(msg);
                }
            }
            catch (Exception)
            {
            }

            db.dreamProducts.Remove(dreamProducts);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 6
0
        public ActionResult Create([Bind(Include = "Id,ProdName,Type,Description")] DreamProducts dreamProducts)
        {
            if (ModelState.IsValid)
            {
                dreamProducts.UserName = User.Identity.Name;
                dreamProducts.Date     = DateTime.Now.Date;

                db.dreamProducts.Add(dreamProducts);
                db.SaveChanges();

                Session["id"] = dreamProducts.Id.ToString();

                return(RedirectToAction("AddIngredients"));
            }

            return(View(dreamProducts));
        }