public Request(User user, Package package, Location origin, Location destination) { this.Destination = destination; this.RequestedUser = user; this.Origin = origin; this.Package = package; }
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); }
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); }
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; }
public Journey(User traveller, Location origin, Location destination) { this.Traveller = traveller; this.Destination = destination; this.Origin = origin; }
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); }