コード例 #1
0
        public ActionResult ProductsinShop()
        {
            User user = (User)Session[WebUtils.Current_User];//for  Seeing Admin

            if (!(user != null && user.IsInRole(WebUtils.Admin)))
            {
                return(RedirectToAction("Login", "Users", new { ctl = "Admin", act = "Index" }));
            }
            List <Drink> drinks = new DrinkHandler().GetAllDrinks();

            return(View(drinks));
        }
コード例 #2
0
        public ActionResult UpdateProduct(int id)
        {
            User user = (User)Session[WebUtils.Current_User];

            if (!(user != null && user.IsInRole(WebUtils.Admin)))
            {
                return(RedirectToAction("Login", "Users", new { ctl = "Product", act = "Update" }));
            }
            Drink drink = new DrinkHandler().GetSingleDrink(id);

            return(View(drink));
        }
        public ActionResult AddFabrics()
        {
            User user = (User)Session[WebUtils.Current_User];

            if (!(user != null && user.IsInRole(WebUtils.Admin)))
            {
                return(RedirectToAction("Login", "Users", new { ctl = "Product", act = "AddProduct" }));
            }
            DrinkHandler mHandler = new DrinkHandler();

            ViewBag.Brands = ModelHelper.ToSelectItemList(mHandler.GetAllBrands());
            return(View());
        }
コード例 #4
0
        public ActionResult ProductDetails(int id)
        {
            List <Drink> drink = new DrinkHandler().GetDrinkbyId(id);

            return(View(drink));
        }
コード例 #5
0
        public ActionResult Order(FormCollection data)
        {
            UniversalContext db     = new UniversalContext();
            string           random = Path.GetRandomFileName().Replace(".", " ");

            Order p = new Order()
            {
                BuyerName    = data["BuyerName"],
                FullAddress  = data["FullAddress"],
                EmailAddress = data["EmailAddress"],
                Phone        = Convert.ToDouble(data["Phone"]),
                IsActive     = false,
                OrderStatus  = new OrderHandler().GetOrderStatusById(1),
                OrderNo      = random
            };
            List <OrderDetail> cartItems = new List <OrderDetail>();
            ShoppingCart       cart      = (ShoppingCart)Session[WebUtils.Cart];


            foreach (var i in cart.Items)
            {
                OrderDetail ci = new OrderDetail
                {
                    Id       = i.Id,
                    Name     = i.Name,
                    ImageUrl = i.ImageUrl,
                    Qauntity = i.Quantity,
                    Price    = i.Price,
                    Amount   = i.Amount,
                };
                cartItems.Add(ci);
            }

            p.OrderDetails = cartItems;

            foreach (var i in cartItems)
            {
                db.OrderDetails.Add(i);
            }

            db.Orders.Add(p);
            db.Entry(p.OrderStatus).State = EntityState.Unchanged;
            db.SaveChanges();
            //Session.Clear();
            //Here We Sent the Email
            string message = null;

            try
            {
                if (ModelState.IsValid)
                {
                    var sender   = new MailAddress("*****@*****.**");
                    var reciver  = new MailAddress(p.EmailAddress);
                    var password = "******";

                    var p1 = new DrinkHandler().GetOrderById(p.Id);
                    if (p1 != null)
                    {
                        var sub = "---- e-UniversalShoppingSystemShope ----";

                        var body = $"<h2 style='color:#bc4b4b'><center>---Your Buyed Product Information From Universal Shopping App Given Below --- </center></h2><br />" +
                                   $"<div><table style='width:60%;border:1px solid yellow;padding:10px; background-color: #eeeeee; margin: auto;border-collapse: collapse; transition: all 1s;'><tr onMouseOver=this.style.color = 'red''  onMouseOut=this.style.color = 'blue''  style='border:1px solid grey;padding:10px;background-color: #eee;'><th style='border:1px solid grey;padding:10px'>Customer Name:</th><td style='border:1px solid grey;padding:10px'>{p1.BuyerName}</td></tr><tr onMouseOver=this.style.color = 'red''  onMouseOut=this.style.color = 'blue'' style='border:1px solid grey;padding:10px;background-color: pink;'><th style='border:1px solid grey;padding:10px'>Customer Address:</th><td style='border:1px solid grey;padding:10px'>{p1.FullAddress}</td></tr><tr onMouseOver=this.style.color = 'red''  onMouseOut=this.style.color = 'blue'' style='border:1px solid grey;padding:10px;background-color:  #eee;'><th style='border:1px solid grey;padding:10px'>Customer PhoneNo:</th><td style='border:1px solid grey;padding:10px'>{p1.Phone}</td></tr><tr onMouseOver=this.style.color = 'red''  onMouseOut=this.style.color = 'blue'' style='border:1px solid grey;padding:10px;background-color: pink;'><th style='border:1px solid grey;padding:10px'>Product Name:</th><td style='border:1px solid grey;padding:10px'>{p1.OrderDetails.First().Name}</td></tr><tr onMouseOver=this.style.color = 'red''  onMouseOut=this.style.color = 'blue'' style='background-color:  #eee;border:1px solid grey;padding:10px'><th style='border:1px solid grey;padding:10px'>Product Quantity:</th><td style='border:1px solid grey;padding:10px'>{p1.OrderDetails.First().Qauntity}</td></tr><tr onMouseOver=this.style.color = 'red'' onMouseOut=this.style.color = 'blue'' style='background-color: pink;border:1px solid grey;padding:10px'><th style='border:1px solid grey;padding:10px'>Product Amount:</th><td style='border:1px solid grey;padding:10px'>{p1.OrderDetails.First().Amount}</td></tr></table></div>";
                        body = body + "<br> <br> ORDER NO: <b><u> " + p.OrderNo + "</u></b>";
                        var smtp1 = new SmtpClient
                        {
                            Host                  = "smtp.gmail.com",
                            Port                  = 587,
                            EnableSsl             = true,
                            DeliveryMethod        = SmtpDeliveryMethod.Network,
                            UseDefaultCredentials = false,
                            Credentials           = new NetworkCredential(sender.Address, password)
                        };
                        using (var mailMessage = new MailMessage(sender, reciver)
                        {
                            IsBodyHtml = true,
                            BodyEncoding = UTF8Encoding.UTF8,
                            Subject = sub,
                            Body = body
                        })
                        {
                            smtp1.Send(mailMessage);
                            message = "Your Order Details Has Been Sent By Email SuccessFully";
                        }
                    }

                    else
                    {
                        message = "Their is Some Problem in NetWork Sending Email Failed";
                    }

                    return(RedirectToAction("Complete"));
                }
            }
            catch (Exception e)
            {
                ViewBag.OrderMessageError = $"There Is Some Problem Here Please Try Agin{e}";
            }

            Session[WebUtils.Cart] = null;
            return(RedirectToAction("Complete", message));
        }