Ejemplo n.º 1
0
        public WikiTitle ExportToModel()
        {
            try
            {
                WikiTitle ap = new WikiTitle();
                        ap.TitleId = Id;
                        ap.Files = Files;
                        ap.Categories = Categories;
                        ap.Content = Content;
                        ap.isLocked = isLocked;
                        ap.MaxVersion = MaxVersion;
                        ap.Name = Name;
                        ap.Slug = Slug;
                        ap.Wiki = Wiki;
                        ap.WrittenBy = WrittenBy.Id;

                return ap;

            }
            catch (Exception ex)
            {

                CommonTools.ErrorReporting(ex);
                return null;

            }
        }
Ejemplo n.º 2
0
        public WikiTitle Add(string wikiname, string name, string slug, ApplicationUser user)
        {
            try
            {
                WikiTitle ap = null;

                if (wikiname != null)// && slug != null)
                {
                    Models.Wiki wiki = this.GetWiki(wikiname);
                    ap = new WikiTitle();
                    ap.Name = name;
                    ap.Slug = slug;
                    ap.Wiki = wiki;
                    ap.WrittenBy = user.Id;
                }
                return ap;

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

                CommonTools.ErrorReporting(ex);
                return null;
            }
        }
Ejemplo n.º 3
0
        public void AddTitleToCategory(string wikiname,int catid,WikiTitle title)
        {
            try
            {
                if (CommonTools.isEmpty(wikiname) == false && catid > 0 && title != null
                     )
                {
                    this.rp.AddTitleToCategory(wikiname, catid, title);
                }
            }
            catch (Exception ex)
            {

                CommonTools.ErrorReporting(ex);

            }
        }
Ejemplo n.º 4
0
        public void EditTitle(string wikiname,int id,WikiTitle newvals)
        {
            try
            {
                if ( CommonTools.isEmpty(wikiname)==false && this.wrepo.WikiExists(wikiname)==true
                    && id>0 && newvals!=null)
                {
                    this.wrepo.EditTitle(wikiname, id, newvals);
                }

            }
            catch (Exception ex)
            {

                CommonTools.ErrorReporting(ex);

            }
        }
Ejemplo n.º 5
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;
            }
        }
Ejemplo n.º 6
0
        public void Delete(WikiTitle title,ApplicationUser user)
        {
            try
            {
                if (title != null && user != null)
                {
                    Wiki wk = CommonTools.wkmngr.GetWiki(title.Wiki.Name);
                    if ( wk !=null  && CommonTools.usrmng.UserHasAccessToWiki(user,wk,true))
                    {
                        wrepo.DeleteTitleById(wk.Name, title.TitleId);
                    }

                }

            }
            catch (Exception ex)
            {

                CommonTools.ErrorReporting(ex);
                // return null;
            }
        }
Ejemplo n.º 7
0
        public void ImportFromModel(WikiTitle md)
        {
            try
            {
                if (md != null && CommonTools.isEmpty(md.WrittenBy) == false)
                {
                    ApplicationUser user = CommonTools.usrmng.GetUserbyID(md.WrittenBy);
                    if (user != null)
                    {
                        this.Id = md.TitleId;
                        this.Files = md.Files;
                        this.Categories = md.Categories;
                        this.Content = md.Content;
                        this.isLocked = md.isLocked;
                        this.MaxVersion = md.MaxVersion;
                        this.Name = md.Name;
                        this.Slug = md.Slug;
                        this.Wiki = md.Wiki;
                        this.WrittenBy= user;

                    }
                }
            }
            catch (Exception ex)
            {

                CommonTools.ErrorReporting(ex);

            }
        }
Ejemplo n.º 8
0
        public void EditTitle(string wikiname, int id, WikiTitle newvals)
        {
            try
            {
                if (CommonTools.isEmpty(wikiname) == false && this.WikiExists(wikiname) == true
                    && id > 0 && newvals != null)
                {
                    WikiTitle oldvals = this.Get(wikiname, id);
                    this.db.Entry(oldvals).CurrentValues.SetValues(newvals);

                    this.db.SaveChanges();
                    this.MarkWikiAsUpdated(this.GetWiki(wikiname));
                }

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

                CommonTools.ErrorReporting(ex);

            }
        }
Ejemplo n.º 9
0
        public Boolean CategoryHasTitle(string catname, string wikiname,WikiTitle title)
        {
            try
            {
                Boolean ap = false;
                if (!CommonTools.isEmpty(wikiname) && this.WikiExists(wikiname)
                    && !CommonTools.isEmpty(catname) && title !=null)
                {
                    List<WikiCategory> cats = this.GetCategorybyWiki(wikiname);
                    if (cats == null)
                    {
                        return false;
                    }
                    else
                    {
                        Boolean t ,c= false;
                        c = cats.Exists(s => s.Title == catname & s.Titles.Contains(title));
                        // cats.Find(s => s.Titles.Contains(title));
                        ap = c;
                    }
                }
                return ap;

            }
            catch (Exception ex)
            {

                CommonTools.ErrorReporting(ex);
                return false;
            }
        }
Ejemplo n.º 10
0
        public void AddTitleToCategory(string wikiname, int catid, WikiTitle title)
        {
            try
            {
                if (CommonTools.isEmpty(wikiname) == false && catid > 0 && title != null)
                {
                    WikiCategory cat = this.GetCategorybyId(catid);
                    if (cat != null)
                    {
                        if (title.Categories == null)
                        {
                            title.Categories = new List<WikiCategory>();
                        }
                        if (title.Categories.FirstOrDefault(x => x.Id == catid) == null &&
                            !this.CategoryHasTitle(cat.Title, wikiname, title))
                        {
                            title.Categories.Add(cat);
                            CommonTools.titlemngr.EditTitle(wikiname, title.TitleId, title);
                            if ( cat.Titles ==null)
                            {
                                cat.Titles = new List<WikiTitle>();
                            }
                            cat.Titles.Add(title);
                            this.EditCategory(catid, wikiname, cat);

                        }

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

                CommonTools.ErrorReporting(ex);

            }
        }
Ejemplo n.º 11
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;
            }
        }