Пример #1
0
 public void Put(int id, [FromBody] Bill employee)
 {
     using (QuanLyQuanCafeEntities dbContext = new QuanLyQuanCafeEntities())
     {
         var entity = dbContext.Bills.FirstOrDefault(e => e.id == id);
         entity.idTable     = employee.idTable;
         entity.DateCheckIn = employee.DateCheckIn;
         entity.totalPrice  = employee.totalPrice;
         entity.discount    = employee.discount;
         entity.status      = employee.status;
         dbContext.SaveChanges();
     }
 }
Пример #2
0
 public HttpResponseMessage Post([FromBody] Bill employee)
 {
     using (QuanLyQuanCafeEntities dbContext = new QuanLyQuanCafeEntities())
     {
         try
         {
             dbContext.Bills.Add(employee);
             dbContext.SaveChanges();
             var message = Request.CreateResponse(HttpStatusCode.Created, employee);
             message.Headers.Location = new Uri(Request.RequestUri +
                                                employee.id.ToString());
             return(message);
         }
         catch (Exception ex)
         {
             return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
         }
     }
 }