Ejemplo n.º 1
0
        public ActionResult DelUserAddress(int id)
        {
            var item = User_addressService.LoadEntities(n => n.id == id && n.del_flag == (int)Del_flag.正常).FirstOrDefault();

            if (item != null)
            {
                item.del_flag = (int)Del_flag.逻辑删除;
                if (User_addressService.EditEntity(item))
                {
                    return(Json(SysEnum.成功, "删除地址成功"));
                }
                return(Json(SysEnum.失败, "删除地址失败"));
            }
            return(Json(SysEnum.失败, "未找到对象"));
        }
Ejemplo n.º 2
0
        public ActionResult EditUserAddress(string address, string name, int id, int state = (int)State.可用)
        {
            var item = User_addressService.LoadEntities(n => n.id == id && n.del_flag == (int)Del_flag.正常).FirstOrDefault();

            if (item != null)
            {
                item.address = address;
                item.name    = name;
                item.state   = state;
                if (User_addressService.EditEntity(item))
                {
                    return(Json(SysEnum.成功, "修改成功"));
                }
                return(Json(SysEnum.失败, "修改失败"));
            }
            return(Json(SysEnum.失败, "未找到对象"));
        }
Ejemplo n.º 3
0
        public ActionResult AddUserAddress(string address, string name)
        {
            var ua = new user_address();

            ua.address  = address;
            ua.user_id  = UserInfo.id;
            ua.name     = name ?? UserInfo.nickname;
            ua.add_time = DateTime.Now;
            ua.del_flag = (int)Del_flag.正常;
            ua.state    = (int)State.可用;
            var res = User_addressService.AddEntity(ua);

            if (res.id > 0)
            {
                return(Json(SysEnum.成功, "添加地址成功"));
            }
            return(Json(SysEnum.失败, "添加地址失败"));
        }
Ejemplo n.º 4
0
        public ActionResult GetUserAddressList()
        {
            var list = User_addressService.LoadEntities(n => n.user_id == UserInfo.id && n.del_flag == (int)Del_flag.正常).ToList();

            if (list.Any())
            {
                var data = list.Select(n => new
                {
                    n.id,
                    n.name,
                    n.address,
                    add_time = n.add_time.ToString(),
                    n.state,
                }).ToList();
                return(Json(SysEnum.成功, data, "获取数据成功", list.Count));
            }
            return(Json(SysEnum.失败, "暂无数据"));
        }
Ejemplo n.º 5
0
 public ActionResult EditUserAddress(int?id)
 {
     if (id != null)
     {
         var item = User_addressService.LoadEntities(n => n.id == id && n.del_flag == (int)Del_flag.正常).FirstOrDefault();
         if (item != null)
         {
             var data = new
             {
                 item.id,
                 item.name,
                 item.address,
                 item.state
             };
             return(Json(SysEnum.成功, data, "获取地址成功", 1));
         }
         return(Json(SysEnum.失败, "未找到对象"));
     }
     return(Json(SysEnum.失败, "参数传递不正确"));
 }
Ejemplo n.º 6
0
        private int SaveAddress(string address, wx_user userInfo)
        {
            int id;
            var item = User_addressService.LoadEntities(n => n.address.Equals(address)).FirstOrDefault();

            if (item != null)
            {
                id = item.id;
            }
            else
            {
                var ad = new user_address();
                ad.del_flag = (int)Del_flag.正常;
                ad.state    = (int)State.可用;
                ad.address  = address;
                ad.user_id  = userInfo.id;
                ad.name     = userInfo.nickname;
                ad.add_time = DateTime.Now;
                var res = User_addressService.AddEntity(ad);
                id = res.id;
            }
            return(id);
        }