示例#1
0
 // GET api/<controller>
 public IEnumerable<tTicket> Get()
 {
     using (var ctx = new TicketEntities())
     {
         return ctx.tTicket;
     }
 }
示例#2
0
 // POST api/<controller>
 public void Post([FromBody]tTicket value)
 {
     using (var ctx = new TicketEntities())
     {
         value.TicketId = 0;//TODO:追加処理
         ctx.tTicket.Add(value);
     }
 }
示例#3
0
 // GET api/<controller>/5
 public tTicket Get(int id)
 {
     using (var ctx = new TicketEntities())
     {
         var entity = ctx.tTicket.SingleOrDefault(p => p.TicketId == id);
         return entity;
     }
 }
示例#4
0
 // DELETE api/<controller>/5
 public void Delete(int id)
 {
     using (var ctx = new TicketEntities())
     {
         var entity = ctx.tTicket.SingleOrDefault(p => p.TicketId == id);
         if (entity != null)
         {
             ctx.tTicket.Remove(entity);
             ctx.SaveChanges();
         }
     }
 }
示例#5
0
        // PUT api/<controller>/5
        public void Put(int id, [FromBody]tTicket value)
        {
            using (var ctx = new TicketEntities())
            {

                var entity = ctx.tTicket.SingleOrDefault(p => p.TicketId == id);

                if (entity == null)
                    return;

                ctx.tTicket.Attach(value);
                ctx.Entry(value).State = System.Data.Entity.EntityState.Modified;
                ctx.SaveChanges();

            }
        }