Beispiel #1
0
 public virtual bool Equals(Request other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return other.RequestedUser.Equals(RequestedUser) && other.Package.Equals(Package) &&
            other.Origin.Equals(Origin) && other.Destination.Equals(Destination);
 }
        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 void ShouldAcceptSelectedMatchedRequestsAndChangeStatusOfTheRequests()
        {
            var matchRepositoryMock = new Mock<IMatchRepository> { };
            var userRepositoryMock = new Mock<IUserRepository> {};

            List<Match> matchedRequests = new List<Match>();
            Request request = new Request();
            User user = new User();
            user.Email = new Email("*****@*****.**");

            Match match = new Match(new Journey(), request);
            match.Status = MatchStatus.Potential;
            match.Id = 1;
            matchedRequests.Add(match);
            matchRepositoryMock.Setup(ps => ps.LoadPotentialMatchesByUserJourney("*****@*****.**")).Returns(matchedRequests);
            userRepositoryMock.Setup(ps => ps.LoadUser("*****@*****.**")).Returns(user);

            Website.Controllers.RequestMatchController requestMatchController =
                            new Website.Controllers.RequestMatchController(matchRepositoryMock.Object,userRepositoryMock.Object ,"*****@*****.**");
            requestMatchController.AcceptRequest(new string[]{"1"});
            Assert.AreEqual(match.Status,MatchStatus.Accepted);
            Assert.AreEqual(match.Request.AcceptingUser,user);
            matchRepositoryMock.Verify(ps => ps.UpdateMatches(matchedRequests));
        }
 public void Save(Request request)
 {
     Session.Save(request);
     if(this.RequestCreated != null)
         RequestCreated(new RequestCreatedEventArgs{Request = request});
 }
 public void Delete(Request request)
 {
     Session.Delete(request);
 }
        public IEnumerable<Journey> Find(Request request)
        {
            const string findByRequest = @"select J from Journey J, Request R
                                            where J.Traveller <> R.RequestedUser
                                            and R.RequestedUser = :requestedUser
                                            and J.Traveller.UserGroup = R.RequestedUser.UserGroup
                                            and J.Origin.Place = :origin
                                            and J.Destination.Place = :destination
                                            and J.Destination.Date.DateTime <= :arrivalDate ";

            IQuery query = Session.CreateQuery(findByRequest);
            query.SetString("origin", request.Origin.Place);
            query.SetString("destination", request.Destination.Place);
            query.SetDateTime("arrivalDate", request.Destination.Date.DateTime);
            query.SetParameter("requestedUser",request.RequestedUser);
            return query.List<Journey>();
        }
Beispiel #7
0
 public Match(Journey journey, Request request)
 {
     this.Journey = journey;
     this.Request = request;
 }