Пример #1
0
        public async Task ChangeStatusToSoldForSeller(int ticketId, string buyerId)
        {
            var ticket = _context.Tickets.FirstOrDefault(t => t.Id == ticketId);

            var ordersArray = _context.Orders.Where(o => o.TicketId == ticketId).ToArray();

            foreach (var order in ordersArray)
            {
                if (order.UserIdBuyer.Equals(buyerId))
                {
                    order.Status = Constants.Confirmed;
                    order.Track  = Guid.NewGuid();

                    if (ticket != null)
                    {
                        ticket.Bought = true;
                    }

                    _context.Update(order);
                }
                else
                {
                    order.Status = Constants.Rejected;
                }
            }

            await _context.SaveChangesAsync();
        }
Пример #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nombre,Apellido,Estado,Cedula,Cola,Tiempo_Init")] Usuarios usuarios)
        {
            if (id != usuarios.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(usuarios);
                    if (usuarios.Cola == null)
                    {
                        usuarios.Cola = "A" + usuarios.Id;
                    }
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UsuariosExists(usuarios.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            return(View(usuarios));
        }
Пример #3
0
        public async Task EditVenue(int venueId, VenueDTO venueDto)
        {
            var venue = await _context.Venues.FindAsync(venueId);

            if (venue != null)
            {
                venue.Name    = venueDto.Name;
                venue.Address = venueDto.Address;
                venue.CityId  = venueDto.CityId;

                _context.Update(venue);
            }

            await _context.SaveChangesAsync();
        }
        public async Task <ActionResult <Ticket> > Put(Ticket ticket)
        {
            if (ticket == null)
            {
                return(BadRequest());
            }
            if (!db.Tickets.Any(x => x.Id == ticket.Id))
            {
                return(NotFound());
            }
            db.Update(ticket);
            await db.SaveChangesAsync();

            return(Ok(ticket));
        }