Esempio n. 1
0
 public ActionResult DeleteConfirmed(int id)
 {
     SessionSet set = db.SessionSets.Find(id);
     db.SessionSets.Remove(set);
     db.SaveChanges();
     return RedirectToAction("Index");
 }
Esempio n. 2
0
        public ActionResult Login(User user)
        {
            var email  = user.Email;
            var pass   = user.Password;
            var result = _br.Query <User>().Where(k => (k.Email.Equals(email)) && (k.Password.Equals(pass))).Any();

            if (result)
            {
                var  myuser = _br.Query <User>().Where(k => (k.Email.Equals(email)) && (k.Password.Equals(pass))).FirstOrDefault();
                User _temp  = new User()
                {
                    ID          = myuser.ID,
                    Name        = myuser.Name,
                    Email       = myuser.Email,
                    Password    = myuser.Password,
                    CreatedDate = myuser.CreatedDate
                };
                SessionSet <User> .Set(_temp, "Login");

                return(RedirectToAction("Home", "Home"));
            }
            else
            {
                string msg = "<script language=\"javascript\">";
                msg += "alert('" + "The username and password you entered did not match our records. Please double-check and try again." + "');";
                msg += "</script>";
                Response.Write(msg);
                return(RedirectToAction("Start", "Home"));
            }
        }
Esempio n. 3
0
        public ActionResult CommentList(int id)
        {
            var _user = SessionSet <User> .Get("login");

            var friend = loginRepo.Query <Tweet>().FirstOrDefault(k => k.Id == id);
            // Tweet tweet = new Tweet();
            List <TweetDto> list = new List <TweetDto>();

            list.Clear();
            if (_user != null)
            {
                var mymodel = (from t in loginRepo.Query <Comment>()

                               where (t.ParentId == friend.Id) && t.IsDeleted == false
                               select new TweetDto()
                {
                    Id = t.Id,
                    Body = t.Body,
                    UserName = t.User.UserName
                }).ToList();
                mymodel.Reverse();
                foreach (TweetDto model in mymodel)
                {
                    list.Add(model);
                }

                //list = mymodel.OrderByDescending(x => x.CreateDate).ToList();


                return(View(list));
            }
            return(View());
        }
Esempio n. 4
0
        public ActionResult ReTweet(int id)
        {
            var user = SessionSet <User> .Get("Login").ID;

            Tweet tweet  = _br.Query <Tweet>().Where(k => k.ID == id).FirstOrDefault();
            var   rtList = _db.Retweets.ToList();
            var   result = _br.Query <Retweet>().Where(k => k.TweetID == id && k.UserID == user).Any();

            if (!result)
            {
                Retweet rt = new Retweet()
                {
                    UserID      = user,
                    TweetID     = id,
                    CreatedDate = DateTime.Now
                };
                _db.Retweets.Add(rt);
                _db.SaveChanges();
            }
            else
            {
                var retwDel = rtList.Where(k => k.TweetID == id && k.UserID == user).FirstOrDefault();
                _db.Retweets.Remove(retwDel);
                _db.SaveChanges();
            }



            return(RedirectToAction("Home", "Home"));
        }
Esempio n. 5
0
        public ActionResult PostLike(int id)
        {
            var user = SessionSet <User> .Get("Login");

            var postUserID = _br.Query <Post>().Where(k => k.ID == id).FirstOrDefault().UserID;

            if (!_brLike.Query <Like>().Where(k => k.PostID == id && k.LikeUserID == user.ID).Any())
            {
                Like addLike = new Like()
                {
                    LikeUserID = user.ID,
                    PostID     = id
                };
                _brLike.AddModel(addLike);
                Notification notify = new Notification()
                {
                    UserID      = user.ID,
                    ActionID    = 2,
                    PostUserID  = postUserID,
                    IsShow      = true,
                    NotifyText  = user.Name + " liked your post.",
                    CreatedDate = DateTime.Now
                };
                _db.Notifications.Add(notify);
                _db.SaveChanges();
            }
            else
            {
                var delLike = _brLike.Query <Like>().Where(k => k.PostID == id && k.LikeUserID == user.ID).FirstOrDefault();
                _db.Entry(delLike).State = EntityState.Deleted;
                _db.SaveChanges();
            }

            return(RedirectToAction("Home", "Home"));
        }
