public ActionResult ChangeEventAvatar(HttpPostedFileBase file, long eventID)
        {
            User user = UserHelpers.GetCurrentUser(Session);

            if (user == null)
            {
                if (Request.Cookies["userName"] != null && Request.Cookies["password"] != null)
                {
                    string userName = Request.Cookies["userName"].Value;
                    string password = Request.Cookies["password"].Value;
                    if (UserDatabaseHelper.Instance.ValidateUser(userName, password))
                    {
                        user = UserDatabaseHelper.Instance.GetUserByUserName(userName);
                        if (UserDatabaseHelper.Instance.isLookedUser(user.UserName))
                        {
                            TempData["errorTitle"]   = "Locked User";
                            TempData["errorMessage"] = "Your account is locked! Please contact with our support";

                            return(RedirectToAction("Index", "Home"));
                        }
                        UserHelpers.SetCurrentUser(Session, user);
                    }
                    TempData["errorTitle"]   = "Require Signin";
                    TempData["errorMessage"] = "Ops.. It look like you are current is not signed in system! Please sign in first!";
                    return(RedirectToAction("Details", "Event", new { id = eventID }));
                }
            }


            if (file != null)
            {
                Image photo = EventDatabaseHelper.Instance.UserAddImage(file, user.UserID);
                if (photo != null)
                {
                    if (EventDatabaseHelper.Instance.ChangeEventAvatar(eventID, photo))
                    {
                    }
                }
                else
                {
                    TempData["errorTitle"]   = "Erorr";
                    TempData["errorMessage"] = "Something wrong! Please try again later!";
                }
            }
            else
            {
                TempData["ImageUploadError"] = "Your must select a file to upload";
            }
            return(RedirectToAction("Details", "Event", new { id = eventID }));
        }
        public ActionResult SignUp()
        {
            User user = UserHelpers.GetCurrentUser(Session);

            if (user != null)
            {
                TempData["errorTittle"]  = "Bad request";
                TempData["errorMessage"] = "You are already signed in the system";
                return(RedirectToAction("Index", "Home"));
            }
            TempData["errorTitle"]   = null;
            TempData["errorMessage"] = null;
            return(PartialView());
        }
