コード例 #1
0
ファイル: Request.cs プロジェクト: lokeshwer/CarrierPigeons
 public Request(User user, Package package, Location origin, Location destination)
 {
     this.Destination = destination;
     this.RequestedUser = user;
     this.Origin = origin;
     this.Package = package;
 }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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;
 }
コード例 #5
0
ファイル: Journey.cs プロジェクト: lokeshwer/CarrierPigeons
 public Journey(User traveller, Location origin, Location destination)
 {
     this.Traveller = traveller;
     this.Destination = destination;
     this.Origin = origin;
 }
コード例 #6
0
ファイル: Location.cs プロジェクト: lokeshwer/CarrierPigeons
 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);
 }