Esempio n. 1
0
        public ActionResult Nuevo(Ticket ticket)
        {
            context.Tickets.Add(ticket);
            context.SaveChanges();

            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
        public void Delete(int id)
        {
            var existing = GetByID(id);

            table.Remove(existing);
            _TicketsContext.SaveChanges();
        }
Esempio n. 3
0
 public IActionResult DeletedEvent(int eventid)
 {
     _context.TicketsModel.Where(p => p.event_id == eventid)
     .ToList().ForEach(p => _context.TicketsModel.Remove(p));
     _context.SaveChanges();
     return(RedirectToAction("Index", "EventsModels"));
 }
Esempio n. 4
0
 public bool EditTicket(Ticket ticket)
 {
     try
     {
         using (var db = new TicketsContext(Manager))
         {
             var ticketObj = db.Tickets.Where(i => i.IdTicket == ticket.IdTicket).FirstOrDefault();
             if (ticketObj != null)
             {
                 ticketObj.Usuario            = ticket.Usuario;
                 ticketObj.FechaActualizacion = DateTime.Now;
                 ticketObj.Status             = ticket.Status;
                 db.Tickets.Update(ticketObj);
                 db.SaveChanges();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
 public void Create(Reservation reservation)
 {
     using (var ctx = new TicketsContext())
     {
         ctx.Reservations.Add(reservation);
         ctx.SaveChanges();
     }
 }
Esempio n. 6
0
 public void DeleteAgency(Data.Entities.Agency agency)
 {
     using (var ctx = new TicketsContext())
     {
         ctx.Agencies.Remove(agency);
         ctx.SaveChanges();
     }
 }
Esempio n. 7
0
 public void DeleteTrain(Data.Entities.Train train)
 {
     using (var ctx = new TicketsContext())
     {
         ctx.Trains.Remove(train);
         ctx.SaveChanges();
     }
 }
Esempio n. 8
0
 public void CreateTrain(Data.Entities.Train train)
 {
     using (var ctx = new TicketsContext())
     {
         ctx.Trains.Add(train);
         ctx.SaveChanges();
     }
 }
Esempio n. 9
0
 public void CreateRun(Data.Entities.Run run)
 {
     using (var ctx = new TicketsContext())
     {
         ctx.Runs.Add(run);
         ctx.SaveChanges();
     }
 }
Esempio n. 10
0
        public void Create(Data.Entities.Ticket ticket)
        {
            using (var ctx = new TicketsContext())
            {
                ctx.Tickets.Add(ticket);

                ctx.SaveChanges();
            }
        }
Esempio n. 11
0
 public void DeleteRun(int runId)
 {
     using (var ctx = new TicketsContext())
     {
         var run = ctx.Runs.Find(runId);
         ctx.Runs.Remove(run);
         ctx.SaveChanges();
     }
 }
Esempio n. 12
0
 public void UpdateTrain(Data.Entities.Train train)
 {
     using (var ctx = new TicketsContext())
     {
         ctx.Trains.Attach(train);
         ctx.Entry(train).State = EntityState.Modified;
         ctx.SaveChanges();
     }
 }
Esempio n. 13
0
 public void Update(Data.Entities.Ticket ticket)
 {
     using (var ctx = new TicketsContext())
     {
         ctx.Tickets.Attach(ticket);
         ctx.Entry(ticket).State = System.Data.Entity.EntityState.Modified;
         ctx.SaveChanges();
     }
 }
Esempio n. 14
0
 public void UpdateAgency(Data.Entities.Agency agency)
 {
     using (var ctx = new TicketsContext())
     {
         ctx.Agencies.Attach(agency);
         ctx.Entry(agency).State = System.Data.Entity.EntityState.Modified;
         ctx.SaveChanges();
     }
 }
Esempio n. 15
0
 public void Update(Reservation reservation)
 {
     using (var ctx = new TicketsContext())
     {
         ctx.Reservations.Attach(reservation);
         ctx.Entry(reservation).State = System.Data.Entity.EntityState.Modified;
         ctx.SaveChanges();
     }
 }
Esempio n. 16
0
        public ActionResult Sell(int id, int count, string price)
        {
            var    email = User.Identity.GetUserName();
            var    order = db.Orders.First(x => x.Id == id && x.Email == email);
            Change item  = new Change();

            item.Count   = count;
            item.Price   = int.Parse(price);
            item.OrderId = id;
            item.Email   = email;
            item.EventId = order.EventId;
            db.TicketsToChange.Add(item);
            order.Count -= count;
            if (order.Count == 0)
            {
                db.Orders.Remove(order);
            }
            db.SaveChanges();
            return(View(item));
        }
Esempio n. 17
0
        public ActionResult Add(int eventId)
        {
            var       email = User.Identity.GetUserName();
            var       items = db.ItemEvents.Where(x => x.EventId == eventId && x.Email == email).ToList();
            ItemEvent item  = new ItemEvent();

            if (items.Count() > 0)
            {
                item = items.First();
                db.Entry(item).State = EntityState.Modified;
            }
            else
            {
                item.EventId  = eventId;
                item.Quantity = 1;
                item.Email    = email;
                db.ItemEvents.Add(item);
            }
            db.SaveChanges();
            return(RedirectToAction("Index", "Cart", item));
        }
Esempio n. 18
0
 public ActionResult Create([Bind(Include = "Id,Name,Artist,Date,City,Place,Price,Count,CategoryId")] Event _event, HttpPostedFileBase upload)
 {
     if (upload != null)
     {
         string fileName = System.IO.Path.GetFileName(upload.FileName);
         if (CheckByGraphicsFormat(fileName))
         {
             SaveImage(upload, fileName);
             _event.ImageUrl = fileName;
         }
         else
         {
             _event.ImageUrl = "event.jpg";
         }
     }
     if (!ModelState.IsValid)
     {
         return(View(_event));
     }
     db.Events.Add(_event);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Esempio n. 19
0
 public bool DeleteTicket(int Id)
 {
     try
     {
         using (var db = new TicketsContext(Manager))
         {
             var ticket = db.Tickets.Where(i => i.IdTicket == Id).FirstOrDefault();
             db.Tickets.Remove(ticket);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Esempio n. 20
0
 public bool CreateTicket(Ticket ticket)
 {
     try
     {
         using (var db = new TicketsContext(Manager))
         {
             Ticket modelTicket = new Ticket();
             modelTicket.Usuario            = ticket.Usuario;
             modelTicket.FechaCreacion      = DateTime.Now;
             modelTicket.FechaActualizacion = DateTime.Now;
             modelTicket.Status             = "Abierto";
             db.Tickets.Add(modelTicket);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Esempio n. 21
0
 public void save()
 {
     _TicketsContext.SaveChanges();
 }
Esempio n. 22
0
 public void Add(TEntity obj)
 {
     Db.Set <TEntity>().Add(obj);
     Db.SaveChanges();
 }