Ejemplo n.º 1
0
        public ActionResult Create(poruke poruke)
        {
            if (ModelState.IsValid)
            {
                db.poruke.Add(poruke);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.idKorisnikaPosiljaoca = new SelectList(db.korisnici, "idKorisnika", "imeKorisnika", poruke.idKorisnikaPosiljaoca);
            ViewBag.idKorisnikaPrimaoca = new SelectList(db.korisnici, "idKorisnika", "imeKorisnika", poruke.idKorisnikaPrimaoca);
            return View(poruke);
        }
Ejemplo n.º 2
0
        // PUT api/Poruke/5
        public HttpResponseMessage Putporuke(int id, poruke poruke)
        {
            if (!ModelState.IsValid)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }

            if (id != poruke.idPoruke)
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }

            db.Entry(poruke).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return Request.CreateErrorResponse(HttpStatusCode.NotFound, ex);
            }

            return Request.CreateResponse(HttpStatusCode.OK);
        }
Ejemplo n.º 3
0
        // POST api/Poruke
        public HttpResponseMessage Postporuke(poruke poruke)
        {
            if (ModelState.IsValid)
            {
                db.poruke.Add(poruke);
                db.SaveChanges();

                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, poruke);
                response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = poruke.idPoruke }));
                return response;
            }
            else
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }
        }
Ejemplo n.º 4
0
        public void postaviporuku(Helpers.Poruka poruka)
        {
            if (poruka != null)
            {
                var porukaStara = new poruke()
                {
                    tekstPoruke = poruka.TekstPoruke,
                    naslovPoruke = poruka.NaslovPoruke,
                    aktivan = poruka.Aktivan,
                    idKorisnikaPosiljaoca = poruka.PosiljaocId,
                    idKorisnikaPrimaoca = poruka.PrimaocId
                };

                db.poruke.Add(porukaStara);
                db.SaveChanges();
            }
        }
Ejemplo n.º 5
0
 public ActionResult Edit(poruke poruke)
 {
     if (ModelState.IsValid)
     {
         db.Entry(poruke).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.idKorisnikaPosiljaoca = new SelectList(db.korisnici, "idKorisnika", "imeKorisnika", poruke.idKorisnikaPosiljaoca);
     ViewBag.idKorisnikaPrimaoca = new SelectList(db.korisnici, "idKorisnika", "imeKorisnika", poruke.idKorisnikaPrimaoca);
     return View(poruke);
 }