Пример #1
0
 public ActionResult Edit(User u)
 {
     if ((string)Session["u_type"] == "Guide" && (int)Session["LoggedIn"] == 1)
     {
         int               i            = (int)Session["LoggedIn"];
         int               id           = (int)Session["uid"];
         string            u_type       = (string)Session["u_type"];
         ChaperoneEntities che          = new ChaperoneEntities();
         User              userToUpdate = che.Users.Where(x => x.Id == id).FirstOrDefault();
         userToUpdate.Name      = u.Name;
         userToUpdate.Languages = u.Languages;
         userToUpdate.Gender    = u.Gender;
         userToUpdate.Email     = u.Email;
         userToUpdate.Password  = u.Password;
         userToUpdate.Location  = u.Location;
         userToUpdate.Contact   = u.Contact;
         userToUpdate.Bio       = u.Bio;
         userToUpdate.Culture   = u.Culture;
         userToUpdate.Festival  = u.Festival;
         userToUpdate.Food      = u.Food;
         userToUpdate.NightLife = u.NightLife;
         userToUpdate.Sports    = u.Sports;
         che.SaveChanges();
         return(RedirectToAction("Index", "Guide"));
     }
     return(RedirectToAction("LogIn", "User"));
 }
Пример #2
0
 // GET: Review
 public ActionResult Index()
 {
     if ((int)Session["LoggedIn"] == 1 && (string)Session["u_type"] == "Gen")
     {
         int id = (int)Session["uid"];
         ChaperoneEntities che     = new ChaperoneEntities();
         List <Review>     reviews = che.Reviews.Where(x => x.ReviewerId == id).ToList();
         if (reviews == null || !reviews.Any())
         {
             TempData["ReviewMessage"] = "You haven't Reviewed anyone yet :(";
         }
         return(View(reviews));
     }
     if ((int)Session["LoggedIn"] == 1 && (string)Session["u_type"] == "Admin")
     {
         ChaperoneEntities che     = new ChaperoneEntities();
         List <Review>     reviews = che.Reviews.ToList();
         if (reviews == null || !reviews.Any())
         {
             TempData["ReviewMessage"] = "No available Reviews to show :(";
         }
         return(View("~/Views/Review/AdminIndex.cshtml", reviews));
     }
     return(RedirectToAction("LogIn", "User"));
 }
