예제 #1
0
        public WikiTitle AddContent(String wikiname , WikiTitle title, WikiContent cont,int cid,ApplicationUser usr )
        {
            try
            {
                WikiTitle ap= null;
                if (CommonTools.isEmpty(wikiname) == false && (cid > 0)
                  && title != null && cont != null)
                {
                    WikiCategory cat = CommonTools.catmngr.GetCategoryById(cid);
                    Wiki wk = CommonTools.wkmngr.GetWiki(wikiname);

                    if (wk != null && cat != null && usr != null)
                    {

                       ap= repository.AddContentTitle(wikiname, title, cont,cat,usr);

                    }
                }
                else if (CommonTools.isEmpty(wikiname) == false && (cid == 0)
                && title != null && cont != null)
                {
                    Wiki wk = CommonTools.wkmngr.GetWiki(wikiname);

                    if (wk != null  && usr != null)
                    {

                        ap = repository.AddContentTitle(wikiname, title, cont, null, usr);

                    }
                }
                    return ap;
            }
            catch (Exception ex)
            {

                CommonTools.ErrorReporting(ex);
                return null;
            }
        }
예제 #2
0
        public void EditContentPost(string wikiname, WikiContent cont, ApplicationUser user,int id)
        {
            try
            {
                if (cont != null)
                {
                    WikiTitle title =this.repository.Get(wikiname, id);
                 //   Title title = cont.Title;
                    if (CommonTools.isEmpty(wikiname) == false
                 && id >0 && cont != null)
                    {

                        this.repository.AddContent(wikiname, id, cont,  user);

                    }
                }

            }
            catch (Exception ex)
            {

                CommonTools.ErrorReporting(ex);
                //return -1;
            }
        }
예제 #3
0
        public WikiTitle AddContentTitle(string wikiname, WikiTitle title , WikiContent cont,WikiCategory cat,ApplicationUser usr)
        {
            try
            {
                WikiTitle ap = null;
                if (wikiname != null && title !=null && cont != null && cat!=null)
                {
                  var  a=this.CategoryExistsinWiki(cat.Title, wikiname);
                    Wiki wk = this.GetWiki(wikiname);
                   // if (wk != null &&a ==true)
                    {
                        //  cont.Id = id;

                        title.Categories = new List<WikiCategory>();
                        if (cat != null)
                        {
                            title.Categories.Add(cat);
                        }
                        title.Wiki = wk;
                        title.WrittenBy = usr.Id;
                        title.Slug = title.Name.Replace(" ", "_");

                        cont.Title = title;
                        cont.TitleId = title.TitleId;
                        cont.Version = 1;
                        cont.Wiki = wk;
                        cont.WrittenBy = usr.Id;
                        cont.VersionDate = DateTime.Now;
                       cont.ContentId = this.db.Content.Count() + 1;
                        title.Content = cont;
                        if (wk.Content == null)
                        {
                            wk.Content = new List<Core.Data.Models.WikiContent>();
                        }
                        wk.Content.Add(cont);
                        if (wk.Titles == null)
                        {
                            wk.Titles = new List<WikiTitle>();
                        }
                        wk.Titles.Add(title);
                        db.Content.Add(cont);
                        db.Title.Add(title);

                      //  this.db.Configuration.ValidateOnSaveEnabled = false;
                        db.SaveChanges();
                        this.MarkWikiAsUpdated(wk);
                        ap = title;

                    }
                }
                return ap;

            }
            catch (ValidationException ex) { CommonTools.ValidationErrorReporting(ex); return null; }
            catch (Exception ex)
            {

                CommonTools.ErrorReporting(ex);
                return null;
            }
        }
예제 #4
0
        public void AddContent(string wikiname, int tid, WikiContent cont,  ApplicationUser usr)
        {
            try
            {
                if (wikiname != null && tid > 0 && cont != null)
                {
                    //  var a = this.CategoryExistsinWiki(cat.Name, wikiname);
                    Wiki wk = this.GetWiki(wikiname);
                    //Content cont1 = new Content();
                    WikiTitle title = this.Get(wikiname, tid);

                    if (wk != null && title != null)
                    {
                        //  cont.Id = id;
                        int i = cont.ContentId;
                        if (i > 0)
                        {
                            i++;
                        }
                        else
                        {
                            i = db.Content.Count() + 1;
                        }
                        cont.ContentId = i;

                        if (this.CountWithTitleId(wikiname, title.TitleId) > 0)
                        {
                            cont.Version = this.CountWithTitleId(wikiname, title.TitleId) + 1;
                        }
                        else
                        {
                            cont.Version = 1;
                        }

                        //cont1.Id = db.Content.Count() + 1;
                        cont.Title = title;
                        cont.TitleId = title.TitleId;
                        // cont1.Version = cont.Version+ 1;

                        //if (wk.Content == null)
                        //{
                        //    wk.Content = new List<Core.Data.Models.Content>();
                        //}
                        wk.Content.Add(cont);
                        cont.Wiki = wk;
                        cont.WrittenBy = usr.Id;
                        cont.VersionDate = DateTime.Now;
                        //cont1.Source = cont.Source;

                        //if (wk.Titles == null)
                        //{
                        //    wk.Titles = new List<Title>();
                        //}

                        db.Content.Add(cont);

                        //  db.Title.Add(title);
                        this.MarkWikiAsUpdated(wk);
                        db.SaveChanges();

                    }
                }

            }
            catch (ValidationException ex) { CommonTools.ValidationErrorReporting(ex); }
            catch (Exception ex)
            {

                CommonTools.ErrorReporting(ex);
                //return null;
            }
        }
예제 #5
0
        public WikiContent ExportToModel()
        {
            try
            {
                WikiContent ap = new WikiContent();

                        ap.ContentId = Id;
                        ap.Source = Source;
                        ap.Title = Title;
                        ap.Version = Version;
                        ap.RenderedSource = RenderedSource;
                        ap.VersionDate = VersionDate;
                        ap.Wiki = Wiki;
                if (WrittenBy != null)
                {
                    ap.WrittenBy = WrittenBy.Id;
                }

                return ap;

                }

            catch (Exception ex)
            {

                CommonTools.ErrorReporting(ex);
                return null;

            }
        }
예제 #6
0
        public void ImportFromModel(WikiContent md)
        {
            try
            {
                if (md != null && CommonTools.isEmpty(md.WrittenBy) == false)
                {
                    ApplicationUser user = CommonTools.usrmng.GetUserbyID(md.WrittenBy);
                    if (user != null)
                    {
                        this.Id = md.ContentId;
                        this.Source = md.Source;
                        this.Title = md.Title;
                        this.Version = md.Version;
                        this.RenderedSource = md.RenderedSource;
                        this.VersionDate = md.VersionDate;
                        this.Wiki = md.Wiki;
                        this.WrittenBy = user;

                    }
                }
            }
            catch (Exception ex)
            {

                CommonTools.ErrorReporting(ex);

            }
        }