Beispiel #3
0
        private void LoadDataWishlist(int skip)
        {
            User user = UserHelpers.GetCurrentUser(Session);

            if (user != null)
            {
                /**
                 * Search limit following post
                 */
                var listPost = GraphDatabaseHelpers.Instance.FindLimitWishlist(user, skip, RecordsPerPage);
                FindRelatedInformationPost(listPost);
            }

            ViewData["typePost"] = "wish";
        }
        public ActionResult Search(string keyword = "")
        {
            User user = UserHelpers.GetCurrentUser(Session);

            if (user == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            List <User>   listUser         = GraphDatabaseHelpers.Instance.SearchUserByKeyword(keyword.ToUpper());
            List <Place>  listPlace        = GraphDatabaseHelpers.Instance.SearchPlaceByKeyword(keyword.ToUpper());
            List <int>    listMutualFriend = new List <int>();
            List <string> listRelationUser = new List <string>();
            List <Room>   listRoom         = GraphDatabaseHelpers.Instance.SearchRoomByKeyword(keyword.ToUpper());

            Dictionary <int, List <Photo> > listPhotoDict    = new Dictionary <int, List <Photo> >();
            Dictionary <int, int>           numberOfPostDict = new Dictionary <int, int>();
            Dictionary <int, bool>          wishlist         = new Dictionary <int, bool>();


            List <User> listAdminRoom = listRoom.Select(room => GraphDatabaseHelpers.Instance.FindAdminInRoom(room.RoomId)).ToList();

            listUser.RemoveAll(u => u.UserId == user.UserId);
            foreach (var u in listUser)
            {
                listMutualFriend.Add(GraphDatabaseHelpers.Instance.CountMutualFriend(user.UserId, u.UserId));
                listRelationUser.Add(GraphDatabaseHelpers.Instance.GetFriendType(user.UserId, u.UserId));
            }

            foreach (var place in listPlace)
            {
                listPhotoDict.Add(place.PlaceId, GraphDatabaseHelpers.Instance.SearchPhotoInPlace(place.PlaceId));
                numberOfPostDict.Add(place.PlaceId, GraphDatabaseHelpers.Instance.CountPostAtPlace(place.PlaceId));
                wishlist.Add(place.PlaceId, GraphDatabaseHelpers.Instance.IsInWishist(place.PlaceId, user.UserId));
            }

            ViewData["listRoom"]         = listRoom;
            ViewData["listAdminRoom"]    = listAdminRoom;
            ViewData["listUser"]         = listUser;
            ViewData["listPlace"]        = listPlace;
            ViewData["keyword"]          = keyword;
            ViewData["listPhotoDict"]    = listPhotoDict;
            ViewData["numberOfPostDict"] = numberOfPostDict;
            ViewData["wishlist"]         = wishlist;
            ViewData["listMutualFriend"] = listMutualFriend;
            ViewData["listRelationUser"] = listRelationUser;
            return(View());
        }
Beispiel #5
0
        public ActionResult ChangePasswordPost(ChangePasswordView chgpwd)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new
                {
                    state = 0,
                    message = "Invalid model"
                }));
            }
            User user = UserHelpers.GetCurrentUser(Session);

            if (user == null)
            {
                return(Json(new
                {
                    state = 0,
                    message = "require signin"
                }));
            }
            else
            {
                if (!UserDatabaseHelper.Instance.ValidateUser(user.UserName, chgpwd.OldPassword))
                {
                    return(Json(new
                    {
                        state = 0,
                        message = "wrong old passsword"
                    }));
                }
                else if (UserDatabaseHelper.Instance.ChangePassword(user, chgpwd.NewPassword))
                {
                    return(Json(new
                    {
                        state = 1,
                        message = ""
                    }));
                }
                else
                {
                    return(Json(new
                    {
                        state = 0,
                        message = "something wrong!"
                    }));
                }
            }
        }
        public ActionResult Comment(int postId, string content)
        {
            User user = UserHelpers.GetCurrentUser(Session);
            Dictionary <int, User> dict = new Dictionary <int, Models.User>();
            Comment comment             = new Comment();

            comment.Content     = content.Replace("\n", "\\n");
            comment.DateCreated = DateTime.Now.ToString(FapConstants.DatetimeFormat);

            bool success = GraphDatabaseHelpers.Instance.InsertComment(postId, comment, user.UserId);

            dict.Add(comment.CommentId, user);

            ViewData["dict"] = dict;
            return(PartialView("_PostDetailPartial", comment));
        }
        public ActionResult Logout()
        {
            User user = UserHelpers.GetCurrentUser(Session);

            if (user.TypeId == 2)
            {
                GoogleConnect.Clear();
            }
            Session["authenicated"]      = "";
            Session["username"]          = "";
            Session["userAva"]           = "";
            Session["UserId"]            = "";
            Session["loginMessageError"] = "";
            UserHelpers.SetCurrentUser(Session, null);
            return(RedirectToAction("Index", "Home"));
        }
 public ActionResult LoadPostInPlace(int placeId = 0)
 {
     if (Request.IsAjaxRequest())
     {
         User  user         = UserHelpers.GetCurrentUser(Session);
         Place currentPlace = GraphDatabaseHelpers.Instance.FindPlaceById(placeId);
         if (user == null || currentPlace == null)
         {
             return(null);
         }
         List <Post> listPost = GraphDatabaseHelpers.Instance.FindPostInPlace(placeId);
         FindRelatedInformationPost(listPost, currentPlace);
         return(PartialView("_ListPost"));
     }
     return(null);
 }
Beispiel #9
0
        public ActionResult ManageEvent()
        {
            User user = UserHelpers.GetCurrentUser(Session);

            if (user == null)
            {
                TempData["errorTitle"]   = "Require Signin";
                TempData["errorMessage"] = "Ops.. It look like you are current is not signed in system! Please sign in first!";
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                List <Event> myevent = UserDatabaseHelper.Instance.GetUserEvent(user.UserID);
                List <ViewThumbEventModel> listThumb = EventDatabaseHelper.Instance.GetThumbEventListByListEvent(myevent);
                return(View());
            }
        }
