public async Task <DeleteTicketViewModel> DeleteTicket([FromBody] DeleteTicketViewModel model) { try { DeleteTicketCommandResult commandResult = await _commandSender.Send <DeleteTicketCommand, DeleteTicketCommandResult>(new DeleteTicketCommand { ETDAltId = model.ETDAltId, TicketLength = model.TicketLength, CurrentStep = model.CurrentStep, EventId = model.EventId }); return(new DeleteTicketViewModel { Success = commandResult.Success, CurrentStep = commandResult.CurrentStep, IsTicketSold = commandResult.IsTicketSold, CompletedStep = commandResult.CompletedStep }); } catch (Exception e) { return(new DeleteTicketViewModel { }); } }
public ActionResult Delete(DeleteTicketViewModel model) { TicketRepository repository = new TicketRepository(); if (model.Id.ToString() != String.Empty) { repository.Delete(model.Id); } return(RedirectToAction("Index")); }
public async Task DeleteTicket(DeleteTicketViewModel model) { var ticketToDelete = await FindTicket(model.Id); if (ticketToDelete == null) { throw new NullReferenceException($"No ticket with id:{model.Id} exists."); } ticketToDelete.IsDeleted = true; dbContext.Update(ticketToDelete); await dbContext.SaveChangesAsync(); }
public async Task <IActionResult> DeleteTicket(DeleteTicketViewModel model) { if (ModelState.IsValid) { var AuthorId = await service.FindUserIdByName(model.AuthorId); model.AuthorId = AuthorId.Id; var AgentId = await service.FindUserIdByName(model.AgentId); model.AgentId = AgentId.Id; await service.DeleteTicket(model); return(RedirectToAction("DisplayAllSendTickets")); } return(View()); }
public async Task <IActionResult> DeleteTicket(DeleteTicketViewModel model) { if (ModelState.IsValid) { var AuthorId = await service.FindUserIdByName(model.AuthorId); model.AuthorId = AuthorId.Id; var AgentId = await service.FindUserIdByName(model.AgentId); model.AgentId = AgentId.Id; await service.DeleteTicket(model); return(RedirectToAction("MySendTickets", "Ticket", new { id = User.Identity.Name, area = "Agent" })); } return(View()); }
public async Task <IActionResult> DeleteTicket(int id) { var ticket = await service.FindTicket(id); if (ticket == null) { return(NotFound()); } if (ticket.IsDeleted) { return(RedirectToAction("DisplayAllSendTickets")); } var ticketToDelete = new DeleteTicketViewModel(); ticketToDelete.Id = ticket.Id; ticketToDelete.Title = ticket.Title; ticketToDelete.Descripton = ticket.Descripton; ticketToDelete.Priority = ticket.Priority; if (ticket.AgentId != null) { var AgentUsername = await service.FindUserNameById(ticket.AgentId); ticketToDelete.AgentId = AgentUsername.UserName; } else { return(RedirectToAction("DisplayAllSendTickets")); } var AuthorUsername = await service.FindUserNameById(ticket.AuthorId); ticketToDelete.AuthorId = AuthorUsername.UserName; ticketToDelete.ProjectId = ticket.ProjectId; ticketToDelete.SendOn = ticket.SendOn; ticketToDelete.IsAnswered = ticket.IsAnswered; ticketToDelete.IsComplete = ticket.IsComplete; ticketToDelete.IsDeleted = ticket.IsDeleted; return(View(ticketToDelete)); }
public ActionResult DeleteTicket(int id) { DeleteTicketViewModel deleteTicket = new DeleteTicketViewModel(); using (var context = TicketDbContext.Create()) { deleteTicket = context.Tickets.Where(x => x.TicketId == id) .Select(x => new DeleteTicketViewModel() { Id = x.TicketId, StatusOfTicket = x.StatusOfTicket, Title = x.Title, TypeOfTicket = x.TypeOfTicket, UserName = x.User.UserName, Description = x.Description }).FirstOrDefault(); } if (null == deleteTicket) { return(new HttpNotFoundResult("Specjalnie tu trafiłeś?")); } return(View(deleteTicket)); }