Esempio n. 1
0
        public IHttpActionResult Posttraveller(traveller traveller)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.travellers.Add(traveller);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (travellerExists(traveller.traveller_id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = traveller.traveller_id }, traveller));
        }
Esempio n. 2
0
        public IHttpActionResult Puttraveller(int id, traveller traveller)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != traveller.traveller_id)
            {
                return(BadRequest());
            }

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!travellerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public ActionResult Traveller(traveller t)
        {
            //int nid = Convert.ToInt32(TempData["new_user"].ToString());
            t.topup = 0;
            nv.travellers.Add(t);
            nv.travellers.Find(keyValues: t.user_id).user_id = Convert.ToInt32(TempData["new_user"].ToString());
            nv.SaveChanges();

            return(View());
        }
Esempio n. 4
0
        public IHttpActionResult Gettraveller(int id)
        {
            traveller traveller = db.travellers.Find(id);

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

            return(Ok(traveller));
        }
Esempio n. 5
0
        public IHttpActionResult Posttraveller(traveller traveller)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.travellers.Add(traveller);
            db.SaveChanges();


            return(CreatedAtRoute("DefaultApi", new { id = traveller.traveller_id }, traveller));
        }
Esempio n. 6
0
        public IHttpActionResult Deletetraveller(int id)
        {
            traveller traveller = db.travellers.Find(id);

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

            db.travellers.Remove(traveller);
            db.SaveChanges();

            return(Ok(traveller));
        }