예제 #1
0
 void CollectEntity(MooDB db, int oldID, int newID)
 {
     revisionOld = (from r in db.HomepageRevisions
                    where r.ID == oldID
                    select r).Single<HomepageRevision>();
     revisionNew = (from r in db.HomepageRevisions
                    where r.ID == newID
                    select r).Single<HomepageRevision>();
     if (revisionOld.ID > revisionNew.ID)
     {
         HomepageRevision tmp = revisionNew;
         revisionNew = revisionOld;
         revisionOld = tmp;
     }
 }
예제 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Permission.Check("homepage.read", true)) return;

        if (!Page.IsPostBack)
        {
            using (MooDB db = new MooDB())
            {
                if (Request["revision"] != null)
                {
                    int revisionID = int.Parse(Request["revision"]);
                    revision = (from r in db.HomepageRevisions
                                where r.ID == revisionID
                                select r).SingleOrDefault<HomepageRevision>();
                    HomepageRevision latestRevision = (from r in db.HomepageRevisions
                                                       orderby r.ID descending
                                                       select r).First<HomepageRevision>();
                    isLatest = revision.ID == latestRevision.ID;
                }
                else
                {
                    revision = (from r in db.HomepageRevisions
                                orderby r.ID descending
                                select r).First<HomepageRevision>();
                    isLatest = true;
                }

                if (revision == null)
                {
                    PageUtil.Redirect(Resources.Moo.FoundNothing, "~/");
                    return;
                }

                if (!isLatest)
                {
                    if (!Permission.Check("homepage.history.read", false)) return;
                }

                Page.DataBind();
            }
        }
    }
예제 #3
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (!Page.IsValid) return;
        if (!Permission.Check("homepage.update", false)) return;

        using (MooDB db = new MooDB())
        {
            User currentUser = ((SiteUser)User.Identity).GetDBUser(db);
            HomepageRevision revision=new HomepageRevision()
            {
                Title = txtTitle.Text,
                Content = txtContent.Text,
                Reason = txtReason.Text,
                CreatedBy = currentUser
            };

            db.HomepageRevisions.AddObject(revision);

            db.SaveChanges();
            Logger.Info(db, "更新主页,新版本为#" + revision.ID);
        }

        PageUtil.Redirect("更新成功", "~/");
    }
예제 #4
0
 /// <summary>
 /// 用于向 HomepageRevisions EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToHomepageRevisions(HomepageRevision homepageRevision)
 {
     base.AddObject("HomepageRevisions", homepageRevision);
 }
예제 #5
0
 /// <summary>
 /// 创建新的 HomepageRevision 对象。
 /// </summary>
 /// <param name="id">ID 属性的初始值。</param>
 /// <param name="title">Title 属性的初始值。</param>
 /// <param name="content">Content 属性的初始值。</param>
 /// <param name="reason">Reason 属性的初始值。</param>
 public static HomepageRevision CreateHomepageRevision(global::System.Int32 id, global::System.String title, global::System.String content, global::System.String reason)
 {
     HomepageRevision homepageRevision = new HomepageRevision();
     homepageRevision.ID = id;
     homepageRevision.Title = title;
     homepageRevision.Content = content;
     homepageRevision.Reason = reason;
     return homepageRevision;
 }