Exemplo n.º 1
0
        public IHttpActionResult PutinfoMaster(int id, infoMaster infoMaster)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != infoMaster.Id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 2
0
        public IHttpActionResult GetinfoMaster(int id)
        {
            infoMaster infoMaster = db.infoMasters.Find(id);

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

            return(Ok(infoMaster));
        }
Exemplo n.º 3
0
        public IHttpActionResult PostinfoMaster(infoMaster infoMaster)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.infoMasters.Add(infoMaster);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = infoMaster.Id }, infoMaster));
        }
 public IHttpActionResult PostInfos(infoMaster info)
 {
     try
     {
         db.infoMasters.Add(info);
         db.SaveChanges();
         return(Ok("Your data is inserted!"));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Exemplo n.º 5
0
        public IHttpActionResult DeleteinfoMaster(int id)
        {
            infoMaster infoMaster = db.infoMasters.Find(id);

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

            db.infoMasters.Remove(infoMaster);
            db.SaveChanges();

            return(Ok(infoMaster));
        }