コード例 #1
0
        public ActionResult Delete(int id)
        {
            ClanciTxt tekst = (from t in oi.ClanciTxts
                               where t.IDClanak == id
                               select t).Single();

            try {
                oi.ClanciTxts.DeleteOnSubmit(tekst);
                oi.SubmitChanges();
            }
            catch
            {
                return(RedirectToAction("Index"));
            }

            Clanci clanak = (from c in oi.Clancis
                             where c.IDClanak == id
                             select c).Single();

            try
            {
                oi.Clancis.DeleteOnSubmit(clanak);
                oi.SubmitChanges();
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(RedirectToAction("Index"));
            }
        }
コード例 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Clanci clanci = db.Clancis.Find(id);

            db.Clancis.Remove(clanci);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #3
0
    public int maxID(Clanci a)
    {
        var id = from e in ent.Clanci
                 orderby e.ClanakID descending
                 select e.ClanakID;

        return(id.First());
    }
コード例 #4
0
 public ActionResult Edit([Bind(Include = "Id,Naslov,CasopisID,broj,AutorID")] Clanci clanci)
 {
     if (ModelState.IsValid)
     {
         db.Entry(clanci).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.AutorID   = new SelectList(db.Autoris, "Id", "ImeIPrezime", clanci.AutorID);
     ViewBag.CasopisID = new SelectList(db.Casopis, "Id", "Naziv", clanci.CasopisID);
     return(View(clanci));
 }
コード例 #5
0
        public ActionResult Edit(int?id, FormCollection fc)
        {
            if (id != null)
            {
                Clanci c = (from cl in oi.Clancis
                            where cl.IDClanak == id
                            select cl).Single();

                Korisnik k = (Korisnik)Session["Korisnik"];
                c.IDKorisnik = k.IDKorisnik;
                c.IDSBK      = Convert.ToInt32(fc["IDSBK"]);
                c.Datum      = fc["Datum"];
                c.Tip        = fc["Tip"];

                try
                {
                    oi.SubmitChanges();
                }
                catch (Exception ex)
                {
                    List <SpecificnostiBudzetskihKorisnika> specifikacijeBK = (from s in oi.SpecificnostiBudzetskihKorisnikas
                                                                               select s).ToList();
                    ViewBag.SpecificnostiBudzetskihKorisnika = specifikacijeBK;
                    ViewBag.Greska = ex.Message;
                    return(View());
                }

                ClanciTxt cTxt = (from m in oi.ClanciTxts
                                  where m.IDClanak == c.IDClanak
                                  select m).Single();
                cTxt.Naslov = fc["Naslov"];
                cTxt.Tekst  = fc["Tekst"];
                try
                {
                    oi.SubmitChanges();
                    return(RedirectToAction("Index"));
                }
                catch (Exception ex)
                {
                    List <SpecificnostiBudzetskihKorisnika> specifikacijeBK = (from s in oi.SpecificnostiBudzetskihKorisnikas
                                                                               select s).ToList();
                    ViewBag.SpecificnostiBudzetskihKorisnika = specifikacijeBK;
                    ViewBag.Greska = ex.Message;
                    return(View());
                }
            }
            else
            {
                return(RedirectToAction("Create"));
            }
        }
コード例 #6
0
        // GET: Clancis/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Clanci clanci = db.Clancis.Find(id);

            if (clanci == null)
            {
                return(HttpNotFound());
            }
            return(View(clanci));
        }
コード例 #7
0
        // GET: Clancis/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Clanci clanci = db.Clancis.Find(id);

            if (clanci == null)
            {
                return(HttpNotFound());
            }
            ViewBag.AutorID   = new SelectList(db.Autoris, "Id", "ImeIPrezime", clanci.AutorID);
            ViewBag.CasopisID = new SelectList(db.Casopis, "Id", "Naziv", clanci.CasopisID);
            return(View(clanci));
        }
コード例 #8
0
        public ActionResult Edit(int id)
        {
            Clanci clanak = (from c in oi.Clancis
                             where c.IDClanak == id
                             select c).Single();

            ClanciTxt tekst = (from c in oi.ClanciTxts
                               where c.IDClanak == clanak.IDClanak
                               select c).Single();

            ViewBag.ClanciTxt = tekst;
            List <SpecificnostiBudzetskihKorisnika> specifikacijeBK = (from s in oi.SpecificnostiBudzetskihKorisnikas
                                                                       select s).ToList();

            ViewBag.SpecificnostiBudzetskihKorisnika = specifikacijeBK;
            return(View(clanak));
        }
コード例 #9
0
        public ActionResult Create(FormCollection fc)
        {
            Clanci   c = new Clanci();
            Korisnik k = (Korisnik)Session["Korisnik"];

            c.IDKorisnik = k.IDKorisnik;
            c.IDSBK      = Convert.ToInt32(fc["IDSBK"]);
            c.Datum      = fc["Datum"];
            c.Tip        = fc["Tip"];

            try {
                oi.Clancis.InsertOnSubmit(c);
                oi.SubmitChanges();
            }
            catch (Exception ex)
            {
                List <SpecificnostiBudzetskihKorisnika> specifikacijeBK = (from s in oi.SpecificnostiBudzetskihKorisnikas
                                                                           select s).ToList();
                ViewBag.SpecificnostiBudzetskihKorisnika = specifikacijeBK;
                ViewBag.Greska = ex.Message;
                return(View());
            }

            int id = (from o in oi.Clancis
                      select o.IDClanak).Max();
            ClanciTxt cTxt = new ClanciTxt();

            cTxt.IDClanak = id;
            cTxt.Naslov   = fc["Naslov"];
            cTxt.Tekst    = fc["Tekst"];
            try
            {
                oi.ClanciTxts.InsertOnSubmit(cTxt);
                oi.SubmitChanges();
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                List <SpecificnostiBudzetskihKorisnika> specifikacijeBK = (from s in oi.SpecificnostiBudzetskihKorisnikas
                                                                           select s).ToList();
                ViewBag.SpecificnostiBudzetskihKorisnika = specifikacijeBK;
                ViewBag.Greska = ex.Message;
                return(View());
            }
        }
コード例 #10
0
    /// <summary>
    /// Dodaje clanak u bazu
    /// </summary>
    /// <param name="nazivClanka"></param>
    /// <param name="textClanka"></param>
    /// <param name="galerijaid"></param>
    public void DodajClanak(string nazivClanka, string textClanka, int galerijaid)
    {
        Clanci cl = new Clanci();

        cl.NazivClanka = nazivClanka;
        cl.TextClanka  = textClanka;
        cl.GalerijaID  = galerijaid;
        cl.ClanakID    = maxID(cl) + 1;


        try
        {
            ent.Clanci.AddObject(cl);
            ent.SaveChanges();
        }
        catch
        {
            throw new Exception("Dodavanje clanka nije uspjelo");
        }
    }