Esempio n. 6
0
        // GET: Profile
        public ActionResult Index()
        {
            var _user = SessionSet <User> .Get("login");

            if (_user != null)
            {
                using (BaseRepository <Submit> _repo = new BaseRepository <Submit>())
                {
                    var mymodel = (from u in _repo.Query <User>()
                                   join
                                   t in _repo.Query <Submit>() on u.Id equals t.UserId
                                   where u.Id == _user.Id && t.IsDeleted == false
                                   orderby t.CreateDate descending
                                   select new SubmitDto()
                    {
                        Id = t.Id,
                        Body = t.Body,
                        UserName = u.UserName,
                    }).Distinct().ToList();
                    mymodel.Reverse();
                    return(View(mymodel));
                }
            }
            else
            {
                return(RedirectToAction("StartPage", "Home"));
            }
        }
Esempio n. 7
0
        public ActionResult Login(User user)
        {
            var userName = user.UserName;
            var pass     = user.Password;

            bool result = _br.Query <User>().Where(k => (k.UserName.Equals(userName)) && (k.Password.Equals(pass))).Any();

            if (result)
            {
                IQueryable <User> users = _br.Query <User>().Where(k => (k.UserName.Equals(userName)) && (k.Password.Equals(pass)));
                var  myUser             = users.FirstOrDefault();
                User _temp = new User();
                _temp.ID           = myUser.ID;
                _temp.NameLastname = myUser.NameLastname;
                _temp.UserName     = myUser.UserName;
                _temp.Email        = myUser.Email;
                _temp.Password     = myUser.Password;
                SessionSet <User> .Set(_temp, "Login");

                return(RedirectToAction("Home", "Home"));
            }
            else
            {
                ModelState.AddModelError("", "The username and password you entered did not match our records. Please double-check and try again.");
                return(RedirectToAction("Starting", "Home"));
            }
        }
Esempio n. 8
0
        public void Configuration(IAppBuilder appBuilder)
        {
            // Регистрируем и конфигурируем SignalR
            appBuilder.Map("/signalr", map => {
                map.UseCors(CorsOptions.AllowAll);
                map.MapSignalR();
            });

            HttpConfiguration selfHostConfig = new HttpConfiguration();

            selfHostConfig.Routes.MapHttpRoute(name: "DefaultApiRoute", routeTemplate: "api/{controller}", defaults: null);
            //selfHostConfig.Routes.MapHttpRoute(name: "DefaultApiWithId", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional });
            selfHostConfig.Routes.MapHttpRoute(name: "DefaultApiWithAction", routeTemplate: "api/{controller}/{action}/{id}", defaults: new { id = RouteParameter.Optional });

            var config = SelfHostConfigRetriever.GetHostConfig();

            if (config.GetElementByName("authentication").Value == "yes")
            {
                HttpListener listener = (HttpListener)appBuilder.Properties["System.Net.HttpListener"];
                listener.AuthenticationSchemes = AuthenticationSchemes.IntegratedWindowsAuthentication;
            }

            selfHostConfig.MessageHandlers.Add(new MessageLoggingHandler());
            selfHostConfig.Services.Add(typeof(IExceptionLogger), new TraceExceptionLogger());

            SessionSet.Create(Settings.Default.msSessionLifiTime);

            WebApiSync.Create(Settings.Default.WebApiSyncUrls, "" /*/Settings.Default.CertificateToZoneThumbprint/*/, Settings.Default.msPingZoneInterval,
                              Settings.Default.PingRequestsCount, Settings.Default.NoPingNotifyInterval.TotalMilliseconds);
            appBuilder.UseWebApi(selfHostConfig);
        }
Esempio n. 9
0
        public ActionResult ConnectWithYourself()
        {
            var _user = SessionSet <User> .Get("login");

            int FriendId = SessionSet <User> .Get("login").Id;

            int myId = _user.Id;

            UserFriends uf0 = new UserFriends();

            uf0.UserId     = myId;
            uf0.FriendId   = FriendId;
            uf0.CreateDate = DateTime.Now;

            var result = postRepo.Query <UserFriends>().Where(k => (k.UserId == uf0.UserId) && (k.FriendId == uf0.FriendId)).FirstOrDefault();

            if (result == null)
            {
                db.UserFriends.Add(uf0);
                db.SaveChanges();
            }


            return(RedirectToAction("Index", "Home"));
        }
