public ActionResult Call_Back_RazorPay(string razorpay_payment_id)
        {
            if (Session["User_Informations"] == null || Session["Shopping_Cart"] == null)
            {
                return(RedirectToAction("ShoppingCart", "Shop"));
            }


            var user_informations = (User_Informations)Session["User_Informations"];

            // Add User Informations into DB
            User_Informations_Helper.Update(user_informations);

            int id = User_Informations_Helper.Get_ID(User.Identity.GetUserId());

            var shoppingCartList = (List <Shopping_Cart>)Session["Shopping_Cart"];

            foreach (var item in shoppingCartList)
            {
                var Item = new Order()
                {
                    UID                = @User.Identity.GetUserId(),
                    Ordered            = DateTime.Now,
                    Paid               = DateTime.Now,
                    Delivered          = DateTime.Now,
                    UserInformationsID = id,
                    ShopItemID         = item.ID,
                    Quantity           = item.Quantity,
                    RazorPayID         = razorpay_payment_id
                };
                _context.Order.Add(Item);
                _context.SaveChanges();

                string message = $"Hello {user_informations.Fname}! <br/> We've just received your paiment for <b>{item.Name}</b>, RazorPaiID: <b>{razorpay_payment_id}</b>!<br /> Thank's for your shopping!";
                string subject = "Information about payment";

                Send_Mail.Mail("*****@*****.**", User.Identity.GetUserName(), message, subject);
            }

            // Clear Session
            Session["Shopping_Cart"]     = null;
            Session["User_Informations"] = null;
            Session["Total_Price"]       = null;

            // Set message
            Session["Message"] = "Congratulations! You just bought in our shop, we send e-mail with more informations!";

            return(RedirectToAction("Information", "Shop"));

            return(View());
        }
Exemplo n.º 2
0
        // GET: Order Informations
        public ActionResult Orders_Informations()
        {
            // Copy lats used User Informations ID
            var Last_ID = User_Informations_Helper.Get_ID(User.Identity.GetUserId());

            // Create copy of User Informations
            var User_Info = _context.User_Informationses.SingleOrDefault(x => x.id == Last_ID);

            if (User_Info != null)
            {
                Session["User_Informations"] = User_Info;
            }
            else
            {
                Session["User_Informations"] = new User_Informations();
            }


            return(View());
        }