// PUT api/TipoviOglasaApi/5
        public HttpResponseMessage Puttipovioglasa(int id, tipovioglasa tipovioglasa)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            if (id != tipovioglasa.idTipaOglasa)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

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

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

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Beispiel #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            tipovioglasa tipovioglasa = db.tipovioglasa.Find(id);

            db.tipovioglasa.Remove(tipovioglasa);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #3
0
        //
        // GET: /TipoviOglasa/Delete/5

        public ActionResult Delete(int id = 0)
        {
            tipovioglasa tipovioglasa = db.tipovioglasa.Find(id);

            if (tipovioglasa == null)
            {
                return(HttpNotFound());
            }
            return(View(tipovioglasa));
        }
Beispiel #4
0
 public ActionResult Edit(tipovioglasa tipovioglasa)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tipovioglasa).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tipovioglasa));
 }
Beispiel #5
0
        public ActionResult Create(tipovioglasa tipovioglasa)
        {
            if (ModelState.IsValid)
            {
                db.tipovioglasa.Add(tipovioglasa);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tipovioglasa));
        }
        // GET api/TipoviOglasaApi/5
        public tipovioglasa Gettipovioglasa(int id)
        {
            tipovioglasa tipovioglasa = db.tipovioglasa.Find(id);

            if (tipovioglasa == null)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            return(tipovioglasa);
        }
        // POST api/TipoviOglasaApi
        public HttpResponseMessage Posttipovioglasa(tipovioglasa tipovioglasa)
        {
            if (ModelState.IsValid)
            {
                db.tipovioglasa.Add(tipovioglasa);
                db.SaveChanges();

                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, tipovioglasa);
                response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = tipovioglasa.idTipaOglasa }));
                return(response);
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }
        }
        // DELETE api/TipoviOglasaApi/5
        public HttpResponseMessage Deletetipovioglasa(int id)
        {
            tipovioglasa tipovioglasa = db.tipovioglasa.Find(id);

            if (tipovioglasa == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            db.tipovioglasa.Remove(tipovioglasa);

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

            return(Request.CreateResponse(HttpStatusCode.OK, tipovioglasa));
        }