Esempio n. 1
0
        public ActionResult Save(Godine god)
        {
            bool status = false;

            if (ModelState.IsValid)
            {
                using (DBModel dc = new DBModel())
                {
                    if (god.GodinaID > 0)
                    {
                        var v = dc.Godines.Where(a => a.GodinaID == god.GodinaID).FirstOrDefault();
                        if (v != null)
                        {
                            v.Opis = god.Opis;
                        }
                    }
                    else
                    {
                        dc.Godines.Add(god);
                    }
                    dc.SaveChanges();
                    status = true;
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
Esempio n. 2
0
        // GET: Godine/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Godine godine = db.Godines.Find(id);

            if (godine == null)
            {
                return(HttpNotFound());
            }
            return(View(godine));
        }
Esempio n. 3
0
        public ActionResult Delete(int id)
        {
            try
            {
                Godine godine = db.Godines.Find(id);
                db.Godines.Remove(godine);
                db.SaveChanges();
            }

            catch (DataException /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.
                return(RedirectToAction("Delete", new { id = id, saveChangesError = true }));
            }
            return(RedirectToAction("Index"));
        }
Esempio n. 4
0
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public ActionResult Edit([Bind(Include = "GodineID,Opis")] Godine godine)
        //{
        //    if (ModelState.IsValid)
        //    {
        //        db.Entry(godine).State = EntityState.Modified;
        //        db.SaveChanges();
        //        return RedirectToAction("Index");
        //    }
        //    return View(godine);
        //}

        // GET: Godine/Delete/5
        public ActionResult Delete(int?id, bool?saveChangesError = false)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            if (saveChangesError.GetValueOrDefault())
            {
                ViewBag.ErrorMessage = "Brisanje nije uspelo. Pokušajte ponovo, i ako problem i dalje postoji, pozovite vaseg administratora sistema.";
            }
            Godine godine = db.Godines.Find(id);

            if (godine == null)
            {
                return(HttpNotFound());
            }
            return(View(godine));
        }
Esempio n. 5
0
        public ActionResult Create([Bind(Include = "GodineID,Opis")] Godine godine)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.Godines.Add(godine);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (DataException /* dex */)
            {
                //Prijavi gresku

                ModelState.AddModelError("", "Ne mogu da sacuvam promene. Pokusajte ponovo,a ako se problem i dalje javlja, obratite se administratoru.");
            }

            return(View(godine));
        }