//
 // GET: /Clanci/
 public ActionResult Index()
 {
     ClanciServisObrada c = new ClanciServisObrada();
     ViewBag.Search = false;
     return View(c.getAllClanci());
 }
Пример #2
0
 //
 // GET: /Clanci/
 public ActionResult Index()
 {
     ClanciServisObrada c = new ClanciServisObrada();
     return View(c.getAllClanci());
 }
 public ActionResult Edit(int id)
 {
     ClanciServisObrada c = new ClanciServisObrada();
     return View(ClanciServisObrada.getClanakById(id));
 }
Пример #4
0
        public List<ClanciServisObrada> getAllClanci()
        {
            using (Spajanje s = new Spajanje())
            {

                List<ClanciServis> tst = (from c in s.Context.Clanci
                                          join sa in s.Context.Sadrzaji
                                          on c.ClanakID equals sa.ClanakID
                                          join ts in s.Context.TagVrste
                                          on c.TagVrstaID equals ts.TagVrstaID
                                          select new ClanciServis
                                          {
                                              ClanakId = c.ClanakID,
                                              slika = c.Slika,
                                              popularnost = (double)c.Popularnost,
                                              ocjena = (int)c.Ocjenjeno,
                                              naslov = sa.Naslov,
                                              opis = sa.Opis,
                                              tekst = sa.Tekst,
                                              klasa = ts.Opis,
                                              vrsta = (int)ts.Vrsta,
                                              komentari=(from k in s.Context.Komentari where k.ClanakID==c.ClanakID select k).Count()

                                          }).ToList();

                List<ClanciServisObrada> finals = new List<ClanciServisObrada>();
                ClanciServisObrada tempF;
                List<TagVrste> SveVrste = GetAllVrste();
                foreach (TagVrste it in SveVrste)
                {

                    try
                    {
                        tempF = null;
                        tempF = new ClanciServisObrada();
                        tempF.ClanciOrig = (from lis in tst where lis.vrsta == it.Vrsta select lis).ToList();
                        tempF.klasa = (from lis in tempF.ClanciOrig select lis.klasa).FirstOrDefault().ToString();
                        finals.Add(tempF);

                    }
                    catch (Exception)
                    {

                    }

                }
                List<Tags> tagovi;
                //tagovi=(from tc in s.Context.TagClanci join clan in s.Context.Clanci on tc.ClanakID equals clan.ClanakID
                //join t in s.Context.Tags on tc.TagID equals t.TagID select t).ToList()
                foreach (ClanciServisObrada repl in finals)
                {
                    foreach (ClanciServis cl in repl.ClanciOrig)
                    {
                        cl.tekst=cl.tekst.Substring(0, (cl.tekst.Length*20)/100);
                        cl.tekst = cl.tekst.Substring(0,cl.tekst.LastIndexOf(' '));
                        cl.tekst += "...";
                        tagovi = null;
                        tagovi = (from tc in s.Context.TagClanci join clan in s.Context.Clanci on tc.ClanakID equals clan.ClanakID
                join t in s.Context.Tags on tc.TagID equals t.TagID where tc.ClanakID==cl.ClanakId select t).ToList();
                        foreach (Tags tg in tagovi)
                        {
                            cl.tekst = MvcHtmlString.Create(cl.tekst.Replace(tg.Ime, "<div class='Clanci-Tag'>" + tg.Ime + "</div>")).ToString();

                        }
                    }
                }

                return finals;

            }
        }