public ActionResult Delete(string ticketIdLocal, TicketPrintableModel ticketPrintableModel) { if (!ModelState.IsValid) { return(View(ticketPrintableModel)); } var localTicketId = Encrypt.Unprotect(ticketIdLocal); if (!int.TryParse(localTicketId, out var ticketId)) { return(View(ticketPrintableModel)); } var result = _ticketCommandsService.UpdateTicketStatus((int)EStatus.Cancelado, _searchQueriesService.SearchTicketId(localTicketId)); if (result == false) { var encryptedTicketId = Encrypt.Protect(ticketId.ToString()); ViewBag.TicketIdEncrypt = encryptedTicketId; ViewBag.Error = "E R R O R al actualizando el ticket"; return(View(ticketPrintableModel)); } ticketPrintableModel = _searchQueriesService.SearchTicketByNumber(ticketId); var currentPeople = (people)Session["User"]; _mailerService.NotifyDeletedTicket(ticketPrintableModel, ticketId, currentPeople); TempData["Successful"] = "Ticket Eliminado correctamente!"; return(RedirectToAction("Index", "Home")); }
public bool UpdateTicket(TicketHistoryViewModel baseTicket, string ticketIdLocal) { var entityTicketId = _searchQueriesService.SearchTicketId(ticketIdLocal); if (!UpdateTicketStatus(baseTicket.idStatus, entityTicketId)) { return(false); } _database = new dbSIACEntities(); var updateTicket = new ticketHistory { date = DateTime.Now, idPeople = baseTicket.idPeople, idStatus = baseTicket.idStatus, idTicket = entityTicketId, note = baseTicket.note }; try { using (_database) { _database.ticketHistory.Add(updateTicket); _database.SaveChanges(); } } catch (Exception) { return(false); } return(true); }