Exemplo n.º 1
0
        public ActionResult Create()
        {
            TripInputVIewModel viewModel = new TripInputVIewModel()
            {
                TownsSelectList = this.TownProvider.GetCachedTowns(),
                AvailableSeatsSelectList = this.TripProvider.GetAvailableSeatsSelectList(),
                AddressPickUpSelectList = this.TripProvider.GetAddressPickUpSelectList()
            };

            return this.View(viewModel);
        }
Exemplo n.º 2
0
        public ActionResult Index(TripInputVIewModel trip)
        {
            if (trip.FromId == trip.ToId)
            {
                this.ModelState.AddModelError("From", "From and To towns should be different");
            }

            if (!this.ModelState.IsValid)
            {
                this.TempData[WebApplicationConstants.TempDataMessageKey] = "From and To towns should be different";
                return this.RedirectToAction("Create");
            }

            string currentUserId = this.User.Identity.GetUserId();

            Trip serviceResponceTrip = this.TripServices.Create(
                    trip.FromId,
                    trip.ToId,
                    trip.DateOfLeaving,
                    trip.AvailableSeats,
                    trip.PlaceOfLeaving,
                    trip.PickUpFromAddress,
                    trip.Description,
                    trip.ETA,
                    trip.Price,
                    currentUserId);

            this.NotificationServices.Create(
                serviceResponceTrip.Id,
                currentUserId,
                currentUserId,
                NotificationConstants.CloseTripDriverRequestTitle,
                string.Format(NotificationConstants.CloseTripDriverRequestFormat, serviceResponceTrip.FromId, serviceResponceTrip.ToId, serviceResponceTrip.DateOfLeaving.ToString("dd/MM/yyyy HH:mm")),
                NotificationKey.FinishTripDriverRequest,
                serviceResponceTrip.DateOfLeaving.AddDays(NotificationConstants.CloseTripDriverRequestAvaialableDaysAfterTripFinished),
                serviceResponceTrip.ETA);

            return this.RedirectToRoute("TripDetails", new { id = serviceResponceTrip.Id });
        }