Ejemplo n.º 1
0
        public async Task <ActionResult> DeleteConfirmedOtpad(string id)
        {
            otpad otpad = await db.otpad.FindAsync(int.Parse(id));

            db.otpad.Remove(otpad);
            await db.SaveChangesAsync();

            return(RedirectToAction("IndexOtpad"));
        }
Ejemplo n.º 2
0
        // GET: otpads/Delete/5
        public async Task <ActionResult> DeleteOtpad(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            otpad otpad = await db.otpad.FindAsync(int.Parse(id));

            if (otpad == null)
            {
                return(HttpNotFound());
            }
            return(View("~/Views/Administrator/Otpad/DeleteOtpad.cshtml", otpad));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> EditOtpad([Bind(Include = "idOtpad,vrstaOtpad")] otpad otpad)
        {
            if (ModelState.IsValid)
            {
                var otpadMatch = from c in db.otpad where c.vrstaOtpad.Equals(otpad.vrstaOtpad) select c;

                if (otpadMatch.Count() != 0)
                {
                    ModelState.AddModelError(string.Empty, "Već postoji otpad sa istim imenom.");
                    return(View("~/Views/Administrator/Otpad/EditOtpad.cshtml", otpad));
                }

                db.Entry(otpad).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("IndexOtpad"));
            }
            return(View("~/Views/Administrator/Otpad/EditOtpad.cshtml", otpad));
        }
Ejemplo n.º 4
0
        public async Task <ActionResult> CreateOtpad([Bind(Include = "idOtpad,vrstaOtpad")] otpad otpad)
        {
            var rezOtpad = db.otpad.OrderBy(x => x.idOtpad).AsEnumerable().Select(x => x.idOtpad);
            int rezIDInt;

            if (ModelState.IsValid)
            {
                if (rezOtpad.Count() != 0)
                {
                    var otpadMatch = from c in db.otpad where c.vrstaOtpad.Equals(otpad.vrstaOtpad) select c;

                    if (otpadMatch.Count() != 0)
                    {
                        ModelState.AddModelError(string.Empty, "Već postoji otpad sa istim imenom.");
                        return(View("~/Views/Administrator/Otpad/CreateOtpad.cshtml", otpad));
                    }

                    var rezID = rezOtpad.Last();

                    rezIDInt = (rezID);
                    rezIDInt++;
                }
                else
                {
                    rezIDInt = 1;
                }

                otpad otpadFinal = new otpad {
                    idOtpad = rezIDInt, vrstaOtpad = otpad.vrstaOtpad
                };
                db.otpad.Add(otpadFinal);
                await db.SaveChangesAsync();

                return(RedirectToAction("IndexOtpad"));
            }

            return(View("~/Views/Administrator/Otpad/CreateOtpad.cshtml", otpad));
        }