コード例 #1
0
 // GET: api/Promo/5
 public Models.Promocion Get(int id)
 {
     using (PromocionEntities db = new PromocionEntities())
     {
         return(db.Promocion.Where(w => w.Id == id).FirstOrDefault());
     }
 }
コード例 #2
0
 // GET: api/Promo
 public IEnumerable <Models.Promocion> Get()
 {
     using (PromocionEntities db = new PromocionEntities())
     {
         return(db.Promocion.ToList());
     }
 }
コード例 #3
0
        // POST: api/Promo
        public HttpResponseMessage Post([FromBody] Models.Promocion value)
        {
            int res = 0;
            HttpResponseMessage msj = null;

            try
            {
                using (PromocionEntities db = new PromocionEntities())
                {
                    db.Entry(value).State = EntityState.Added;
                    res = db.SaveChanges();
                    msj = Request.CreateResponse(HttpStatusCode.OK, res);
                }
            }
            catch (Exception ex)
            {
                msj = Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message);
            }
            return(msj);
        }