Beispiel #10
0
        public ActionResult BasicSearch(BasicSearch model, int tab = -1)
        {
            User user = UserHelpers.GetCurrentUser(Session);

            if (user == null)
            {
                if (Request.Cookies["userName"] != null && Request.Cookies["password"] != null)
                {
                    string userName = Request.Cookies["userName"].Value;
                    string password = Request.Cookies["password"].Value;
                    if (UserDatabaseHelper.Instance.ValidateUser(userName, password))
                    {
                        user = UserDatabaseHelper.Instance.GetUserByUserName(userName);
                        if (UserDatabaseHelper.Instance.isLookedUser(user.UserName))
                        {
                            TempData["errorTitle"]   = "Locked User";
                            TempData["errorMessage"] = "Your account is locked! Please contact with our support";

                            return(RedirectToAction("Index", "Home"));
                        }
                        UserHelpers.SetCurrentUser(Session, user);
                    }
                }
            }
            string keyword;

            if (model.Keyword.IsNullOrWhiteSpace())
            {
                keyword = "";
            }
            else
            {
                keyword = model.Keyword;
            }
            keyword = keyword.Trim();
            TempData["TabSearch"] = tab;
            Session["listEvent"]  =
                EventDatabaseHelper.Instance.GetThumbEventListByListEvent(
                    EventDatabaseHelper.Instance.SearchEventByKeyword(keyword));
            Session["listLiveStream"] =
                EventDatabaseHelper.Instance.GetThumbEventListByListEvent(
                    EventDatabaseHelper.Instance.SearchLiveStreamByKeyword(keyword));
            Session["listUser"] = UserDatabaseHelper.Instance.GetUserThumbByList(UserDatabaseHelper.Instance.SearchUserByKeyword(keyword));
            TempData["task"]    = "Search";
            return(View("SearchResult"));
        }
Beispiel #11
0
        /// <summary>
        /// View User index của user có userID= userID,
        /// nếu userID = -1 thì view trang quản lý user của người đăng nhập,
        /// nếu user chưa đăng nhập và userID=-1 thì trở về trang Home
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        public ActionResult Index(long userID = -1)
        {
            User user = UserHelpers.GetCurrentUser(Session);

            if (userID == -1)
            {
                if (user == null)
                {
                    if (Request.Cookies["userName"] != null && Request.Cookies["password"] != null)
                    {
                        string userName = Request.Cookies["userName"].Value;
                        string password = Request.Cookies["password"].Value;
                        if (UserDatabaseHelper.Instance.ValidateUser(userName, password))
                        {
                            user = UserDatabaseHelper.Instance.GetUserByUserName(userName);
                            if (UserDatabaseHelper.Instance.isLookedUser(user.UserName))
                            {
                                TempData["errorTitle"]   = "Locked User";
                                TempData["errorMessage"] = "Your account is locked! Please contact with our support";
                            }
                            else
                            {
                                UserHelpers.SetCurrentUser(Session, user);
                            }
                        }
                    }
                }
            }
            else
            {
                user = UserDatabaseHelper.Instance.GetUserByID(userID);
                if (user == null)
                {
                    TempData["errorTitle"]   = "Not Avaiable";
                    TempData["errorMessage"] = "Ops.. This user does not exists in the system!";
                    return(RedirectToAction("Index", "Home"));
                }
                else if (user.AccountStatus == EventZoneConstants.Lock)
                {
                    TempData["errorTitle"]   = "Locked User";
                    TempData["errorMessage"] = "Ops.. This user has been locked!";
                    return(RedirectToAction("Index", "Home"));
                }
            }
            return(View(user));
        }
        public JsonResult GetMessage(int friendId)
        {
            User           user        = UserHelpers.GetCurrentUser(Session);
            List <Message> listMessage = new List <Message>();
            List <User>    listUser    = new List <User>();

            if (user != null)
            {
                listMessage = GraphDatabaseHelpers.Instance.GetListMessage(user.UserId, friendId, 10);
                for (int i = 0; i < listMessage.Count; i++)
                {
                    listUser.Add(GraphDatabaseHelpers.Instance.FindUser(listMessage[i]));
                }
            }
            KeyValuePair <List <Message>, List <User> > returnObject = new KeyValuePair <List <Message>, List <User> >(listMessage, listUser);

            return(Json(returnObject));
        }
