示例#1
0
 public static string get_channel_article_goods()
 {
     using (var db = new HospitalEntities())
     {
         return(Obj2Json(new
         {
             data = (from t in db.dt_channel_article_goods
                     where t.status != 2
                     orderby t.sort_id
                     select new
             {
                 t.id,
                 t.title,
                 t.sub_title,
                 t.img_url,
                 zhaiyao = t.zhaiyao.Length <= 37 ? t.zhaiyao : t.zhaiyao.Substring(0, 37) + "...",
                 t.is_hot,
                 t.source,
                 t.add_time,
             })
                    .ToList(),
             result = 1
         }));
     }
 }
示例#2
0
        public static string get_channel_article_news_detail(int id)
        {
            using (var db = new HospitalEntities())
            {
                var obj = (from t in db.dt_channel_article_news
                           orderby t.sort_id
                           where t.id == id
                           select new
                {
                    t.id,
                    t.title,
                    t.sub_title,
                    t.img_url,
                    t.zhaiyao,
                    t.content,
                    t.update_time,
                    t.add_time,
                    t.is_hot,

                    t.source,
                }).FirstOrDefault();
                var images = (from t in db.dt_article_albums
                              from c in db.dt_channel_article_news
                              where t.article_id == id && t.channel_id == c.channel_id && t.article_id == c.id
                              select new
                {
                    img_url = t.original_path.Replace("src=\"/upload", "src=\"http://guomengtech.com/upload")
                }).ToList();
                return(Obj2Json(new
                {
                    data = new
                    {
                        obj.id,
                        obj.title,
                        obj.sub_title,
                        obj.img_url,
                        obj.zhaiyao,
                        obj.update_time,
                        obj.add_time,
                        obj.is_hot,

                        obj.source,

                        content = obj.content.Replace("src=\"/upload", "src=\"http://guomengtech.com/upload"),
                        images
                    },
                    result = 1
                }));
            }
        }
示例#3
0
 public static string get_channel_article_content()
 {
     using (var db = new HospitalEntities())
     {
         return(Obj2Json(new
         {
             data = (from t in db.dt_channel_article_content
                     where t.status != 2
                     orderby t.sort_id
                     select new
             {
                 t.id,
                 t.title,
                 t.sub_title,
                 t.img_url,
                 t.zhaiyao,
                 t.is_hot,
                 t.content,
                 t.add_time,
             }).ToList(),
             result = 1
         }));
     }
 }
示例#4
0
        public static string add_or_update_user(string openid, string unionid, string photo, int sex, string nickname,
                                                int age, string phone, string interest, float latitude, float longitude, float accuracy)
        {
            using (var db = new HospitalEntities())
            {
                dt_users user = null;
                if (openid != null && openid != "")
                {
                    user = db.dt_users.FirstOrDefault(s => s.openid == openid);
                    if (user == null)
                    {
                        user           = new dt_users();
                        user.openid    = openid;
                        user.unionid   = unionid;
                        user.user_name = nickname;
                        user.password  = "******";
                        user.group_id  = 1;
                        user.status    = 0;
                        user.avatar    = photo;
                        user.sex       = sex.ToString();
                        user.age       = age;
                        user.mobile    = phone;
                        user.interest  = interest;
                        user.latitude  = latitude;
                        user.longitude = longitude;

                        user.reg_time = DateTime.Now;
                        user.GetAddress();
                        db.dt_users.Add(user);
                    }
                    else
                    {
                        if (unionid != null && unionid != "")
                        {
                            user.unionid = unionid;
                        }
                        if (photo != null && photo != "")
                        {
                            user.avatar = photo;
                        }
                        if (sex != -1)
                        {
                            user.sex = sex.ToString();
                        }
                        if (nickname != null && nickname != "")
                        {
                            user.user_name = nickname;
                        }
                        if (age != -1)
                        {
                            user.age = age;
                        }
                        if (phone != null && phone != "")
                        {
                            user.mobile = phone;
                        }
                        if (interest != null && interest != "")
                        {
                            user.interest = interest;
                        }
                        if (latitude != -1)
                        {
                            user.latitude = latitude;
                        }
                        if (longitude != -1)
                        {
                            user.longitude = longitude;
                        }

                        user.GetAddress();
                    }
                    db.SaveChanges();
                }

                return(Obj2Json(new
                {
                    user,
                    result = 1
                }));
            }
        }