Пример #3
0
 public ActionResult GuidedProfile(int id)
 {
     if ((int)Session["LoggedIn"] == 1 && (string)Session["u_type"] == "Gen")
     {
         ChaperoneEntities che = new ChaperoneEntities();
         int     i             = (int)Session["uid"];
         User    guide         = che.Users.Where(x => x.Id == id).FirstOrDefault();
         User    tourist       = che.Users.Where(x => x.Id == i).FirstOrDefault();
         Request check         = che.Requests.Where(x => x.TouristId == i && x.GuideId == id && x.RequestState == "Pending").FirstOrDefault();
         if (check != null)
         {
             return(RedirectToAction("Index"));
         }
         Request r = new Request();
         r.Location     = (string)Session["Location"];
         r.GuideId      = guide.Id;
         r.Contact      = tourist.Contact;
         r.TouristId    = tourist.Id;
         r.StartDate    = (string)Session["startDate"];
         r.EndDate      = (string)Session["endDate"];
         r.RequestState = "Pending";
         che.Requests.Add(r);
         che.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(RedirectToAction("LogIn", "User"));
 }
Пример #4
0
 public ActionResult CreateReview(int id, Review r)
 {
     if ((int)Session["LoggedIn"] == 1 && (string)Session["u_type"] == "Gen")
     {
         if (ModelState.IsValid)
         {
             ChaperoneEntities che = new ChaperoneEntities();
             Request           req = che.Requests.Where(x => x.Id == id).FirstOrDefault();
             int reviewedId        = req.GuideId;
             int reviewerId        = (int)Session["uid"];
             r.ReviewedId = reviewedId;
             r.ReviewerId = reviewerId;
             Review verf = che.Reviews.Where(x => x.ReviewedId == reviewedId && x.ReviewerId == reviewerId).FirstOrDefault();
             if (verf != null)
             {
                 TempData["ReviewMessage"] = "Already Reviewed Onced";
                 return(RedirectToAction("Index", "Review"));
             }
             che.Reviews.Add(r);
             che.SaveChanges();
             TempData["ReviewMessage"] = "Thank You for your Review";
             return(RedirectToAction("Index", "Review"));
         }
         return(View(r));
     }
     return(RedirectToAction("LogIn", "User"));
 }
Пример #5
0
        public ActionResult Details(int id)
        {
            ChaperoneEntities che = new ChaperoneEntities();
            User u = che.Users.Where(x => x.Id == id).FirstOrDefault();

            return(View(u));
        }
Пример #6
0
        // GET: Admin
        public ActionResult Index()
        {
            if ((string)Session["u_type"] == "Admin" && (int)Session["LoggedIn"] == 1)
            {
                IDictionary <int, int> topGuides = new Dictionary <int, int>();
                ChaperoneEntities      che       = new ChaperoneEntities();
                List <User>            users     = che.Users.Where(x => x.User_type == "Guide").ToList();
                int maxScore   = 0;
                int topGuideId = 0;
                foreach (User u in users)
                {
                    List <Review> reviews     = che.Reviews.Where(x => x.ReviewedId == u.Id).ToList();
                    int           totalRating = 0;
                    foreach (Review r in reviews)
                    {
                        totalRating += (int)r.Rating;
                    }
                    topGuides.Add(u.Id, totalRating);

                    if (maxScore < totalRating)
                    {
                        maxScore   = totalRating;
                        topGuideId = u.Id;
                    }
                }
                if (topGuideId != 0)
                {
                    User   topGuide = che.Users.Where(x => x.Id == topGuideId).FirstOrDefault();
                    string name     = topGuide.Name;
                    TempData["TopGuide"] = name + " is the top guide with total score of " + maxScore;
                }
                return(View());
            }
            return(RedirectToAction("LogIn", "User"));
        }
Пример #7
0
 public ActionResult Edit(int id)
 {
     if ((int)Session["LoggedIn"] == 1 && (string)Session["u_type"] == "Admin")
     {
         ChaperoneEntities che = new ChaperoneEntities();
         Message           m   = che.Messages.Where(x => x.Id == id).FirstOrDefault();
         return(View());
     }
     return(RedirectToAction("LogIn", "User"));
 }
Пример #8
0
 public ActionResult GuideProfile(int id)
 {
     if ((int)Session["LoggedIn"] == 1 && (string)Session["u_type"] == "Gen")
     {
         ChaperoneEntities che = new ChaperoneEntities();
         User u = che.Users.Where(x => x.Id == id).FirstOrDefault();
         return(View(u));
     }
     return(RedirectToAction("LogIn", "User"));
 }
Пример #9
0
        public ActionResult GetGenderData()
        {
            ChaperoneEntities che = new ChaperoneEntities();
            int    male           = che.Users.Where(x => x.Gender.Contains("Male") && x.User_type == "Guide").Count();
            int    female         = che.Users.Where(x => x.Gender.Contains("Female") && x.User_type == "Guide").Count();
            Ratio2 obj            = new Ratio2();

            obj.Male   = male;
            obj.Female = female;
            return(Json(obj, JsonRequestBehavior.AllowGet));
        }
Пример #10
0
 public ActionResult Edit()
 {
     if ((string)Session["u_type"] == "Admin" && (int)Session["LoggedIn"] == 1)
     {
         ChaperoneEntities che = new ChaperoneEntities();
         int  id = (int)Session["uid"];
         User u  = che.Users.Where(x => x.Id == id).FirstOrDefault();
         return(View(u));
     }
     return(RedirectToAction("LogIn", "User"));
 }
Пример #11
0
 // GET: Guide
 public ActionResult Index()
 {
     if ((string)Session["u_type"] == "Guide" && (int)Session["LoggedIn"] == 1)
     {
         int i = (int)Session["uid"];
         ChaperoneEntities che   = new ChaperoneEntities();
         User           guide    = che.Users.Where(x => x.Id == i && x.User_type == "Guide").FirstOrDefault();
         List <Request> requests = che.Requests.Where(x => x.GuideId == i).ToList();
         return(View(requests));
     }
     return(RedirectToAction("LogIn", "User"));
 }
Пример #12
0
 public ActionResult deleteGuide(int id)
 {
     if ((string)Session["u_type"] == "Admin" && (int)Session["LoggedIn"] == 1)
     {
         ChaperoneEntities che = new ChaperoneEntities();
         User u = che.Users.Where(x => x.Id == id).FirstOrDefault();
         u.status = "Banned";
         che.SaveChanges();
         return(RedirectToAction("Guides"));
     }
     return(RedirectToAction("LogIn", "User"));
 }
Пример #13
0
 public ActionResult GenUserRequestIndex()
 {
     if ((int)Session["LoggedIn"] == 1 && (string)Session["u_type"] == "Gen")
     {
         int               i            = (int)Session["LoggedIn"];
         string            u_type       = (string)Session["u_type"];
         int               id           = (int)Session["uid"];
         ChaperoneEntities che          = new ChaperoneEntities();
         List <Request>    userRequests = che.Requests.Where(x => x.TouristId == id).ToList();
         return(View(userRequests));
     }
     return(RedirectToAction("Index"));
 }
Пример #14
0
 public ActionResult Guides()
 {
     if ((string)Session["u_type"] == "Admin" && (int)Session["LoggedIn"] == 1)
     {
         ChaperoneEntities che    = new ChaperoneEntities();
         List <User>       Guides = che.Users.Where(x => x.User_type == "Guide").ToList();
         if (Guides != null)
         {
             return(View(Guides));
         }
     }
     return(RedirectToAction("LogIn", "User"));
 }
Пример #15
0
 public ActionResult Delete(int id)
 {
     if ((int)Session["LoggedIn"] == 1 && (string)Session["u_type"] == "Admin")
     {
         ChaperoneEntities che = new ChaperoneEntities();
         Message           m   = che.Messages.Where(x => x.Id == id).FirstOrDefault();
         che.Messages.Remove(m);
         che.SaveChanges();
         TempData["messageMessage"] = "Message Deleted";
         return(RedirectToAction("Index"));
     }
     return(RedirectToAction("LogIn", "User"));
 }
Пример #16
0
        public ActionResult GetData()
        {
            ChaperoneEntities che = new ChaperoneEntities();
            int   gen             = che.Users.Where(x => x.User_type == "Gen").Count();
            int   guide           = che.Users.Where(x => x.User_type == "Guide").Count();
            int   admin           = che.Users.Where(x => x.User_type == "Admin").Count();
            Ratio obj             = new Ratio();

            obj.Admin   = admin;
            obj.Guide   = guide;
            obj.Tourist = gen;

            return(Json(obj, JsonRequestBehavior.AllowGet));
        }
Пример #17
0
 public ActionResult GuideReview(int id)
 {
     if ((int)Session["LoggedIn"] == 1 && (string)Session["u_type"] == "Gen")
     {
         ChaperoneEntities che     = new ChaperoneEntities();
         List <Review>     reviews = che.Reviews.Where(x => x.ReviewedId == id).ToList();
         if (reviews == null || !reviews.Any())
         {
             TempData["profileReviewMessage"] = "Sorry...No reviews Yet :(";
         }
         return(View(reviews));
     }
     return(RedirectToAction("LogIn", "User"));
 }
Пример #18
0
 public ActionResult CreateGuide(User u)
 {
     if (ModelState.IsValid)
     {
         ChaperoneEntities che = new ChaperoneEntities();
         u.User_type = "Guide";
         u.status    = "Active";
         che.Users.Add(u);
         che.SaveChanges();
         TempData["LogInMessage"] = "Account Successfully Created. Please Log in";
         return(RedirectToAction("LogIn"));
     }
     return(View(u));
 }
Пример #19
0
        public ActionResult GetVisitData()
        {
            ChaperoneEntities che = new ChaperoneEntities();
            int        Dhaka      = che.Visits.Where(x => x.Location == "Dhaka").Count();
            int        Tokyo      = che.Visits.Where(x => x.Location == "Tokyo").Count();
            int        London     = che.Visits.Where(x => x.Location == "London").Count();
            int        newYork    = che.Visits.Where(x => x.Location == "New York").Count();
            VisitRatio obj        = new VisitRatio();

            obj.Dhaka   = Dhaka;
            obj.Tokyo   = Tokyo;
            obj.newYork = newYork;
            obj.London  = London;
            return(Json(obj, JsonRequestBehavior.AllowGet));
        }
Пример #20
0
 public ActionResult RejectRequest(int id)
 {
     if ((string)Session["u_type"] == "Guide" && (int)Session["LoggedIn"] == 1)
     {
         int guideId           = (int)Session["uid"];
         ChaperoneEntities che = new ChaperoneEntities();
         Request           r   = che.Requests.Where(x => x.Id == id && x.GuideId == guideId && x.RequestState == "Pending").FirstOrDefault();
         if (r != null)
         {
             r.RequestState = "Rejected";
             che.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     return(RedirectToAction("LogIn", "User"));
 }
Пример #21
0
 public ActionResult Create(User u)
 {
     if ((string)Session["u_type"] == "Admin" && (int)Session["LoggedIn"] == 1)
     {
         if (ModelState.IsValid)
         {
             ChaperoneEntities che = new ChaperoneEntities();
             u.User_type = "Admin";
             u.status    = "Active";
             che.Users.Add(u);
             che.SaveChanges();
             return(RedirectToAction("Admins"));
         }
         return(View(u));
     }
     return(RedirectToAction("LogIn", "User"));
 }
Пример #22
0
 public ActionResult Edit(User u)
 {
     if ((int)Session["LoggedIn"] == 1 && (string)Session["u_type"] == "Gen")
     {
         int id = (int)Session["uid"];
         ChaperoneEntities che = new ChaperoneEntities();
         User userToUpdate     = che.Users.Where(x => x.Id == id).FirstOrDefault();
         userToUpdate.Name     = u.Name;
         userToUpdate.Email    = u.Email;
         userToUpdate.Password = u.Password;
         userToUpdate.Location = u.Location;
         userToUpdate.Contact  = u.Contact;
         che.SaveChanges();
         return(RedirectToAction("Index", "GenUser"));
     }
     return(RedirectToAction("LogIn", "User"));
 }
Пример #23
0
 public ActionResult Edit(User u)
 {
     if ((string)Session["u_type"] == "Admin" && (int)Session["LoggedIn"] == 1)
     {
         ChaperoneEntities che = new ChaperoneEntities();
         int  id            = (int)Session["uid"];
         User adminToUpdate = che.Users.Where(x => x.Id == id).FirstOrDefault();
         adminToUpdate.Name     = u.Name;
         adminToUpdate.Email    = u.Email;
         adminToUpdate.Contact  = u.Contact;
         adminToUpdate.Password = u.Password;
         adminToUpdate.Location = u.Location;
         che.SaveChanges();
         return(RedirectToAction("Edit"));
     }
     return(RedirectToAction("LogIn", "User"));
 }
Пример #24
0
 public ActionResult Create(Message m)
 {
     if ((int)Session["LoggedIn"] == 1 && (string)Session["u_type"] == "Admin")
     {
         if (ModelState.IsValid)
         {
             m.Form = (string)Session["uname"];
             ChaperoneEntities che = new ChaperoneEntities();
             che.Messages.Add(m);
             che.SaveChanges();
             TempData["messageMessage"] = "Message Sent";
             return(RedirectToAction("Index"));
         }
         return(View(m));
     }
     return(RedirectToAction("LogIn", "User"));
 }
Пример #25
0
 public ActionResult Edit(Message m, int id)
 {
     if ((int)Session["LoggedIn"] == 1 && (string)Session["u_type"] == "Admin")
     {
         if (ModelState.IsValid)
         {
             ChaperoneEntities che      = new ChaperoneEntities();
             Message           toUpdate = che.Messages.Where(x => x.Id == id).FirstOrDefault();
             toUpdate.Message1 = m.Message1;
             toUpdate.To       = m.To;
             che.SaveChanges();
             TempData["messageMessage"] = "Message Updated";
             return(RedirectToAction("Index"));
         }
         return(View(m));
     }
     return(RedirectToAction("LogIn", "User"));
 }
Пример #26
0
 public ActionResult closeRequest(int id)
 {
     if ((int)Session["LoggedIn"] == 1 && (string)Session["u_type"] == "Gen")
     {
         int               i      = (int)Session["LoggedIn"];
         string            u_type = (string)Session["u_type"];
         int               userId = (int)Session["uid"];
         ChaperoneEntities che    = new ChaperoneEntities();
         Request           r      = che.Requests.Where(x => x.Id == id && x.RequestState == "Accepted").FirstOrDefault();
         if (r != null)
         {
             r.RequestState = "Closed";
             che.SaveChanges();
         }
         return(RedirectToAction("GenUserRequestIndex"));
     }
     return(RedirectToAction("Index", "Home"));
 }
Пример #27
0
 public ActionResult requestDone(int id)
 {
     if ((int)Session["LoggedIn"] == 1 && (string)Session["u_type"] == "Gen")
     {
         int               i      = (int)Session["LoggedIn"];
         string            u_type = (string)Session["u_type"];
         int               userId = (int)Session["uid"];
         ChaperoneEntities che    = new ChaperoneEntities();
         Request           r      = che.Requests.Where(x => x.Id == id && x.RequestState == "Accepted").FirstOrDefault();
         if (r != null)
         {
             r.RequestState = "Done";
             Visit v = new Visit();
             v.TouristId = userId;
             v.Location  = r.Location;
             che.Visits.Add(v);
             che.SaveChanges();
         }
         return(RedirectToAction("GenUserRequestIndex"));
     }
     return(RedirectToAction("Index", "Home"));
 }
Пример #28
0
        public ActionResult LogIn(User u)
        {
            ChaperoneEntities che = new ChaperoneEntities();
            User verfUser         = che.Users.Where(x => x.Email.Equals(u.Email)).FirstOrDefault();

            if (verfUser != null)
            {
                if (u.Password == verfUser.Password && verfUser.status == "Active")
                {
                    //initialize SESSION components.......
                    Session["LoggedIn"] = 1;
                    Session["uname"]    = verfUser.Name;
                    Session["uid"]      = verfUser.Id;
                    Session["u_type"]   = verfUser.User_type;
                    if (verfUser.User_type == "Gen")
                    {
                        return(RedirectToAction("Index", "GenUser"));
                    }
                    if (verfUser.User_type == "Guide")
                    {
                        return(RedirectToAction("Index", "Guide"));
                    }
                    if (verfUser.User_type == "Admin")
                    {
                        return(RedirectToAction("Index", "Admin"));
                    }
                }
                if (verfUser.status == "Banned")
                {
                    TempData["LogInMessage"] = "You are Banned. Please Contact Admin for further Queries";
                }
                else
                {
                    TempData["LogInMessage"] = "Invalide Username or Password";
                }
            }
            return(RedirectToAction("LogIn"));
        }
Пример #29
0
 // GET: Message
 public ActionResult Index()
 {
     if ((int)Session["LoggedIn"] == 1 && (string)Session["u_type"] == "Gen")
     {
         ChaperoneEntities che = new ChaperoneEntities();
         int            id     = (int)Session["uid"];
         List <Message> msgs   = che.Messages.Where(m => m.To == "Gen" || m.To == "All").ToList();
         if (msgs == null || !msgs.Any())
         {
             TempData["messageMessage"] = "Nothing to show here";
         }
         return(View(msgs));
     }
     if ((int)Session["LoggedIn"] == 1 && (string)Session["u_type"] == "Guide")
     {
         ChaperoneEntities che = new ChaperoneEntities();
         int            id     = (int)Session["uid"];
         List <Message> msgs   = che.Messages.Where(m => m.To == "Guide" || m.To == "All").ToList();
         if (msgs == null || !msgs.Any())
         {
             TempData["messageMessage"] = "Nothing to show here";
         }
         return(View("~/Views/Message/IndexGuide.cshtml", msgs));
     }
     if ((int)Session["LoggedIn"] == 1 && (string)Session["u_type"] == "Admin")
     {
         ChaperoneEntities che = new ChaperoneEntities();
         int            id     = (int)Session["uid"];
         List <Message> msgs   = che.Messages.ToList();
         if (msgs == null || !msgs.Any())
         {
             TempData["messageMessage"] = "Nothing to show here";
         }
         return(View("~/Views/Message/IndexAdmin.cshtml", msgs));
     }
     return(View("User", "LogIn"));
 }
Пример #30
0
 public ActionResult Index(SearchModel s)
 {
     if ((int)Session["LoggedIn"] == 1 && (string)Session["u_type"] == "Gen")
     {
         if (ModelState.IsValid)
         {
             ChaperoneEntities che       = new ChaperoneEntities();
             List <User>       tempUsers = che.Users.ToList();
             Session["startDate"] = s.StartDate.ToString("dd/MM/yyyy");
             Session["endDate"]   = s.EndDate.ToString("dd/MM/yyyy");
             Session["Location"]  = s.searchString;
             Users = new List <User>();
             foreach (User u in tempUsers)
             {
                 if (u.User_type == "Guide")
                 {
                     if (u.Location.ToString().Contains(s.searchString.ToString()))
                     {
                         Users.Add(u);
                     }
                 }
             }
             tempUsers = Users.ToList();
             if (s.Female)
             {
                 Users = new List <User>();
                 foreach (User u in tempUsers.ToList())
                 {
                     if (u.Gender == "Female")
                     {
                         Users.Add(u);
                     }
                 }
             }
             tempUsers = Users.ToList();
             if (s.Male)
             {
                 Users = new List <User>();
                 foreach (User u in tempUsers.ToList())
                 {
                     if (u.Gender == "Male")
                     {
                         Users.Add(u);
                     }
                 }
             }
             tempUsers = Users.ToList();
             if (s.culture)
             {
                 Users = new List <User>();
                 foreach (User u in tempUsers.ToList())
                 {
                     if (Convert.ToBoolean(u.Culture))
                     {
                         Users.Add(u);
                     }
                 }
             }
             tempUsers = Users.ToList();
             if (s.nightlife)
             {
                 Users = new List <User>();
                 foreach (User u in tempUsers.ToList())
                 {
                     if (Convert.ToBoolean(u.NightLife))
                     {
                         Users.Add(u);
                     }
                 }
             }
             tempUsers = Users.ToList();
             if (s.sports)
             {
                 Users = new List <User>();
                 foreach (User u in tempUsers.ToList())
                 {
                     if (Convert.ToBoolean(u.Sports))
                     {
                         Users.Add(u);
                     }
                 }
             }
             tempUsers = Users.ToList();
             if (s.festival)
             {
                 Users = new List <User>();
                 foreach (User u in tempUsers.ToList())
                 {
                     if (Convert.ToBoolean(u.Festival))
                     {
                         Users.Add(u);
                     }
                 }
             }
             tempUsers = Users.ToList();
             if (s.food)
             {
                 Users = new List <User>();
                 foreach (User u in tempUsers.ToList())
                 {
                     if (Convert.ToBoolean(u.Food))
                     {
                         Users.Add(u);
                     }
                 }
             }
             return(View(Users));
         }
         return(View("~/Views/User/GenUserDash.cshtml", s));
     }
     return(RedirectToAction("LogIn", "User"));
 }