Esempio n. 10
0
        public ActionResult AddFriend(int id)
        {
            var user = SessionSet <User> .Get("Login");

            RelationShip rs = new RelationShip()
            {
                User1ID      = user.ID,
                User2ID      = id,
                CreatedDate  = DateTime.Now,
                ActionUserID = user.ID,
                StatusID     = 1
            };

            _br.AddModel(rs);
            Notification notify = new Notification()
            {
                UserID      = user.ID,
                ActionID    = 1,
                PostUserID  = id,
                IsShow      = true,
                NotifyText  = user.Name + " wants to add you as a friend.",
                CreatedDate = DateTime.Now
            };

            _db.Notifications.Add(notify);
            _db.SaveChanges();

            return(RedirectToAction("Home", "Home"));
        }
Esempio n. 11
0
        public ActionResult Index()
        {
            var _user = SessionSet <User> .Get("login");

            List <TweetDto> list = new List <TweetDto>();

            list.Clear();
            if (_user != null)
            {
                var mymodel = (from uf in _repo.Query <UserFriends>()
                               join
                               t in _repo.Query <Tweet>() on uf.FriendId equals t.UserId
                               where (uf.UserId == _user.Id ||
                                      t.UserId == _user.Id) && t.IsDeleted == false
                               select new TweetDto()
                {
                    Id = t.Id,
                    Body = t.Body,
                    UserName = uf.Friend.UserName
                }).Distinct().ToList();               //liste halinde commentlist ini görüntüle!
                foreach (TweetDto model in mymodel)
                {
                    list.Add(model);
                }

                list = mymodel.OrderByDescending(x => x.CreateDate).ToList();


                return(View(list));
            }
            else
            {
                return(RedirectToAction("Login", "Login"));
            }
        }
Esempio n. 12
0
        public ActionResult Search(string username)
        {
            var _user = SessionSet <User> .Get("login");

            var user_name = loginRepo.Query <Tweet>().FirstOrDefault(k => k.UserName == username).UserName;

            List <TweetDto> list = new List <TweetDto>();

            list.Clear();
            if (_user != null)
            {
                var mymodel = (from t in loginRepo.Query <Tweet>()

                               where (t.UserName == user_name) && t.IsDeleted == false
                               select new TweetDto()
                {
                    Id = t.Id,
                    Body = t.Body,
                    UserName = t.UserName
                }).Distinct().ToList();               //liste halinde commentlist ini görüntüle!
                foreach (TweetDto model in mymodel)
                {
                    list.Add(model);
                }

                list = mymodel.OrderByDescending(x => x.CreateDate).ToList();


                return(View(list));
            }
            else
            {
                return(RedirectToAction("Login", "Login"));
            }
        }
Esempio n. 13
0
        //BaseRepository<Like> _repo = new BaseRepository<Like>();

        public ActionResult Index()
        {
            var _user = SessionSet <User> .Get("login");

            if (_user != null)
            {
                using (BaseRepository <Post> _repo = new BaseRepository <Post>())
                {
                    var mymodel = (from u in _repo.Query <User>()
                                   join
                                   p in _repo.Query <Post>() on u.Id equals p.UserId
                                   where (u.Id == _user.Id) && p.IsDeleted == false
                                   orderby p.CreateDate descending
                                   select new PostDto()
                    {
                        Id = p.Id,
                        Body = p.Body,
                        UserName = u.UserName,
                    }).Distinct().ToList();
                    mymodel.Reverse();
                    return(View(mymodel));
                }
            }
            else
            {
                return(RedirectToAction("Login", "Login"));
            }
        }
Esempio n. 14
0
        public ActionResult SubmitList(int id)
        {
            var _user = SessionSet <User> .Get("login");

            var friend = _repo.Query <Submit>().FirstOrDefault(k => k.Id == id);

            List <SubmitDto> list = new List <SubmitDto>();

            list.Clear();
            if (_user != null)
            {
                var mymodel = (from t in _repo.Query <Comment>()

                               where (t.ParentId == friend.Id) && t.IsDeleted == false
                               select new SubmitDto()
                {
                    Id = t.Id,
                    Body = t.Body,
                    UserName = t.User.UserName
                }).ToList();
                mymodel.Reverse();
                foreach (SubmitDto model in mymodel)
                {
                    list.Add(model);
                }



                return(View(list));
            }
            return(View());
        }
