Esempio n. 1
0
        public void Add(TripsInfoModel tripInfoViewModel)
        {
            var trip = new Trip
            {
                StartPoint    = tripInfoViewModel.StartPoint,
                EndPoint      = tripInfoViewModel.EndPoint,
                DepartureTime = tripInfoViewModel.DepartureTime,
                Seats         = tripInfoViewModel.Seats,
                Description   = tripInfoViewModel.Description,
            };

            this.db.Trips.Add(trip);
            this.db.SaveChanges();
        }
Esempio n. 2
0
        public HttpResponse Add(TripsInfoModel input)
        {
            if (!this.IsUserLoggedIn())
            {
                return(this.Redirect("/Users/Login"));
            }

            if (input.Seats < 2 || input.Seats > 6)
            {
                return(this.View());
            }

            if (input.Description.Length > 80)
            {
                return(this.View());
            }

            this.itripService.Add(input);
            return(this.Redirect("/Trips/All"));
        }