Ejemplo n.º 1
0
 //modificar relacion
 public void updateRelation(RelTicketHasStatus newRel)
 {
     using (var db = new ToDoListContext())
     {
         var relation = db.REL_TICKET_HAS_STATUS.Where(r => r.id == newRel.Id).First();
         relation.id_status = newRel.idStatus;
         db.SaveChanges();
     }
 }
Ejemplo n.º 2
0
        //guardar relation
        public long addRelation(RelTicketHasStatus relation)
        {
            long newId = 0;

            using (var db = new ToDoListContext())
            {
                var newRelation = new REL_TICKET_HAS_STATUS
                {
                    id_ticket = relation.IdTicket,
                    id_status = relation.idStatus,
                    date      = relation.Date
                };

                db.REL_TICKET_HAS_STATUS.Add(newRelation);
                db.SaveChanges();
                newId = newRelation.id;
            }

            return(newId);
        }
Ejemplo n.º 3
0
        public RelTicketHasStatus[] getAll()
        {
            List <RelTicketHasStatus> relations = new List <RelTicketHasStatus>();

            using (var db = new ToDoListContext())
            {
                var query = from u in db.REL_TICKET_HAS_STATUS
                            orderby u.id ascending
                            select u;
                foreach (var item in query)
                {
                    RelTicketHasStatus relation = new RelTicketHasStatus();
                    relation.Id       = item.id;
                    relation.Date     = item.date;
                    relation.IdTicket = item.id_ticket;
                    relation.idStatus = item.id_status;
                    relations.Add(relation);
                }
            }
            return(relations.ToArray());
        }
Ejemplo n.º 4
0
        public IHttpActionResult postTicket(Ticket ticket)
        {
            //ingresar nuevo ticket y obtener id
            long newTicketId = dataTickets.addTicket(ticket);

            //corroborar ingresado
            if (newTicketId != 0)
            {
                //ingresar nueva relacion, para dejar ticket como pendiente
                RelTicketHasStatus relation = new RelTicketHasStatus();
                relation.idStatus = 1; //1=> pendiente
                relation.IdTicket = newTicketId;
                relation.Date     = ticket.Date;
                //ingresar relacion y corroborar que se ingresa correctamente
                if (dataRelations.addRelation(relation) != 0)
                {
                    return(Ok(ticket));
                }
            }
            return(NotFound());
        }
 //modificar relacion
 //put: api/ticketstatus/{id_relation}
 public void putRelation(int id, RelTicketHasStatus relation)
 {
     dataRelation.updateRelation(relation);
 }