Esempio n. 15
0
        public ActionResult Login(User model)
        {
            BaseRepository <User> _repo = new BaseRepository <User>();

            var repo = _repo.Query <User>().Where(x => x.Email == model.Email && x.Password == model.Password).ToList();

            if (repo.Count > 0)
            {
                User _temp = new User();
                foreach (var item in repo)
                {
                    _temp.UserName = item.UserName;
                    _temp.Email    = item.Email;
                    _temp.Id       = item.Id;
                    //_temp.LastName = item.LastName;
                    //_temp.Dis = item.Dis;
                }

                SessionSet <User> .Set(_temp, "login");

                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                ModelState.AddModelError("", "Hatalı Giriş Yaptınız");
                return(View());
            }
        }
Esempio n. 16
0
        public ActionResult GetPost()
        {
            var userID = SessionSet <User> .Get("Login").ID;

            List <PostDto> postList  = new List <PostDto>();
            var            FriendsID = _br.Query <RelationShip>().Where(k => (k.User1ID == userID || k.User2ID == userID) && k.StatusID == 2).ToList();
            List <User>    myFriends = new List <User>();

            foreach (var item in FriendsID)
            {
                User friends = new User();;
                if (item.User1ID == userID)
                {
                    friends = _br.Query <User>().Where(k => k.ID == item.User2ID).FirstOrDefault();
                }
                else
                {
                    friends = _br.Query <User>().Where(k => k.ID == item.User1ID).FirstOrDefault();
                }

                myFriends.Add(friends);
            }

            foreach (var item in myFriends)
            {
                var FriendPostList = _br.Query <Post>().Where(k => k.UserID == item.ID).ToList();
                foreach (var item2 in FriendPostList)
                {
                    PostDto post = new PostDto()
                    {
                        ID          = item2.ID,
                        PostText    = item2.PostText,
                        CreatedDate = item2.CreatedDate,
                        UserName    = item.Name,
                        UserID      = item.ID
                    };
                    postList.Add(post);
                }
            }

            var UserPostList = _br.Query <Post>().Where(k => k.UserID == userID).ToList();

            foreach (var item in UserPostList)
            {
                var     user = _br.Query <User>().Where(k => k.ID == userID).FirstOrDefault();
                PostDto post = new PostDto()
                {
                    ID          = item.ID,
                    PostText    = item.PostText,
                    CreatedDate = item.CreatedDate,
                    UserName    = user.Name,
                    UserID      = userID
                };
                postList.Add(post);
            }
            var orderList = postList.OrderByDescending(k => k.CreatedDate).ToList();

            return(View(orderList));
        }
Esempio n. 17
0
        public ActionResult AddPost(int id, string text)
        {
            //Wall wall = wallService.GetBy(x => x.UserId == id);

            //wall.Message = text;
            //wall.DateEdited = DateTime.Now;


            //wallService.Update(wall);
            var deleteuser = SessionSet <Users> .CurrentUser("login");

            Post po = new Post();

            po.Text      = text;
            po.UserId    = id;
            po.LikeCount = 0;
            po.IsDeleted = false;

            postservice.Add(po);

            List <PostListViewModel> postlist = (from use in userService.Query <Users>()
                                                 join pos in userService.Query <Post>() on use.Id equals pos.UserId
                                                 where use.Id == deleteuser.Id
                                                 select new PostListViewModel
            {
                username = use.Username,
                Text = pos.Text,
                LikeCount = pos.LikeCount,
                UserId = use.Id,
                CreatedDate = pos.CreatedDate,
                postId = pos.Id
            }).ToList();


            //List<PostListViewModel> postlist2 = postservice.GetAll(x => allfriendsIds.Contains(x.UserId)).Select(x => new PostListViewModel(x)).ToList();


            var postlist2 = (from uf in userFriendService.Query <UserFriend>()
                             join p in userFriendService.Query <Post>() on uf.FriendId equals p.UserId
                             join use in userFriendService.Query <Users>() on p.UserId equals use.Id
                             where uf.UserId == deleteuser.Id && uf.Active == true
                             select new PostListViewModel
            {
                Text = p.Text,
                CreatedDate = p.CreatedDate,
                username = use.Username,
                LikeCount = p.LikeCount,
                UserId = use.Id,
                postId = p.Id
            }).ToList();;


            List <PostListViewModel> wallList = postlist.Concat(postlist2).OrderByDescending(x => x.CreatedDate).ToList();



            return(PartialView("_AddPartial", wallList));
        }
