Exemplo n.º 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            SobaTip sobaTip = db.SobaTips.Find(id);

            db.SobaTips.Remove(sobaTip);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "ID,Naziv,Cijena")] SobaTip sobaTip)
 {
     if (ModelState.IsValid)
     {
         db.Entry(sobaTip).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(sobaTip));
 }
Exemplo n.º 3
0
        public ActionResult Create([Bind(Include = "ID,Naziv,Cijena")] SobaTip sobaTip)
        {
            if (ModelState.IsValid)
            {
                db.SobaTips.Add(sobaTip);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(sobaTip));
        }
Exemplo n.º 4
0
        public IHttpActionResult GetSobaTip(int id)
        {
            SobaTip sobaTip = db.SobaTips.Find(id);

            if (sobaTip == null)
            {
                return(NotFound());
            }

            return(Ok(Mapper.Map <SobaTip, SobaTipDto>(sobaTip)));
        }
Exemplo n.º 5
0
        // GET: SobaTip/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SobaTip sobaTip = db.SobaTips.Find(id);

            if (sobaTip == null)
            {
                return(HttpNotFound());
            }
            return(View(sobaTip));
        }
Exemplo n.º 6
0
        public IHttpActionResult DeleteSobaTip(int id)
        {
            SobaTip sobaTip = db.SobaTips.Find(id);

            if (sobaTip == null)
            {
                return(NotFound());
            }

            db.SobaTips.Remove(sobaTip);
            db.SaveChanges();

            return(Ok(Mapper.Map <SobaTip, SobaTipDto>(sobaTip)));
        }
Exemplo n.º 7
0
        public IHttpActionResult PostSobaTip(SobaTipDto sobaTipDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            SobaTip sobaTip = Mapper.Map <SobaTipDto, SobaTip>(sobaTipDto);


            db.SobaTips.Add(sobaTip);
            db.SaveChanges();

            return(Created(new Uri(Request.RequestUri + "/" + sobaTip.ID), sobaTipDto));
        }
Exemplo n.º 8
0
        public IHttpActionResult PutSobaTip(int id, SobaTipDto sobaTipDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }


            SobaTip sobaTip = db.SobaTips.SingleOrDefault(st => st.ID == id);

            if (sobaTip == null)
            {
                return(NotFound());
            }
            Mapper.Map(sobaTipDto, sobaTip);
            db.SaveChanges();

            return(Ok());
        }