Beispiel #13
0
        public ActionResult VideoAdd(String VideoURL, long LocationID, long EventID)
        {
            User user = UserHelpers.GetCurrentUser(Session);

            if (user == null)
            {
                if (Request.Cookies["userName"] != null && Request.Cookies["password"] != null)
                {
                    string userName = Request.Cookies["userName"].Value;
                    string password = Request.Cookies["password"].Value;
                    if (UserDatabaseHelper.Instance.ValidateUser(userName, password))
                    {
                        user = UserDatabaseHelper.Instance.GetUserByUserName(userName);
                        if (UserDatabaseHelper.Instance.isLookedUser(user.UserName))
                        {
                            TempData["errorTitle"]   = "Locked User";
                            TempData["errorMessage"] = "Your account is locked! Please contact with our support";

                            return(RedirectToAction("Index", "Home"));
                        }
                        UserHelpers.SetCurrentUser(Session, user);
                    }
                    TempData["errorTitle"]   = "Require Signin";
                    TempData["errorMessage"] = "Ops.. It look like you are current is not signed in system! Please sign in first!";
                    return(RedirectToAction("Details", "Event", new { id = EventID }));
                }
            }
            Video newVideo = new Video();

            newVideo.EventPlaceID = LocationHelpers.Instance.GetEventPlacesID(EventID, LocationID);
            newVideo.StartTime    = DateTime.Now;
            newVideo.Privacy      = 1;
            newVideo.VideoLink    = VideoURL;
            if (EventDatabaseHelper.Instance.AddVideo(newVideo))
            {
                TempData["VideoAddError"] = null; // success
            }
            else
            {
                TempData["VideoAddError"] = "There is something wrong";
            }
            return(RedirectToAction("Details", "Event", new { id = EventID }));
        }
Beispiel #14
0
        public ActionResult UpdateInfoPost(EditUserModel editUserModel)
        {
            try
            {
                // TODO: Add update logic here
                if (ModelState.IsValid)
                {
                    User user = UserHelpers.GetCurrentUser(Session);
                    if (user == null)
                    {
                        ModelState.AddModelError("", "You are signed out!Please signin to do this!");
                        return(RedirectToAction("EditProfile"));
                    }
                    user.UserFirstName = editUserModel.UserFirstName;
                    user.UserLastName  = editUserModel.UserLastName;
                    user.UserDOB       = editUserModel.UserDOB;
                    user.IDCard        = editUserModel.IDCard;
                    user.Gender        = editUserModel.Gender;
                    user.Phone         = editUserModel.Phone;
                    user.Place         = editUserModel.Place;

                    if (UserDatabaseHelper.Instance.UpdateUser(user))
                    {
                        UserHelpers.SetCurrentUser(Session, user);
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Something went wrong! Please try again!");
                        return(RedirectToAction("EditProfile"));
                    }
                }
                ModelState.AddModelError("", "Something went wrong! Please try again!");
                return(RedirectToAction("EditProfile"));
            }
            catch (Exception ex)
            {
                TempData["ManageProfileTask"] = "EditProfile";
                ModelState.AddModelError("", "Something went wrong! Please try again!");
                return(RedirectToAction("EditProfile"));
            }
        }
