예제 #1
0
 public IEnumerable<Request> Find(Journey journey)
 {
     string findByJourney =
         @"select R from Request as R, Journey J
         where J.Traveller = :journeyUser
         and J.Traveller <> R.RequestedUser
         and J.Traveller.UserGroup = R.RequestedUser.UserGroup
         and R.Origin.Place = :origin
         and R.Destination.Place = :destination
         and R.Destination.Date.DateTime <= :arrivalDate";
     IQuery query = Session.CreateQuery(findByJourney);
     query.SetParameter("journeyUser", journey.Traveller);
     query.SetString("origin", journey.Origin.Place);
     query.SetString("destination", journey.Destination.Place);
     query.SetDateTime("arrivalDate", journey.Destination.Date.DateTime);
     return query.List<Request>();
 }
예제 #2
0
        public ViewResult Create(JourneyModel journeyModel)
        {
            if (ModelState.IsValid)
            {
                Location origin = new Location(journeyModel.OriginPlace, new TravelDate(DateTime.Parse(journeyModel.OriginDate)));
                Location destination = new Location(journeyModel.DestinationPlace, new TravelDate(DateTime.Parse(journeyModel.DestinationDate)));

                IUserRepository userRepository = UserRepository.Instance;
                DomainModel.User user = userRepository.LoadUser(User.Identity.Name);
                DomainModel.Journey journey = new Journey(user,  origin, destination);
                DomainModel.JourneyRepository.Instance.Save(journey);

                ViewData["MyOtherJourneyDetails"] = GetJourneyList(user);

                ViewData["Message"] = "Journey Created Successfully!";

            }

            return View(journeyModel);
        }
예제 #3
0
 public void Delete(Journey journey)
 {
     Session.Delete(journey);
     Session.Flush();
 }
예제 #4
0
 public void Save(Journey journey)
 {
     Session.Save(journey);
     if(JourneyCreated != null)
         JourneyCreated(new JourneyCreatedEventArgs{Journey = journey});
 }
예제 #5
0
 public Journey Load(int journeyId)
 {
     Journey journey = new Journey();
     Session.Load(journey, journeyId);
     return journey;
 }
예제 #6
0
 public Match(Journey journey, Request request)
 {
     this.Journey = journey;
     this.Request = request;
 }