/// <summary>
            /// 提交表单
            /// </summary>
            protected override object OnSubmit(Article saveTo)
            {
                if (saveTo.Author == null)
                {
                    var sessionManager = Application.Ioc.Resolve <SessionManager>();
                    var session        = sessionManager.GetSession();
                    var userManager    = Application.Ioc.Resolve <UserManager>();
                    saveTo.Author = userManager.Get(session.ReleatedId.Value);
                }
                saveTo.Title   = Title;
                saveTo.Summary = Summary;
                var classManager = Application.Ioc.Resolve <GenericClassManager>();
                var tagManager   = Application.Ioc.Resolve <GenericTagManager>();

                saveTo.Classes = new HashSet <GenericClass>(
                    classManager.GetMany(c => ArticleClass.Contains(c.Id)));
                saveTo.Tags = new HashSet <GenericTag>(
                    tagManager.GetMany(t => ArticleTag.Contains(t.Id)));
                saveTo.DisplayOrder = DisplayOrder;
                saveTo.Contents     = Contents;
                saveTo.Remark       = Remark;
                return(this.SaveSuccessAndCloseModal());
            }
예제 #2
0
            /// <summary>
            /// 提交表单
            /// </summary>
            protected override object OnSubmit(IDatabaseContext context, Database.Article saveTo)
            {
                if (saveTo.Id <= 0)
                {
                    var sessionManager = Application.Ioc.Resolve <SessionManager>();
                    var session        = sessionManager.GetSession();
                    var userRepository = RepositoryResolver.Resolve <User>(context);
                    saveTo.Author     = userRepository.GetById(session.ReleatedId);
                    saveTo.CreateTime = DateTime.UtcNow;
                }
                saveTo.Title   = Title;
                saveTo.Summary = Summary;
                var classRepository = RepositoryResolver.Resolve <GenericClass>(context);
                var tagRepository   = RepositoryResolver.Resolve <GenericTag>(context);

                saveTo.Classes      = new HashSet <GenericClass>(classRepository.GetMany(c => ArticleClass.Contains(c.Id)));
                saveTo.Tags         = new HashSet <GenericTag>(tagRepository.GetMany(t => ArticleTag.Contains(t.Id)));
                saveTo.DisplayOrder = DisplayOrder;
                saveTo.Contents     = Contents;
                saveTo.Remark       = Remark;
                saveTo.LastUpdated  = DateTime.UtcNow;
                return(new {
                    message = new T("Saved Successfully"),
                    script = ScriptStrings.AjaxtableUpdatedAndCloseModal
                });
            }