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)); } } } }
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"); } } }