Ejemplo n.º 1
0
        public IActionResult AddHistory(int id)
        {
            var model = new AddHistoryViewModel();

            model.TripId = id;
            return(View(model));
        }
Ejemplo n.º 2
0
 public IActionResult AddHistory(AddHistoryViewModel model)
 {
     if (ModelState.IsValid)
     {
         var history = new History()
         {
             Title   = model.Title,
             Comment = model.Comment,
             TripId  = model.TripId,
             Date    = DateTime.Now
         };
         _context.History.Add(history);
         _context.SaveChanges();
         return(RedirectToAction("ShowHistory", new { id = model.TripId }));
     }
     return(View(model));
 }