Example #1
0
        // GET: Matching
        public ActionResult Index()
        {
            //Check if user is logged in
            if (!PageAuthorization.Authorize()) return RedirectToAction("Login", "Users");

            //User user = new User();
            //user.Id = 72;
            var user = (User)Session["logged_in_user_obj"];

            var client = new SMARestClient("MeetUpService.svc");
            var meetupContent = client.Get<List<MeetUp>>("meetups/").ToList();
            List<MeetUp> received = new List<MeetUp>();
            List<MeetUp> sent = new List<MeetUp>();

            foreach (var item in meetupContent)
            {
                if (item.Guide.Id == user.Id)
                {
                    received.Add(item);
                }
            }

            foreach (var item in meetupContent)
            {
                if (item.Traveler.Id == user.Id)
                {
                    sent.Add(item);
                }
            }

            ViewBag.ReceivedRequest = received;
            ViewBag.SentRequest= sent;
            return View();
        }
Example #2
0
        public ActionResult Login(LoginCredentials credentials)
        {
            var client = new SMARestClient("SessionService.svc");
            Session newSession = null;

            try
            {
                newSession = client.Post<LoginCredentials, Session>("/login", credentials);
            }
            catch
            {
                newSession = null;
            }

            if(newSession == null)
            {
                ViewBag.Message = "Login failed. Please try again.";
                ViewBag.MessageClass = "text-danger";
                return View();
            }
            else
            {
                var user = new SMARestClient("UserService.svc").Get<User>($"/user/{newSession.UserID}");
                if (user != null) System.Web.HttpContext.Current.Session["logged_in_user_obj"] = user;
                System.Web.HttpContext.Current.Session["auth_token"] = newSession.Token;

                return RedirectToAction("Index", "Dashboard");
            }
        }
        public ActionResult Matching(int id)
        {
            MeetUp meetUp = new MeetUp();
            List<Match> matches = (List<Match>)TempData["Matches"];
            meetUp.Guide = matches[id].Guide;
            meetUp.Traveler = matches[id].Traveler;
            meetUp.StartDate = (DateTime)TempData["Start"];
            meetUp.FinishDate = (DateTime)TempData["End"];
            meetUp.City = new City { Name = (string)TempData["City"] };
            meetUp.City_Name = meetUp.City.Name;
            meetUp.TravelerState = RequestState.Sent;
            meetUp.GuideState = RequestState.Received;

            var client = new SMARestClient("MeetUpService.svc");
            client.AuthToken = (string)Session["auth_token"];
            MeetUp createdMeetUp = client.Post<MeetUp>("meetups/", meetUp);

            if (createdMeetUp == null)
            {
                return View();
            }
            else
            {
                return RedirectToAction("Index", "MeetUp", new { area = "" });
            }
        }
Example #4
0
        public Users()
        {
            InitializeComponent();
            client = new SMARestClient("UserService.svc");
            users = new List<User>();

            this.FormBorderStyle = FormBorderStyle.FixedSingle;
        }
Example #5
0
        public ActionResult Accept(int id)
        {
            var client = new SMARestClient("MeetUpService.svc");
            client.AuthToken = (string)Session["auth_token"];
            var mu = client.Get<MeetUp>("/meetup/" + id);
            mu.TravelerState = RequestState.Confirmed;
            mu.GuideState = RequestState.Confirmed;
            client.Put<MeetUp>("/meetup/" + id, mu);

            //return RedirectToAction("Index", "MeetUp", new { area = "" });
            return RedirectToAction("Index", "MeetUp");
        }
Example #6
0
        public ActionResult Register()
        {
            if (Session["logged_in_user_obj"] != null) return RedirectToAction("Index", "Dashboard");
            //Languages
            var uClient = new SMARestClient("UserService.svc");
            var languageContent = uClient.Get<List<Language>>("languages/");
            var languages = languageContent.ToList().Select(c => new SelectListItem
            {
                Text = c.Name,
                Value = c.Name.ToString(),
            }).ToList();

            ViewBag.LanguageList = languages;

            var cClient = new SMARestClient("CountryService.svc");
            var countryContent = cClient.Get<List<Country>>("countries/");
            var countries = countryContent.ToList().Select(c => new SelectListItem
            {
                Text = c.Name,
                Value = c.Name.ToString()
            }).ToList();

            ViewBag.CountryList = countries;

            //Interest
            var interestContent = uClient.Get<List<InterestPopularity>>("interests/popular");
            var interests = interestContent.ToList().Select(i => new SelectListItem
            {
                Text = i.Interest.Name,
                Value = i.Interest.Name.ToString(),
            }).ToList();

            var vm = new Models.Registration();

            foreach (var item in interestContent)
            {
                vm.Interests.Add(new Models.InterestModel { Interest = item.Interest, Popularity = item.Popularity });
            }

            var session = System.Web.HttpContext.Current.Session;
            return View(vm);
        }
        public ActionResult Matching(string city, DateTime start, DateTime end, int minAge, int maxAge)
        {
            // Check if user is logged in
            if (!PageAuthorization.Authorize()) return RedirectToAction("Login", "Users");

            var user = (User)Session["logged_in_user_obj"];
            //var city = (string)TempData["matching_city"];

            //var start = (DateTime)TempData["matching_start"];
            //var end = (DateTime)TempData["matching_end"];

            var client = new SMARestClient("MatchingService.svc");
            client.AuthToken = (string)Session["auth_token"];
            var matchesContent = client.Get<List<Match>>($"matches/{user.Id}?city={city}&minAge={minAge}&maxAge={maxAge}");

            ViewBag.MatchList = matchesContent.ToList<Match>();
            TempData["Matches"] = matchesContent;
            TempData["Start"] = start;
            TempData["End"] = end;
            TempData["City"] = city;
            ViewBag.City = city;
            return View();
        }
Example #8
0
        public ActionResult Register(Models.Registration registration)
        {
            //registration.User.Languages.Add(new Language("English"));
            //registration.User.Interests.Add(new Interest("String content 1"));

            var selectedInterests = new List<Interest>();
            foreach (var model in registration.Interests)
            {
                if (model.IsSelected) selectedInterests.Add(model.Interest);
            }

            registration.User.Languages = registration.LanguageContainer;
            registration.User.Interests = selectedInterests;

            var client = new SMARestClient("UserService.svc");
            User createdUser = client.Post<User>("users/", registration.User);
            if(createdUser == null)
            {
                ViewBag.Message = "User registration failed. Please try again later.";
                return View();
            }
            else
            {
                TempData["successful_registration_message"] = "Your user account has been successfully created and you are now able to login!";
                return RedirectToAction("Login");
            }
        }