public ActionResult DeleteProduct(int id)
        {
            tbl_Product      tb  = _db.tbl_Product.Where(u => u.ProductId == id).FirstOrDefault();
            ProductViewModel pvm = new ProductViewModel();

            pvm.ProductId          = tb.ProductId;
            pvm.ProductName        = tb.ProductName;
            pvm.ProductDescription = tb.ProductDescription;
            pvm.ProductPackingDate = tb.ProductPackingDate;
            pvm.ProductExpireDate  = tb.ProductExpireDate;
            tbl_Deals td = _db.tbl_Deals.Where(u => u.DealsId == id).FirstOrDefault();

            pvm.DealsName = td.DealsName;
            tbl_ProductCategory tpc = _db.tbl_ProductCategory.Where(u => u.CategoryId == tb.CategoryId).FirstOrDefault();

            pvm.CategoryName = tpc.CategoryName;
            tbl_ProductStatus tpss = _db.tbl_ProductStatus.Where(u => u.StatusId == tb.StatusId).FirstOrDefault();

            pvm.StatusName = tpss.StatusName;
            tbl_ProductStore tps = _db.tbl_ProductStore.Where(u => u.ProductId == tb.ProductId).FirstOrDefault();
            tbl_Store        ts  = _db.tbl_Store.Where(u => u.StoreId == tps.StoreId).FirstOrDefault();

            pvm.StoreName = ts.StoreName;
            return(View(pvm));
        }
        public ActionResult deletedeal(int id)
        {
            tbl_Deals tb = _db.tbl_Deals.Where(u => u.DealsId == id).FirstOrDefault();

            _db.tbl_Deals.Remove(tb);
            _db.SaveChanges();
            return(RedirectToAction("Deals"));
        }
        public ActionResult deletedeals(int id)
        {
            tbl_Deals tb = _db.tbl_Deals.Where(u => u.DealsId == id).FirstOrDefault();
            Deals     uv = new Deals();

            uv.DealsName        = tb.DealsName;
            uv.DealsDiscription = tb.DealsDiscription;
            uv.DiscountPercent  = tb.DiscountPercent;
            uv.StartDate        = tb.StartDate;
            uv.EndDate          = tb.EndDate;
            return(View(uv));
        }
        public ActionResult EditDeals(int id)
        {
            tbl_Deals tb  = _db.tbl_Deals.Where(p => p.DealsId == id).FirstOrDefault();
            Deals     pvm = new Deals();

            pvm.DealsId          = tb.DealsId;
            pvm.DealsName        = tb.DealsName;
            pvm.DealsDiscription = tb.DealsDiscription;
            pvm.DiscountPercent  = tb.DiscountPercent;
            pvm.StartDate        = tb.StartDate;
            pvm.EndDate          = tb.EndDate;
            return(View(pvm));
        }
 public ActionResult Deals_data(Deals d)
 {
     if (ModelState.IsValid)
     {
         try
         {
             tbl_Deals deals = new tbl_Deals();
             deals.DealsId          = d.DealsId;
             deals.DealsName        = d.DealsName;
             deals.DealsDiscription = d.DealsDiscription;
             deals.DiscountPercent  = d.DiscountPercent;
             deals.StartDate        = d.StartDate;
             deals.EndDate          = d.EndDate;
             _db.tbl_Deals.Add(deals);
             _db.SaveChanges();
             //----
             List <tblUser> tbluser = new List <tblUser>();
             var            user    = _db.tblUsers.ToList();
             foreach (tblUser item in user)
             {
                 string from = "*****@*****.**";
                 using (MailMessage mm = new MailMessage(from, item.Email, deals.DealsName, "Discount Percent: " + deals.DiscountPercent + "%" + "\n" + "StartDate: " + deals.StartDate + "\n" + "EndDate: " + deals.EndDate))
                 {
                     mm.IsBodyHtml = false;
                     SmtpClient smtp = new SmtpClient();
                     smtp.Host                  = "smtp.gmail.com";
                     smtp.EnableSsl             = true;
                     smtp.UseDefaultCredentials = false;
                     NetworkCredential NetworkCred = new NetworkCredential(from, "YogeshPassword");
                     smtp.Credentials    = NetworkCred;
                     smtp.Port           = 587;
                     smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
                     smtp.Send(mm);
                     ViewBag.Message = "Mail Sent";
                 }
             }
             //--
             ViewBag.Message = "Deals Created Successfully.";
             return(RedirectToAction("Deals"));
         }
         catch (Exception e)
         {
             return(View("Error", new HandleErrorInfo(e, "Admin", "CreateUser")));
         }
     }
     return(View());
 }
 public ActionResult EditDeal(Deals d)
 {
     if (ModelState.IsValid)
     {
         try
         {
             tbl_Deals deal = _db.tbl_Deals.Where(p => p.DealsId == d.DealsId).FirstOrDefault();
             deal.DealsName        = d.DealsName;
             deal.DealsDiscription = d.DealsDiscription;
             deal.DiscountPercent  = d.DiscountPercent;
             deal.StartDate        = d.StartDate;
             deal.EndDate          = d.EndDate;
             _db.SaveChanges();
             ViewBag.Message = "Deal Updated Successfully.";
             return(RedirectToAction("Deals"));
         }
         catch (Exception e)
         {
             return(View("Error", new HandleErrorInfo(e, "Admin", "EditDeals")));
         }
     }
     return(RedirectToAction("Deals"));
 }