Example #1
0
        //检查是否是vip用户
        public static object Check(string userid)
        {
            TB_USER user = null;

            using (XMWBEntities entity = new XMWBEntities())
            {
                try
                {
                    user = entity.TB_USER.SingleOrDefault(t => t.CM_USERID == userid);
                }
                catch (Exception e)
                {
                    return(ReturnResult.Return("4", "网络异常,请稍后再试", null, null));
                }
            }

            if (user == null)
            {
                return(ReturnResult.Return("2", "不存在此用户", null, null));
            }
            else if (user.CM_EXPIRINGTIME == null || (user.CM_EXPIRINGTIME != null && user.CM_EXPIRINGTIME < DateTime.Now))
            {
                return(ReturnResult.Return("3", "Vip过期", null, null));
            }
            else
            {
                return(ReturnResult.Return("0", "权限正常", null, null));
            }
        }
Example #2
0
        public ActionResult Preview(string id, string avid)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                return(new EmptyResult());
            }
            else
            {
                using (XMWBEntities entity = new XMWBEntities())
                {
                    TB_LSARTICLE at = entity.TB_LSARTICLE.SingleOrDefault(t => t.CM_ID == id);

                    if (at != null)
                    {
                        TB_ARTICLE ad = new TB_ARTICLE();
                        ad.CM_USERID  = at.CM_USERID;
                        ad.CM_ADVMTID = string.IsNullOrWhiteSpace(avid) ? "" : avid;
                        ad.CM_AUTHOR  = at.CM_AUTHOR;
                        ad.CM_CONTENT = at.CM_CONTENT;
                        ad.CM_ID      = at.CM_ID;
                        ad.CM_TIME    = DateTime.Now;
                        ad.CM_TITLE   = at.CM_TITLE;
                        ad.CM_TYPE    = 2;
                        ad.CM_ISPASS  = 0;

                        entity.TB_ARTICLE.Add(ad);
                        entity.Set <TB_LSARTICLE>().Remove(at);
                        entity.SaveChanges();

                        return(View(ad));
                    }
                    else
                    {
                        TB_ARTICLE ARTICLE = entity.TB_ARTICLE.SingleOrDefault(t => t.CM_ID == id);
                        if (ARTICLE != null)
                        {
                            TB_USER user = entity.TB_USER.SingleOrDefault(t => t.CM_USERID == ARTICLE.CM_USERID);
                            if (user != null)
                            {
                                if (user.CM_EXPIRINGTIME < DateTime.Now)
                                {
                                    ARTICLE = null;
                                }
                            }
                            else
                            {
                                ARTICLE = null;
                            }
                        }
                        return(View(ARTICLE));
                    }
                }
            }
        }
Example #3
0
        //通过手机号码登录
        public static string Login(string phone, string password)
        {
            using (XMWBEntities entity = new XMWBEntities())
            {
                TB_USER user = entity.TB_USER.SingleOrDefault(t => t.CM_PHONE == phone && t.CM_PASSWORD == password);

                if (user != null)
                {
                    return(handle.DES.GetLoginString(user.CM_USERID));
                }
                else
                {
                    return("2");
                }
            }
        }
Example #4
0
        public static string Save(string id, string title, string time, string author, string content, string userid)
        {
            using (XMWBEntities entity = new XMWBEntities())
            {
                TB_LSARTICLE ad = entity.TB_LSARTICLE.SingleOrDefault(t => t.CM_USERID == userid);
                if (ad == null)
                {
                    try
                    {
                        TB_LSARTICLE lsad = new TB_LSARTICLE();
                        lsad.CM_TITLE   = title;
                        lsad.CM_TIME    = DateTime.Now;
                        lsad.CM_AUTHOR  = author;
                        lsad.CM_CONTENT = content;
                        lsad.CM_USERID  = userid;
                        lsad.CM_ID      = id;

                        entity.TB_LSARTICLE.Add(lsad);
                        entity.SaveChanges();

                        return(handle.ObjToJson.ToJson(lsad));
                    }
                    catch (Exception e)
                    {
                        return("5");
                    }
                }
                else
                {
                    try
                    {
                        ad.CM_TITLE   = title;
                        ad.CM_TIME    = DateTime.Now;
                        ad.CM_AUTHOR  = author;
                        ad.CM_CONTENT = content;

                        entity.SaveChanges();

                        return(handle.ObjToJson.ToJson(ad));
                    }
                    catch (Exception e)
                    {
                        return("5");
                    }
                }
            }
        }
Example #5
0
        public static string Revise(string id, string content, string advertid, string title, string date, string author)
        {
            using (XMWBEntities entity = new XMWBEntities())
            {
                TB_LSARTICLE at = entity.TB_LSARTICLE.SingleOrDefault(t => t.CM_ID == id);
                try
                {
                    if (at != null)
                    {
                        TB_ARTICLE ad = new TB_ARTICLE();
                        ad.CM_USERID  = at.CM_USERID;
                        ad.CM_ADVMTID = string.IsNullOrWhiteSpace(advertid) ? "" : advertid;
                        ad.CM_AUTHOR  = string.IsNullOrWhiteSpace(author) ? at.CM_AUTHOR : author;
                        ad.CM_CONTENT = content;
                        ad.CM_ID      = at.CM_ID;
                        ad.CM_TIME    = DateTime.Now;
                        ad.CM_TITLE   = string.IsNullOrWhiteSpace(title) ? at.CM_TITLE : title;
                        ad.CM_TYPE    = 2;
                        ad.CM_ISPASS  = 0;

                        entity.TB_ARTICLE.Add(ad);
                        entity.Set <TB_LSARTICLE>().Remove(at);
                        entity.SaveChanges();
                        return("0");
                    }
                    else
                    {
                        return("3");
                    }
                }
                catch (Exception e)
                {
                    return("2");
                }
            }
        }