Exemplo n.º 1
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();
     }
 }
Exemplo n.º 2
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));
        }
Exemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "Id,Name,Artist,Date,City,Place,Price,Count,CategoryId,ImageUrl")] Event _event, HttpPostedFileBase upload)
 {
     if (upload != null)
     {
         string fileName = System.IO.Path.GetFileName(upload.FileName);
         if (CheckByGraphicsFormat(fileName))
         {
             SaveImage(upload, fileName);
             _event.ImageUrl = fileName;
         }
     }
     if (!ModelState.IsValid)
     {
         return(View(_event));
     }
     db.Entry(_event).State = EntityState.Modified;
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Exemplo n.º 4
0
        public long Update(long id, Ticket ticket)
        {
            var ticketSaved = _context.Tickets.Find(id);

            if (ticket.Description != null)
            {
                ticketSaved.Description = ticket.Description;
            }
            if (ticket.AuthorName != null)
            {
                ticketSaved.AuthorName = ticket.AuthorName;
            }
            if (ticket.Date != null && ticket.Date != new DateTime())
            {
                ticketSaved.Date = ticket.Date;
            }

            _context.Entry(ticketSaved).State = EntityState.Modified;
            _context.SaveChangesAsync();

            return(ticketSaved.Id);
        }
Exemplo n.º 5
0
 public ActionResult Actualizar(Ticket ticket)
 {
     context.Entry(ticket).State = System.Data.Entity.EntityState.Modified;
     context.SaveChanges();
     return(RedirectToAction("Index"));
 }