public static void GuardarSalida(string Logged, Ticket ticket) { using (var db = new SisparkModel()) { var user = db.User.FirstOrDefault(u => u.Usuario == Logged); var TicLog = db.TicketLog.Create(); TicLog.UserId = user.UserId; TicLog.DateTimeLog = DateTime.Now; TicLog.TransactionType = "Salida"; TicLog.TicketId = ticket.TicketId; db.TicketLog.Add(TicLog); db.SaveChanges(); } }
public ActionResult TicketEntrada(Ticket ticket) { if (ModelState.IsValid) { List<string> ListaPatente = (from p in db.Ticket where p.TicketStateId == 1 && p.Car.CarId == ticket.CarId select p.Car.Patente).ToList(); if (ListaPatente.Count == 0) { // ticketstateid = 1 ingresado, = 2 retirado, = 3 cancelado ticket.TicketStateId = 1; ticket.StartDateTime = DateTime.Now; db.Ticket.Add(ticket); db.SaveChanges(); Controllers.TicketLogsController.GuardarEntrada(User.Identity.Name, ticket); ViewBag.Mensaje = ""; return RedirectToAction("Index"); } else { ViewBag.Mensaje = "Patente ya ingresada"; ViewBag.CarId = new SelectList(db.Car, "CarId", "Patente", ticket.CarId); return View(); } } ViewBag.CarId = new SelectList(db.Car, "CarId", "Patente", ticket.CarId); return View(); }