public IActionResult AddTrip(int id) { var trip = new AddTripFormViewModel() { Id = id }; return(View(trip)); }
public IActionResult AddTrip(AddTripFormViewModel model) { tours.AddTrip(model.TourId, model.StartDate, model.EndDate, model.Price, model.BusSeatsNumber); TempData.AddSuccessMessage($"Trip was successfully added to tour {model.TourId}!"); return(base.RedirectToAction( nameof(Web.Controllers.ToursController.Details), "Tours", new { area = string.Empty, id = model.TourId })); }
public void CreateTrip(AddTripFormViewModel input) { var trip = new Trip() { StartPoint = input.StartPoint, EndPoint = input.EndPoint, DepartureTime = input.DepartureTime, ImagePath = input.ImagePath, Seats = input.Seats, Description = input.Description, }; this.db.Trips.Add(trip); this.db.SaveChanges(); }
public HttpResponse Add(AddTripFormViewModel input) { if (!this.IsUserLoggedIn()) { return(this.Redirect("/")); } if (string.IsNullOrWhiteSpace(input.StartPoint)) { return(this.View("Add")); } if (string.IsNullOrWhiteSpace(input.EndPoint)) { return(this.View("Add")); } if (input.DepartureTime == null) { return(this.View("Add")); } if (input.Seats < 2 || input.Seats > 6) { return(this.View("Add")); } if (input.Description.Length < 0 || input.Description.Length > 80) { return(this.View("Add")); } this.tripsService.CreateTrip(input); return(this.Redirect("All")); }