Esempio n. 1
0
 public IActionResult Create(TripCreate model)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest());
     }
     _tripService.Create(model, User.FindFirst(ClaimTypes.NameIdentifier).Value);
     return(Ok());
 }
Esempio n. 2
0
        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)));
        }
Esempio n. 3
0
        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();
        }
Esempio n. 4
0
        public IHttpActionResult Post(TripCreate trip)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateTripService();

            if (!service.CreateTrip(trip))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
Esempio n. 5
0
        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"));
        }
Esempio n. 6
0
        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);
            }
        }
Esempio n. 7
0
        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));
        }
Esempio n. 8
0
        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);
            }
        }
Esempio n. 9
0
        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));
        }
Esempio n. 10
0
        //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);
            }
        }
Esempio n. 11
0
        //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);
            }
        }
Esempio n. 12
0
        public bool TripCreate(TripCreate model)
        {
            CreateTripCallCount++;

            return(CreateTripReturnValue);
        }