コード例 #1
0
        public IHttpActionResult PutTicket(int id, Ticket ticket)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #2
0
 public int Alterar(Status status)
 {
     try
     {
         using (HelpDeskEntities contexto = new HelpDeskEntities(Util.ConnectionString))
         {
             contexto.Entry(status).State = System.Data.EntityState.Modified;
             return(contexto.SaveChanges());
         }
     }
     catch (Exception)
     {
         return(-1);
     }
 }
コード例 #3
0
 public int Gravar(Solicitante sol)
 {
     try
     {
         using (HelpDeskEntities contexto =
                    new HelpDeskEntities(Util.ConnectionString))
         {
             contexto.Solicitante.Add(sol);
             return(contexto.SaveChanges());
         }
     }
     catch (Exception)
     {
         return(-1);
     }
 }