Ejemplo n.º 1
0
 public Request(User user, Package package, Location origin, Location destination)
 {
     this.Destination = destination;
     this.RequestedUser = user;
     this.Origin = origin;
     this.Package = package;
 }
Ejemplo n.º 2
0
        public ViewResult Create(CreateRequestResponse requestResponse)
        {
            if (ModelState.IsValid)
            {
                Package package = new Package(requestResponse.PackageDescription, requestResponse.PackageWeight, requestResponse.PackageDescription);
                Location origin = new Location(requestResponse.OriginPlace, null);
                Location destination = new Location(requestResponse.DestinationPlace, new TravelDate(DateTime.Parse(requestResponse.DestinationDate)));
                if (User.Identity.IsAuthenticated)
                {
                    IUserRepository userRepository = UserRepository.Instance;
                    DomainModel.User user = userRepository.LoadUser(User.Identity.Name);
                    DomainModel.Request request = new Request(user, package, origin, destination);
                    DomainModel.RequestRepository.Instance.Save(request);

                    ViewData["Message"] = "Request Submitted Successfully!";
                    ViewData["AllRequests"] = GetAllRequests(User.Identity.Name);
                }
                else
                {
                    ViewData["Message"] = "You need to be registered to view this page!";
                }
            }

            return View(requestResponse);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
 public List<Request> Search(Location location, Location toLocation, TravelDate date)
 {
     string querystring =
         "from Request as R where R.Destination.Place = :destination and R.Origin.Place= :origin and R.Destination.Date.DateTime <= :date";
     IQuery query = Session.CreateQuery(querystring);
     query.SetString("destination", toLocation.Place);
     query.SetString("origin", location.Place);
     query.SetDateTime("date", date.DateTime);
     var requestList = (List<Request>) query.List<Request>();
     return requestList;
 }
Ejemplo n.º 5
0
 public Journey(User traveller, Location origin, Location destination)
 {
     this.Traveller = traveller;
     this.Destination = destination;
     this.Origin = origin;
 }
Ejemplo n.º 6
0
 public bool Equals(Location other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return other.Place.Equals(Place) && other.Date.Equals(Date);
 }