Beispiel #15
0
        public ActionResult ReadNotification(int notificationChangeID)
        {
            NotificationChange item = NotificationDataHelpers.Instance.GetNotificationChangeByID(notificationChangeID);
            User user     = UserHelpers.GetCurrentUser(Session);
            int  notiType = NotificationDataHelpers.Instance.GetNotificationObjectByID(item.NotificationObjectID).Type;

            if (notiType == EventZoneConstants.FollowingUserAddNewEvent)
            {
                NotificationDataHelpers.Instance.ReadNotification(item);
            }
            else if (notiType == EventZoneConstants.CommentNotification)
            {
                NotificationDataHelpers.Instance.ReadNotifiComment(item, user.UserID);
            }
            else if (notiType == EventZoneConstants.NewFollower)
            {
                NotificationDataHelpers.Instance.ReadNotifiNewFollow(item, user.UserID);
            }
            else if (notiType == EventZoneConstants.RequestUploadImage)
            {
                NotificationDataHelpers.Instance.ReadNotifiRequestUploadImage(item);
            }
            else if (notiType == EventZoneConstants.EventHasBeenLocked)
            {
                NotificationDataHelpers.Instance.ReadNotification(item);
            }
            else if (notiType == EventZoneConstants.EventHasBeenUnLocked)
            {
                NotificationDataHelpers.Instance.ReadNotification(item);
                //<li>
                //    <a onlick="ReadNoty(@item.ID)" href="@Url.Action("Details", "Event", new {id = item.EventID})">Good new! Your event @EventDatabaseHelper.Instance.GetEventByID(item.EventID).EventName has been unlocked</a>
                //</li>
                //<li role="separator" class="divider"></li>
            }
            else if (notiType == EventZoneConstants.ReportNotification)
            {
                NotificationDataHelpers.Instance.ReadNotifiReport(item, user.UserID);
            }
            return(Json(new
            {
            }));
        }
        public ActionResult LookAround(double longitude, double latitude, string name)
        {
            List <Post>   listPost     = new List <Post>();
            List <Place>  listPlace    = new List <Place>();
            List <Double> distance     = new List <double>();
            Place         currentPlace = null;
            User          user         = UserHelpers.GetCurrentUser(Session);

            if (user == null)
            {
                /*
                 * User not login
                 */
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                /**
                 * Search limit following post
                 */
                currentPlace = GraphDatabaseHelpers.Instance.FindPlaceByCoordinate(longitude, latitude);
                if (currentPlace == null)
                {
                    currentPlace           = new Place();
                    currentPlace.PlaceId   = -1;
                    currentPlace.Name      = name;
                    currentPlace.Longitude = longitude;
                    currentPlace.Latitude  = latitude;
                }
                listPost  = GraphDatabaseHelpers.Instance.FindPostInPlace(currentPlace.PlaceId);
                listPlace = GraphDatabaseHelpers.Instance.SearchPlaceByKeyword("");
                listPlace.Remove(currentPlace);
                listPlace.RemoveAll(item => (CalculateDistance(currentPlace, item) - 50.0) > 1E-6);

                distance.AddRange(listPlace.Select(p => CalculateDistance(currentPlace, p)));
                FindRelatedInformationPost(listPost, currentPlace);
            }

            ViewData["currentPlace"] = currentPlace;
            ViewData["listPlace"]    = JsonConvert.SerializeObject(listPlace);
            return(View("SearchDetail"));
        }
        public JsonResult EditProfile(string firstName, string lastName, string address, string gender, string phoneNumber,
                                      string dateOfBirth, string password)
        {
            User user    = UserHelpers.GetCurrentUser(Session);
            bool success = false;

            if (user != null)
            {
                user.FirstName   = firstName;
                user.LastName    = lastName;
                user.Address     = address;
                user.Gender      = gender;
                user.PhoneNumber = phoneNumber;
                user.DateOfBirth = dateOfBirth;
                user.Password    = password;

                success = GraphDatabaseHelpers.Instance.EditProfile(user);
            }
            return(Json(success));
        }
Beispiel #18
0
        public ActionResult UpdateInfo()
        {
            User userSession = UserHelpers.GetCurrentUser(Session);

            if (userSession == null)
            {
                TempData["errorTitle"]   = "Require Signin";
                TempData["errorMessage"] = "Ops.. It look like you are current is not signed in system! Please sign in first!";
                return(RedirectToAction("Index", "Home"));
            }
            EditUserModel editUserModel = new EditUserModel();

            editUserModel.UserID        = userSession.UserID;
            editUserModel.UserDOB       = userSession.UserDOB;
            editUserModel.UserFirstName = userSession.UserFirstName;
            editUserModel.UserLastName  = userSession.UserLastName;
            editUserModel.Phone         = userSession.Phone;
            editUserModel.Place         = userSession.Place;
            editUserModel.IDCard        = userSession.IDCard;
            return(PartialView(editUserModel));
        }
