Exemple #1
0
        /// <summary>
        /// 用户管理收货地址
        /// </summary>
        /// <returns></returns>
        public ActionResult Addressedit(string code, string fromURL, string addressId)
        {
            #region 用户信息部分
            string userOpenId             = string.Empty;
            Tuple <string, string> result = base.getUserOpenId(code);
            if (!string.IsNullOrEmpty(result.Item1))
            {
                userOpenId = result.Item1;
            }
            else if (!string.IsNullOrEmpty(result.Item2))
            {
                return(Redirect(result.Item2));
            }
            ViewBag.userOpenId = userOpenId;
            #endregion

            #region 收货地址部分
            if (string.IsNullOrEmpty(addressId))
            {
                return(RedirectToAction("Addresslist", "User", new { fromURL = fromURL }));
            }
            else
            {
                useraddress_extension userAddress = UserBiz.CreateNew().getUserAddressById(userOpenId, addressId);
                ViewBag.fromBaseURL = fromURL;
                ViewBag.FooterType  = "custom";
                ViewBag.PageName    = "管理收货地址";
                return(View(userAddress));
            }
            #endregion
        }
Exemple #2
0
        /// <summary>
        /// 根据用户收货地址id获取具体信息
        /// </summary>
        /// <param name="userOpenId"></param>
        /// <param name="addressId"></param>
        /// <returns></returns>
        public useraddress_extension getUserAddressById(string userOpenId, string addressId)
        {
            useraddress_extension userAddressInfo = new useraddress_extension();

            using (IDbConnection conn = DapperHelper.MySqlConnection())
            {
                try
                {
                    string sqlCommandText = @"SELECT a.*,b.name as provinceName,c.name as cityName ,d.name as countyName 
                                                FROM ganxian.useraddress a
                                                inner join district b on a.province = b.id
                                                left join district c on a.city = c.id
                                                left join district d on a.county = d.id
                                                where a.status = 1 and userOpenId =@userOpenId and a.id=@id ";
                    userAddressInfo = conn.Query <useraddress_extension>(sqlCommandText, new { userOpenId = userOpenId, id = addressId }).FirstOrDefault();
                }
                catch (Exception e)
                {
                    throw new Exception(e.Message);
                }
            }
            return(userAddressInfo);
        }