private void InitViewDataForSelectList(TicketDto ticketDto = null) { log.Info(nameof(TicketController.InitViewDataForSelectList)); try { ViewData["TicketTypeId"] = new SelectList(ticketTypeService.GetTicketTypes(), "Id", "TypeName", ticketDto?.Id); ViewData["TransactionHistoryId"] = new SelectList(transactionService.GetTransactions(), "Id", "ReferenceNumber", ticketDto?.TransactionHistoryId); ViewData["UserId"] = new SelectList(userService.GetUsers().Select(s => new { s.Id, Name = $"{s.LastName} {s.FirstName}" }), "Id", "Name", ticketDto?.UserId); ViewData["AreaId"] = new MultiSelectList(areaService.GetAreas().Select(a => new { a.Id, a.Name }), "Id", "Name", ticketDto?.Areas); } catch (Exception e) { log.Error(e); } }
public IActionResult GetTicketTypes() { logger.Info(nameof(TicketTypesController.GetTicketTypes)); try { return(Ok(ticketTypeService.GetTicketTypes())); } catch (Exception exception) { logger.Error(exception); return(BadRequest()); } }
public IActionResult Index() { logger.Info(nameof(TicketController.Index)); try { var ticketTypes = ticketTypeService.GetTicketTypes(); return(View(ticketTypes)); } catch (Exception exception) { logger.Error(exception); return(BadRequest()); } }
public async Task <IActionResult> GetAll() { var currentUser = await _identityService.GetCurrentUser(); if (currentUser == null) { return(BadRequest(new { error = "You are not allowed!" })); } var person = await _identityService.GetPersonByUserId(currentUser.Id); if (person == null) { return(BadRequest(new { error = "Person was not found" })); } return(Ok(_mapper.Map <List <TicketTypeDto> >(await _ticketTypeService.GetTicketTypes()))); }