Beispiel #19
0
        public JsonResult DisLike(long eventId)
        {
            User    user    = UserHelpers.GetCurrentUser(Session);
            Boolean success = false;
            int     state   = EventZoneConstants.NotRate;

            if (user != null)
            {
                LikeDislike findlike = UserDatabaseHelper.Instance.FindLike(user.UserID, eventId);
                if (findlike != null)
                {
                    state = findlike.Type;
                }
                success = UserDatabaseHelper.Instance.InsertDislike(user.UserID, eventId);
            }
            return(Json(new
            {
                success = success,
                state = state
            }));
        }
Beispiel #20
0
        public ActionResult CategorySearch(long categoryid, long tab = -1)
        {
            User user = UserHelpers.GetCurrentUser(Session);

            if (user == null)
            {
                if (Request.Cookies["userName"] != null && Request.Cookies["password"] != null)
                {
                    string userName = Request.Cookies["userName"].Value;
                    string password = Request.Cookies["password"].Value;
                    if (UserDatabaseHelper.Instance.ValidateUser(userName, password))
                    {
                        user = UserDatabaseHelper.Instance.GetUserByUserName(userName);
                        if (UserDatabaseHelper.Instance.isLookedUser(user.UserName))
                        {
                            TempData["errorTitle"]   = "Locked User";
                            TempData["errorMessage"] = "Your account is locked! Please contact with our support";

                            return(RedirectToAction("Index", "Home"));
                        }
                        UserHelpers.SetCurrentUser(Session, user);
                    }
                }
            }
            List <Event> listEvent = new List <Event>();
            List <Event> liveEvent = new List <Event>();

            listEvent = EventDatabaseHelper.Instance.SearchEventByCategoryID(categoryid);
            liveEvent = EventDatabaseHelper.Instance.GetLiveEventByListEvent(listEvent);
            try
            {
                TempData["task"] = "Category " + CommonDataHelpers.Instance.GetCategoryById(categoryid).CategoryName;
            }
            catch { }
            TempData["TabSearch"]     = tab;
            Session["listLiveStream"] = EventDatabaseHelper.Instance.GetThumbEventListByListEvent(liveEvent);
            Session["listEvent"]      = EventDatabaseHelper.Instance.GetThumbEventListByListEvent(listEvent);
            return(View("SearchResult"));
        }
Beispiel #21
0
        public JsonResult FollowEvent(long eventId)
        {
            User    user        = UserHelpers.GetCurrentUser(Session);
            Boolean success     = false;
            int     followState = 0;// trang thai khong follow

            if (user != null)
            {
                success = UserDatabaseHelper.Instance.FollowEvent(user.UserID, eventId);
                if (UserDatabaseHelper.Instance.IsFollowingEvent(user.UserID, eventId))
                {
                    //trang thai tu unfollow sang follow
                    followState = 1;
                }
            }
            return(Json(new
            {
                success = success,
                state = followState
            }
                        ));
        }
        public JsonResult Dislike(int postId)
        {
            User    user    = UserHelpers.GetCurrentUser(Session);
            Boolean success = false;

            if (user != null)
            {
                int dislike = GraphDatabaseHelpers.Instance.FindDislike(user.UserId, postId);
                if (dislike == 0)
                {
                    // user dislike post and delete exist like
                    success = GraphDatabaseHelpers.Instance.InsertDislike(user.UserId, postId);
                    GraphDatabaseHelpers.Instance.DeleteLike(user.UserId, postId);
                }
                else
                {
                    // delete exist dislike
                    GraphDatabaseHelpers.Instance.DeleteDislike(user.UserId, postId);
                }
            }
            return(Json(success));
        }
Beispiel #23
0
        public JsonResult FollowCategory(long categoryId)
        {
            User    user        = UserHelpers.GetCurrentUser(Session);
            Boolean success     = false;
            int     followState = 0;

            if (user != null)
            {
                success = UserDatabaseHelper.Instance.FollowCategory(user.UserID, categoryId);
                if (UserDatabaseHelper.Instance.IsFollowingCategory(user.UserID, categoryId))
                {
                    followState = 1;
                }
            }
            return(Json(new
            {
                success = success,
                state = followState
            }

                        ));
        }
