GetWikiByID() 공개 메소드

public GetWikiByID ( int p ) : Article
p int
리턴 Igman.DB.DAL.Article
 public ActionResult WikiEdit(int? id)
 {
     if (id.HasValue)
     {
         using (DBBL Baza = new DBBL())
         {
             ViewBag.Kategorije = Baza.GetKatogorije();
             Article w = Baza.GetWikiByID(id.Value);
             TempData["w"] = w;
             TempData["w-tag"] = w.Tags.ToList();
             TempData["w-cat"] = w.Categories.ToList();
         }
         CheckUser();
         return View();
     }
     else
         return View("index");
 }
        public ActionResult Wiki(int? id)
        {
            CheckUser();
            if (id.HasValue)
            {
                using (DBBL Baza = new DBBL())
                {
                    Article a = Baza.GetWikiByID(id.Value);
                    int rating = 0;
                    if (a != null)
                    {

                        int suma = 0;
                        if (a.ArticlesRatings.Count > 0)
                        {
                            foreach (var rat in a.ArticlesRatings.ToList())
                            {
                                suma += rat.Score.Value;
                            }

                            rating = (suma / a.ArticlesRatings.Count);
                        }

                        TempData["wiki"] = a;
                        TempData["tags"] = a.Tags.ToList();
                        TempData["grup"] = a.Categories.ToList();
                        TempData["likes"] = a.ArticlesLikes.ToList().Count;
                        TempData["rating"] = rating;
                        TempData["Kom"] = a.Comments.OrderByDescending(x => x.CommentID).ToList();

                        ExteranlBase eb = new ExteranlBase(a.Tags.ToList());

                        TempData["ExteranlWiki"] = eb.Preporuci();

                        Baza.IncremenViews(a.ArticlesID);

                        TempData["RecWiki"] = GetPreporuka(a);
                        return View();
                    }
                }
            }
            return RedirectToAction("Index", "Wellcome");
        }
        public string Like(int? id)
        {
            CheckUser();
            Article a = null;
            int Uid = Autorizacija.Autorizacija.GetCurrentUser(this.HttpContext).UserID;
            string likes = "";
            if (id.HasValue)
            {
                using (DBBL Baza = new DBBL())
                {

                    ArticlesLike al = new ArticlesLike()
                    {
                        ArticleID = id.Value,
                        UserID = Uid,
                        GUID = Guid.NewGuid(),
                        DateLike = DateTime.Now,
                        CreatorIP = this.Request.GetIpAdresa()
                    };
                    try
                    {
                        Baza.IncetrementLikes(al);
                    }
                    catch (Exception)
                    {

                        return "False";
                    }

                    a = Baza.GetWikiByID(id.Value);
                    likes = a.ArticlesLikes.Count.ToString();
                }

            }
            return likes;
        }
        public string Rating(int? id, int? score)
        {
            Article a = null;
            int Uid = Autorizacija.Autorizacija.GetCurrentUser(this.HttpContext).UserID;
            string rating = "";
            if (id.HasValue && score.HasValue)
            {
                using (DBBL Baza = new DBBL())
                {

                    ArticlesRating ar = new ArticlesRating()
                    {
                        ArticlesID = id.Value,
                        UserID = Uid,
                        GUID = Guid.NewGuid(),
                        DateRating = DateTime.Now,
                        Score = score
                    };
                    try
                    {
                        Baza.AddRating(ar);
                    }
                    catch (Exception)
                    {

                        return "False";
                    }

                    a = Baza.GetWikiByID(id.Value);
                    int suma = 0;
                    foreach (var rat in a.ArticlesRatings.ToList())
                    {
                        suma += rat.Score.Value;
                    }
                    rating = (suma / a.ArticlesRatings.Count).ToString();
                }

            }
            return rating;
        }
        public ActionResult EditWiki(string Naslov, string Content, string jsonTag, string jsonKat, int? WikiId)
        {
            if (WikiId.HasValue)
            {
                Article a;
                using (DBBL Baza = new DBBL())
                {
                    a = Baza.GetWikiByID(WikiId.Value);

                    a.Name = Naslov;
                    a.Content = Server.HtmlDecode(Content).Replace("'", "'").Trim();
                    a.CreatorIP = this.HttpContext.Request.GetIpAdresa();
                    a.CreatorUserAgent = this.HttpContext.Request.UserAgent;
                    a.DatePublish = DateTime.Now;
                    a.GUID = Guid.NewGuid();
                    a.IsActive = true;
                    a.Views = 0;
                    a.IsPublish = true;
                    a.UserID = Autorizacija.Autorizacija.GetCurrentUser(this.HttpContext).UserID;

                    var ListaTagova = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Models.Json.Tag>>(jsonTag);
                    var ListaKategorija = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Models.Json.Kategorija>>(jsonKat);

                    Baza.ClearTagsAndCategiry(a.ArticlesID);

                    List<Igman.DB.DAL.Tag> listTempTag = SinhronyzeWithDB(ListaTagova.Where(x => x.TagID == "-1").ToList(), ListaTagova.Where(x => x.TagID != "-1").ToList());
                    List<Category> listaKategorija = SinhronyzeWithDB(ListaKategorija);

                    a.Categories = new List<Category>(listaKategorija);
                    a.Tags = new List<Igman.DB.DAL.Tag>(listTempTag);

                    a = Baza.EditWiki(a);

                    #region Lucine
                    LuceneEngine.LuceneDbEngine ldbe = new LuceneEngine.LuceneDbEngine();
                    ldbe.UpdateWiki(a);
                    #endregion

                    TempData["wikiSuccess"] = true;
                    return RedirectToRoute("Wiki-Edit", new { id = a.ArticlesID });

                }
            }
            return RedirectToAction("index", "Articles");
        }