public IActionResult Create(TripCreate model) { if (!ModelState.IsValid) { return(BadRequest()); } _tripService.Create(model, User.FindFirst(ClaimTypes.NameIdentifier).Value); return(Ok()); }
public IHttpActionResult Post(TripCreate model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var tripService = new TripService(Guid.Parse(User.Identity.GetUserId())); return(Ok(tripService.TripCreate(model))); }
public void Create(TripCreate model, string userId) { var entity = new Trip { Price = model.Price, DateEnd = model.DateEnd, Country = model.Country, DateStart = model.DateStart, UserId = userId }; _dbContext.Trips.Add(entity); _dbContext.SaveChanges(); }
public IHttpActionResult Post(TripCreate trip) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateTripService(); if (!service.CreateTrip(trip)) { return(InternalServerError()); } return(Ok()); }
public ActionResult Create(TripCreate model) { if (!ModelState.IsValid) { return(View(model)); } if (!TripCreateService().TripCreate(model)) { ModelState.AddModelError("", "Unable to create ticket"); return(View(model)); } TempData["SaveResult"] = "Your ticket was created"; return(RedirectToAction("Index")); }
public bool CreateTrip(TripCreate model) { var entity = new Trip() { OwnerID = _userID, TripName = model.TripName, DepartDate = model.DepartDate, ReturnDate = model.ReturnDate }; using (var ctx = new ApplicationDbContext()) { ctx.Trips.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(TripCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateService(); if (service.CreateTrip(model)) { TempData["SaveResult"] = "Your trip has been saved."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Trip could not be created."); return(View(model)); }
public bool CreateTrip(TripCreate model) { var entity = new Trip() { UserId = _userId, TripStartDate = model.TripStartDate, TripEndDate = model.TripEndDate, CountryId = model.CountryId, PersonId = model.PersonId, }; using (var ctx = new ApplicationDbContext()) { ctx.Trips.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(TripCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateTripService(); if (service.CreateTrip(model)) { return(RedirectToAction("IndexAllTrips")); } else { ModelState.AddModelError("", "Trip could not be created"); } return(View(model)); }
//public IEnumerable<TripListItem> GetTripsByBuddyId() //{ //} public bool CreateTrip(TripCreate model) { var entity = new Trip() { StartTime = model.StartTime, BuddyId = model.BuddyId, VolunteerId = model.VolunteerId, StartLocation = model.StartLocation, ProjectedEndLocation = model.ProjectedEndLocation, EndLocation = model.EndLocation, EndTime = model.EndTime, }; using (var ctx = new ApplicationDbContext()) { ctx.Trips.Add(entity); return(ctx.SaveChanges() == 1); } }
//Create the Trip Ticket public bool TripCreate(TripCreate model) { using (var ctx = new ApplicationDbContext()) { var entity = new Trip { Price = model.Price, TripTime = model.TripTime, Origin = model.Origin, Destination = model.Destination, Hours = model.Hours, Minutes = model.Minutes, Seats = model.Seats, CarID = model.CarID, DriverID = model.DriverID }; ctx.Trips.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool TripCreate(TripCreate model) { CreateTripCallCount++; return(CreateTripReturnValue); }