Esempio n. 1
0
        // PUT api/TipoviKorisnikaApi/5
        public HttpResponseMessage Puttipovikorisnika(int id, tipovikorisnika tipovikorisnika)
        {
            if (!ModelState.IsValid)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }

            if (id != tipovikorisnika.idTipaKorisnika)
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }

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

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

            return Request.CreateResponse(HttpStatusCode.OK);
        }
Esempio n. 2
0
        public ActionResult Create(tipovikorisnika tipovikorisnika)
        {
            if (ModelState.IsValid)
            {
                db.tipovikorisnika.Add(tipovikorisnika);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(tipovikorisnika);
        }
Esempio n. 3
0
        // POST api/TipoviKorisnikaApi
        public HttpResponseMessage Posttipovikorisnika(tipovikorisnika tipovikorisnika)
        {
            if (ModelState.IsValid)
            {
                db.tipovikorisnika.Add(tipovikorisnika);
                db.SaveChanges();

                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, tipovikorisnika);
                response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = tipovikorisnika.idTipaKorisnika }));
                return response;
            }
            else
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }
        }
Esempio n. 4
0
 public ActionResult Edit(tipovikorisnika tipovikorisnika)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tipovikorisnika).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(tipovikorisnika);
 }