Beispiel #24
0
        public ActionResult PagingReportManage(int page, string keyword = "")
        {
            User         user = UserHelpers.GetCurrentUser(Session);
            List <Event> listEventHasReports = UserDatabaseHelper.Instance.GetAllEventHasReports(user.UserID);

            if (!string.IsNullOrEmpty(keyword))
            {
                listEventHasReports = listEventHasReports.FindAll(model => CommonDataHelpers.Instance.MatchKeyWord(keyword, model));
            }
            int startIndex = (page - 1) * 10;
            int endIndex   = (listEventHasReports.Count) < (page * 10) ? (listEventHasReports.Count - 1) : (page * 10) - 1;

            if (startIndex > endIndex)
            {
                return(null);
            }
            if (listEventHasReports == null)
            {
                TempData["LoadMore"] = false;
                return(PartialView("_ViewReport", null));
            }
            if (listEventHasReports.Count > (page * 10))
            {
                TempData["LoadMore"] = true;
            }
            else
            {
                TempData["LoadMore"] = false;
            }
            List <Event> listView = new List <Event>();

            for (int i = startIndex; i < endIndex + 1; i++)
            {
                listView.Add(listEventHasReports[i]);
            }

            return(PartialView("_ViewReport", listView));
        }
        //
        // GET: /User/
        public ActionResult Index(int id = 0)
        {
            User        userSession = UserHelpers.GetCurrentUser(Session);
            User        user;
            List <Post> listPost;
            List <User> friend;

            if (userSession == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            if (userSession.UserId == id || id == 0)
            {
                user     = userSession;
                listPost = GraphDatabaseHelpers.Instance.FindPostOfUser(userSession);
                friend   = GraphDatabaseHelpers.Instance.FindFriend(userSession);

                FindRelatedInformationPost(listPost);
            }
            else
            {
                user = GraphDatabaseHelpers.Instance.FindUser(id);
                if (user == null)
                {
                    return(RedirectToAction("Index", "Home"));
                }
                listPost = GraphDatabaseHelpers.Instance.FindPostOfOtherUser(userSession, user);
                friend   = GraphDatabaseHelpers.Instance.FindFriend(user);

                FindRelatedInformationPost(listPost);
            }

            ViewData["userSession"] = userSession;
            ViewData["friend"]      = friend;
            ViewData["isFriend"]    = GraphDatabaseHelpers.Instance.GetFriendType(userSession.UserId, user.UserId);
            return(View(user));
        }
Beispiel #26
0
        /// <summary>
        /// return new event to new event column Home page
        /// </summary>
        /// <returns></returns>
        public ActionResult NewEvent()
        {
            List <ThumbEventHomePage> listThumb = new List <ThumbEventHomePage>();
            List <Event> listEvent = new List <Event>();

            listEvent = EventDatabaseHelper.Instance.GetListNewEvent();
            listEvent = EventDatabaseHelper.Instance.RemoveLockedEventInList(listEvent);
            User user = UserHelpers.GetCurrentUser(Session);

            if (user == null)
            {
                if (Request.Cookies["userName"] != null && Request.Cookies["password"] != null)
                {
                    string userName = Request.Cookies["userName"].Value;
                    string password = Request.Cookies["password"].Value;
                    if (UserDatabaseHelper.Instance.ValidateUser(userName, password))
                    {
                        user = UserDatabaseHelper.Instance.GetUserByUserName(userName);
                        if (UserDatabaseHelper.Instance.isLookedUser(user.UserName))
                        {
                            TempData["errorTitle"]   = "Locked User";
                            TempData["errorMessage"] = "Your account is locked! Please contact with our support";
                            listThumb = EventDatabaseHelper.Instance.GetThumbEventHomepage(listEvent);
                            return(RedirectToAction("Index", "Home"));
                        }
                        UserHelpers.SetCurrentUser(Session, user);
                    }
                }
            }
            if (user != null)
            {
                listEvent = EventDatabaseHelper.Instance.GetListNewEventByUser(user.UserID);
            }
            listThumb = EventDatabaseHelper.Instance.GetThumbEventHomepage(listEvent).Take(5).ToList();
            TempData["errorTitle"]   = TempData["errorTitle"];
            TempData["errorMessage"] = TempData["errorMessage"];
            return(PartialView("_ThumbEventHomepage", listThumb));
        }
Beispiel #27
0
        public JsonResult UnFollowUser(long userID)
        {
            User user = UserHelpers.GetCurrentUser(Session);

            if (user != null)
            {
                if (UserDatabaseHelper.Instance.UnFollowPeople(user.UserID, userID))
                {
                    return(Json(new
                    {
                        state = 1,
                        userID = userID
                    }));
                }
                ;
            }
            return(Json(new
            {
                state = 0,
                error = "Error",
                message = "Something wrong! Please reload page and try again!"
            }));
        }
        //
        // GET: /Room/
        public ActionResult Index(string startplace, string targetplace, string startdate, string returndate, int?slotOption, int id = -1)
        {
            User user = UserHelpers.GetCurrentUser(Session);

            if (user == null)
            {
                RedirectToAction("Index", "Home");
            }
            List <Room> listRoom;
            List <User> listAdminRoom = new List <User>();

            if (id == -1)
            {
                // Search all room.
                listRoom = GraphDatabaseHelpers.Instance.SearchRoomByKeyword();

                FilterByStartPlace(ref listRoom, startplace);
                FilterByTargetPlace(ref listRoom, targetplace);
                FilterByStartDate(ref listRoom, startdate);
                FilterByReturnDate(ref listRoom, returndate);
                FilterBySlot(ref listRoom, slotOption);

                listAdminRoom.AddRange(listRoom.Select(room => GraphDatabaseHelpers.Instance.FindAdminInRoom(room.RoomId)));
            }
            else
            {
                listRoom = GraphDatabaseHelpers.Instance.SearchRoomByUserId(user.UserId);   // search room of current User
                for (int i = 0; i < listRoom.Count; i++)
                {
                    listAdminRoom.Add(user);
                }
            }

            ViewData["listRoom"]      = listRoom;
            ViewData["listAdminRoom"] = listAdminRoom;
            return(View());
        }
        public async Task <ActionResult> CreateEvent(CreateEventModel model, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                List <Location> locationList = model.Location;
                locationList.RemoveAll(o => o.LocationName.Equals("Remove Location"));
                //add location to database
                var listLocation = LocationHelpers.Instance.AddNewLocation(locationList);

                //Adding new event with given infomation to database
                var newEvent = EventDatabaseHelper.Instance.AddNewEvent(model, file, UserHelpers.GetCurrentUser(Session).UserID);

                //Add event place to database
                var listEventPlaces = EventDatabaseHelper.Instance.AddEventPlace(listLocation, newEvent);

                NotificationDataHelpers.Instance.SendNotifyNewEventToFollower(UserHelpers.GetCurrentUser(Session).UserID, newEvent.EventID);
                return(RedirectToAction("Details", "Event", new{ id = newEvent.EventID }));
            }
            // If we got this far, something failed, redisplay form
            ViewBag.CategoryID       = new SelectList(db.Categories, "CategoryId", "CategoryName");
            TempData["errorTitle"]   = "Error";
            TempData["errorMessage"] = "Please select location from suggestion!";
            return(View("Create", model));
        }
Beispiel #30
0
        public ActionResult ViewProfile()
        {
            //Show view profile
            if (UserHelpers.GetCurrentUser(Session) == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            // userId = UserHelpers.GetCurrentUser(Session).Id.ToString();
            User user = UserContext.GetUser(UserHelpers.GetCurrentUser(Session).Id);

            if (user == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            UserProfileView model = new UserProfileView();

            model.Id           = user.Id;
            model.avatarURL    = user.avatarURL;
            model.dateOfBirdth = string.Empty;
            model.username     = user.username;
            model.address      = user.address;
            model.fullName     = user.firstName + " " + user.middleName + " " + user.lastName;
            return(View(model));
        }