Exemplo n.º 1
0
        public ActionResult SaveSignup(user user)
        {
            user.status     = "active";
            user.createdate = DateTime.Now;
            user.updatedate = DateTime.Now;
            user.type       = 1;
            user.discount   = 0;
            db.users.Add(user);
            db.SaveChanges();
            user_role ur = new user_role();

            ur.userid = user.Id;
            ur.roleid = 6;
            ur.status = "active";
            db.user_role.Add(ur);
            userdata ud = new userdata();

            ud.userid = user.Id;
            db.userdatas.Add(ud);
            db.SaveChanges();
            var t   = SendTemplateEmail(user.email, user.email, "", "Email register success", 1);
            var tem = db.users.FirstOrDefault(m => m.username == user.username && m.password == user.password);

            if (tem != null)
            {
                Session["LoggedAccount"] = null;
                AllLoggedUserInfo userFullInfo = new AllLoggedUserInfo(tem);
                Session["LoggedAccount"] = userFullInfo;
                string decodedUrl = "";
                if (!string.IsNullOrEmpty(Url.Action("AccountInfo", "Account", new { id = user.Id })))
                {
                    decodedUrl = Server.UrlDecode(Url.Action("AccountInfo", "Account", new { id = user.Id }));
                }
                if (decodedUrl != "" && !decodedUrl.Contains("Login"))
                {
                    return(Redirect(decodedUrl));
                }
                if (userFullInfo.role.RoleName == "super_admin")
                {
                    return(RedirectToAction("Index", "Admin"));
                }
                else
                {
                    return(RedirectToAction("Index", "Home"));
                }
            }
            else
            {
                return(RedirectToAction("Login", "Home", new { message = "Acount do not exist." }));
            }
        }
Exemplo n.º 2
0
        // GET: /Checkout/Create
        public ActionResult Create()
        {
            var order = new order();
            var user  = new AllLoggedUserInfo();

            if (Session["ShoppingCart"] == null)
            {
                return(RedirectToAction("UpdateCart", "Home"));
            }
            else
            {
                ShoppingCart cart = (ShoppingCart)Session["ShoppingCart"];
                if (cart.cartItem.Count == 0)
                {
                    return(RedirectToAction("UpdateCart", "Home"));
                }

                ViewBag.Cart = cart;
                if (Session["LoggedAccount"] == null)
                {
                    return(View());
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(cart.paid_key))
                    {
                        user = (AllLoggedUserInfo)Session["LoggedAccount"];
                        var tblUser = db.users.Join(db.userdatas, us => us.Id, usdt => usdt.userid,
                                                    (us, usdt) => new AllModel {
                            tblUser = us, tblUserData = usdt
                        }).FirstOrDefault(x => x.tblUser.Id == user.user.Id);

                        if (tblUser != null)
                        {
                            if (tblUser.tblUser.Id == 7 || tblUser.tblUser.Id == 1)
                            {
                                order = new order();
                            }
                            else
                            {
                                order.fname      = tblUser.tblUserData.firstname;
                                order.lname      = tblUser.tblUserData.lasname;
                                order.email      = tblUser.tblUser.email;
                                order.phone      = tblUser.tblUserData.contact_phone;
                                order.d_fname    = tblUser.tblUserData.delivery_name;
                                order.d_phone    = tblUser.tblUserData.delivery_phone;
                                order.d_email    = tblUser.tblUserData.delivery_email;
                                order.d_addr1    = tblUser.tblUserData.delivery_address1;
                                order.d_postcode = tblUser.tblUserData.delivery_postcode;
                                order.d_country  = tblUser.tblUserData.delivery_contry;
                                order.b_fname    = tblUser.tblUserData.billing_name;
                                order.b_phone    = tblUser.tblUserData.billing_phone;
                                order.b_email    = tblUser.tblUserData.billing_email;
                                order.b_addr1    = tblUser.tblUserData.billing_address1;
                                order.b_postcode = tblUser.tblUserData.billing_poscode;
                                order.b_country  = tblUser.tblUserData.billing_country;
                            }
                        }
                    }
                    else
                    {
                        order = db.orders.FirstOrDefault(t => t.paid_key == cart.paid_key);
                        if (order == null)
                        {
                            order = new order();
                            user  = (AllLoggedUserInfo)Session["LoggedAccount"];
                            var tblUser = db.users.Join(db.userdatas, us => us.Id, usdt => usdt.userid,
                                                        (us, usdt) => new AllModel {
                                tblUser = us, tblUserData = usdt
                            }).FirstOrDefault(x => x.tblUser.Id == user.user.Id);

                            if (tblUser != null)
                            {
                                if (tblUser.tblUser.Id == 7 || tblUser.tblUser.Id == 1)
                                {
                                    order = new order();
                                }
                                else
                                {
                                    order.fname      = tblUser.tblUserData.firstname;
                                    order.lname      = tblUser.tblUserData.lasname;
                                    order.email      = tblUser.tblUser.email;
                                    order.phone      = tblUser.tblUserData.contact_phone;
                                    order.d_fname    = tblUser.tblUserData.delivery_name;
                                    order.d_phone    = tblUser.tblUserData.delivery_phone;
                                    order.d_email    = tblUser.tblUserData.delivery_email;
                                    order.d_addr1    = tblUser.tblUserData.delivery_address1;
                                    order.d_postcode = tblUser.tblUserData.delivery_postcode;
                                    order.d_country  = tblUser.tblUserData.delivery_contry;
                                    order.b_fname    = tblUser.tblUserData.billing_name;
                                    order.b_phone    = tblUser.tblUserData.billing_phone;
                                    order.b_email    = tblUser.tblUserData.billing_email;
                                    order.b_addr1    = tblUser.tblUserData.billing_address1;
                                    order.b_postcode = tblUser.tblUserData.billing_poscode;
                                    order.b_country  = tblUser.tblUserData.billing_country;
                                }
                            }
                        }
                    }
                }
            }
            ViewBag.ListCountry = db.countries.ToList();
            return(View(order));
        }