public async Task <IActionResult> TicketTypes( [FromQuery] int catalogEventId) { List <CatalogTicketType> ticketTypes = null; if (catalogEventId > 0) { if (catalogEventId <= await _context.CatalogEvents.LongCountAsync()) { ticketTypes = await _context.CatalogTicketTypes .Where(tt => tt.CatalogEventId == catalogEventId) .ToListAsync(); } } var viewModel = new TicketTypesViewModel { CatalogEventId = catalogEventId, CatalogTicketTypes = ticketTypes }; return(Ok(viewModel)); }
public async Task <IActionResult> Create(TicketTypesViewModel model) { if (!ModelState.IsValid) { return(View(model)); } TicketType ticket = new TicketType(); ticket.name = model.name; ticket.discount = (float)(model.discount / 100); _context.TicketType.Add(ticket); await _context.SaveChangesAsync(); TempData["SuccesMessage"] = "Biletul a fost creat cu succes!"; return(RedirectToAction("List")); }
public IActionResult Create() { TicketTypesViewModel model = new TicketTypesViewModel(); return(View(model)); }