Esempio n. 18
0
        public ActionResult TweetID(int id)//click tweet
        {
            Comment com = new Comment();

            com.tweetID = id;
            SessionSet <Comment> .Set(com, "get");

            return(View());
        }
Esempio n. 19
0
        public ActionResult TweetId(int id)
        {
            Comment com = new Comment();

            com.Id = id;
            SessionSet <Comment> .Set(com, "get");

            return(View());
        }
Esempio n. 20
0
        public ActionResult AddTweet(Tweet newTweet)
        {
            newTweet.UserId = SessionSet <User> .Get("login").Id;

            newTweet.ParentId = 0;

            loginRepo.Add(newTweet);
            return(RedirectToAction("Index", "Home"));
        }
Esempio n. 21
0
        public ActionResult AddPost(Post newPost)
        {
            newPost.UserId = SessionSet <User> .Get("login").Id;

            newPost.ParentId = 0;

            postRepo.Add(newPost);
            return(RedirectToAction("Index", "Home"));
        }
Esempio n. 22
0
        public void DeclineFrinedRequest(int friendid)
        {
            Users user = SessionSet <Users> .CurrentUser("login");


            UserFriend users  = userFriendService.GetBy(x => x.FriendId == user.Id && x.UserId == friendid && x.Active == false);
            int        userid = users.Id;

            userFriendService.Delete(userid);
        }
Esempio n. 23
0
        public ActionResult RemoveFriend(int id)
        {
            var userID = SessionSet <User> .Get("Login").ID;

            var remove = _br.Query <RelationShip>().Where(k => (k.User1ID == id && k.User2ID == userID) || (k.User1ID == userID && k.User2ID == id) && k.StatusID == 2).FirstOrDefault();

            _db.Entry(remove).State = EntityState.Deleted;
            _db.SaveChanges();
            return(RedirectToAction("GetFriendns"));
        }
Esempio n. 24
0
        public ActionResult Delete(int id)
        {
            var userID = SessionSet <User> .Get("Login").ID;

            var confirm = _br.Query <RelationShip>().Where(k => k.User1ID == id && k.User2ID == userID && k.StatusID == 1).FirstOrDefault();

            _db.Entry(confirm).State = EntityState.Deleted;
            _db.SaveChanges();
            return(RedirectToAction("Home", "Home"));
        }
Esempio n. 25
0
        public ActionResult AddPost(Post post)
        {
            var userID = SessionSet <User> .Get("Login").ID;

            post.CreatedDate = DateTime.Now;
            post.UserID      = userID;
            _br.AddModel(post);

            return(RedirectToAction("Home", "Home"));
        }
Esempio n. 26
0
        public ActionResult AddTweet(Tweet tweet)
        {
            var user = SessionSet <User> .Get("Login");

            tweet.UserID      = user.ID;
            tweet.ParentID    = 0;
            tweet.CreatedDate = DateTime.Now;
            _br.AddModel(tweet);
            return(RedirectToAction("Home", "Home"));
        }
Esempio n. 27
0
        public ActionResult AddSubmit(Submit newSubmit)
        {
            newSubmit.UserId = SessionSet <User> .Get("login").Id;

            newSubmit.UserName = SessionSet <User> .Get("login").UserName;

            newSubmit.ParentId = 0;

            loginRepo.Add(newSubmit);
            return(RedirectToAction("Index", "Home"));
        }
Esempio n. 28
0
 public ActionResult Edit([Bind(Include = "SessionId,SetNumber,ExerciseID,Reps,RPE,Load,Commentary,PersonalRecord")] SessionSet set)
 {
     if (ModelState.IsValid)
     {
         db.Entry(set).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.ExerciseID = new SelectList(db.Exercises, "ExerciseID", "Name", set.ExerciseID);
     ViewBag.SessionId = new SelectList(db.Sessions, "SessionId", "Commentary", set.SessionId);
     return View(set);
 }
Esempio n. 29
0
 // GET: Sets/Details/5
 public ActionResult Details(int? id)
 {
     if (id == null)
     {
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     }
     SessionSet set = db.SessionSets.Find(id);
     if (set == null)
     {
         return HttpNotFound();
     }
     return View(set);
 }
Esempio n. 30
0
        public ActionResult Home()
        {
            var userID = SessionSet <User> .Get("Login").ID;

            if (userID != null)
            {
                return(View());
            }
            else
            {
                return(RedirectToAction("Start", "Home"));
            }
        }