public ActionResult ProfilPicture(int userId, HttpPostedFileBase pic) { if (Session["UserName"] == null) { return(RedirectToAction("Error")); } if (pic != null && pic.ContentLength > 0) { var fileName = Path.GetFileName(pic.FileName); List <string> imgExtension = new List <string>(new string[] { ".gif", ".png", ".PNG", ".jpg", ".jpeg", ".bmp", ".tiff" }); string extension = Path.GetExtension(fileName); if (imgExtension.Contains(extension)) { var path = Path.Combine(Server.MapPath("~/Content/images/profil"), userId.ToString() + fileName); if (!System.IO.File.Exists(fileName)) { pic.SaveAs(path); } string profilPicUrl = "~/Content/images/profil/" + userId.ToString() + Path.GetFileName(pic.FileName); Session["UserPic"] = profilPicUrl; KoombuBll kBll = new KoombuBll(); kBll.AddProfilPic(userId, profilPicUrl); } } return(RedirectToAction("Profil", new { id = userId })); }
public ActionResult CreateAccount(string firstName, string lastName, string email, DateTime bday, string password, string confirmPassword, string department, string title) { if (password != confirmPassword) { ViewData["PassError"] = "true"; return(View("Index")); } KoombuBll kBll = new KoombuBll(); if (kBll.CheckEmail(email)) { ViewData["EmailExist"] = "true"; return(View("Index")); } var user = kBll.RegisterUser(firstName, lastName, email, bday, password, department, title); Session["UserName"] = user.FirstName + " " + user.LastName; Session["UserId"] = user.UserId; if (user.ProfilPicture != null) { Session["UserPic"] = user.ProfilPicture; } else { Session["UserPic"] = "~/Content/images/user.png"; } return(RedirectToAction("Home")); }
public ActionResult EditGroupUsers(int groupId) { if (Session["UserName"] == null) { return(RedirectToAction("Error")); } int userId = Int32.Parse(Session["UserId"].ToString()); KoombuBll kBll = new KoombuBll(); var group = kBll.GetGroup(groupId); GroupUsersVm groupUsersVm = new GroupUsersVm(); if (group.GroupOwnerId == userId) { groupUsersVm.AllUsers = kBll.GetAllUsers(); groupUsersVm.Group = group; groupUsersVm.GroupMembersObjects = kBll.GroupMembersObjects(groupId); groupUsersVm.GroupMembersId = kBll.GetGroupMembersId(groupUsersVm.GroupMembersObjects); } else { return(RedirectToAction("Groups")); } return(View(groupUsersVm)); }
public ActionResult Profil(int id) { if (Session["UserName"] == null) { return(RedirectToAction("Error")); } int connectedUserId = Int32.Parse(Session["UserId"].ToString()); KoombuBll kBll = new KoombuBll(); ProfilVm profilVm = new ProfilVm(); profilVm.User = kBll.GetUser(id); profilVm.FollowedUsersObjects = kBll.GetFollowedUsersObject(connectedUserId); if (id == connectedUserId) { ViewData["isConnect"] = "true"; } else { ViewData["isConnect"] = "false"; } return(View(profilVm)); }
public ActionResult RemoveSelf(int groupId) { int userId = Int32.Parse(Session["UserId"].ToString()); KoombuBll kBll = new KoombuBll(); kBll.RemoveUserFromGroup(userId, groupId); return(RedirectToAction("Groups")); }
public ActionResult DeleteUser(int groupId, int userId) { if (Session["UserName"] == null) { return(RedirectToAction("Error")); } KoombuBll kBll = new KoombuBll(); kBll.RemoveUserFromGroup(userId, groupId); return(RedirectToAction("EditGroupUsers", new { groupId = groupId })); }
public ActionResult FollowedUsers() { if (Session["UserName"] == null) { return(RedirectToAction("Error")); } int userId = Int32.Parse(Session["UserId"].ToString()); KoombuBll kBll = new KoombuBll(); var followedUsers = kBll.GetFollowedUsersObject(userId); return(View(followedUsers)); }
public ActionResult DeleteGroup(int groupId) { if (Session["UserName"] == null) { return(RedirectToAction("Error")); } int userId = Int32.Parse(Session["UserId"].ToString()); KoombuBll kBll = new KoombuBll(); kBll.DeleteGroup(groupId); return(RedirectToAction("Groups")); }
public ActionResult SearchPostGroup(string postString, int groupId) { int userConnectedId = Int32.Parse(Session["UserId"].ToString()); KoombuBll kBll = new KoombuBll(); var postList = kBll.SearchPost(postString, 0, groupId); GroupPostVm groupPostVm = new GroupPostVm { PostList = kBll.SetPostUserObject(postList), GroupMembersObjects = kBll.GroupMembersObjects(groupId), Group = kBll.GetGroup(groupId), UserConnected = kBll.GetUser(userConnectedId) }; return(View(groupPostVm)); }
public ActionResult Groups() { if (Session["UserName"] == null) { return(RedirectToAction("Error")); } int userId = Int32.Parse(Session["UserId"].ToString()); KoombuBll kBll = new KoombuBll(); GroupListVm groupListVm = new GroupListVm(); groupListVm.GroupList = kBll.GetAllGroupsForUser(userId); groupListVm.FollowedUsersObjects = kBll.GetFollowedUsersObject(userId); groupListVm.UserConnected = kBll.GetUser(userId); return(View(groupListVm)); }
public ActionResult SearchUser(string userName) { if (Session["UserName"] == null) { return(RedirectToAction("Error")); } int userConnectedId = Int32.Parse(Session["UserId"].ToString()); KoombuBll kBll = new KoombuBll(); UsersVm usersVm = new UsersVm(); usersVm.AllUsers = kBll.SearchUser(userName); usersVm.FollowedUsers = kBll.GetFollowedUserList(userConnectedId); usersVm.FollowedUsersObjects = kBll.GetFollowedUsersObject(userConnectedId); return(View("Users", usersVm)); }
public ActionResult RemoveComment(int commentId, int groupId) { if (Session["UserName"] == null) { return(RedirectToAction("Error")); } KoombuBll kBll = new KoombuBll(); kBll.RemoveComment(commentId); if (groupId != 0) { return(RedirectToAction("GroupWall", "Group", new { groupId = groupId })); } return(RedirectToAction("Home", "Home")); }
public ActionResult Comment(string commentContent, int postId, int groupId) { if (Session["UserName"] == null) { return(RedirectToAction("Error")); } int userId = Int32.Parse(Session["UserId"].ToString()); KoombuBll kBll = new KoombuBll(); kBll.CommentPost(commentContent, postId, userId); if (groupId != 0) { return(RedirectToAction("GroupWall", "Group", new { groupId = groupId })); } return(RedirectToAction("Home", "Home")); }
public ActionResult UnLike(int id, int groupId) { if (Session["UserName"] == null) { return(RedirectToAction("Error")); } int userId = Int32.Parse(Session["UserId"].ToString()); KoombuBll kBll = new KoombuBll(); kBll.UnlikePost(id, userId); if (groupId != 0) { return(RedirectToAction("GroupWall", "Group", new { groupId = groupId })); } return(RedirectToAction("Home", "Home")); }
public ActionResult Home() { if (Session["UserName"] == null) { return(RedirectToAction("Error")); } int userId = Int32.Parse(Session["UserId"].ToString()); KoombuBll kBll = new KoombuBll(); HomeVm homeVm = new HomeVm(); var postList = kBll.GetAllPostForUser(userId); homeVm.UserPostList = kBll.SetPostUserObject(postList); homeVm.UserConnected = kBll.GetUser(userId); homeVm.FollowedUsersObjects = kBll.GetFollowedUsersObject(userId); return(View(homeVm)); }
public ActionResult GroupWall(int groupId) { if (Session["UserName"] == null) { return(RedirectToAction("Error")); } int userId = Int32.Parse(Session["UserId"].ToString()); KoombuBll kBll = new KoombuBll(); GroupPostVm groupPostVm = new GroupPostVm(); groupPostVm.PostList = kBll.GetAllPostForGroup(groupId); groupPostVm.Group = kBll.GetGroup(groupId); groupPostVm.UserConnected = kBll.GetUser(userId); groupPostVm.GroupMembersObjects = kBll.GroupMembersObjects(groupId); return(View(groupPostVm)); }
public ActionResult UnFollowUser(int id) { if (Session["UserName"] == null) { return(RedirectToAction("Error")); } int userId = Int32.Parse(Session["UserId"].ToString()); if (id != userId) { KoombuBll kBll = new KoombuBll(); kBll.UnFollowUser(userId, id); } return(RedirectToAction("Profil", new { id = id })); }
public ActionResult RemovePost(int postOwnerId, int postId, int groupId) { if (Session["UserName"] == null) { return(RedirectToAction("Error")); } int userConnectedId = Int32.Parse(Session["UserId"].ToString()); if (postOwnerId == userConnectedId) { KoombuBll kBll = new KoombuBll(); kBll.RemovePost(postId); } if (groupId != 0) { return(RedirectToAction("GroupWall", "Group", new { groupId = groupId })); } return(RedirectToAction("Home", "Home")); }
public ActionResult MakeGroup(string groupName, string groupDescription, HttpPostedFileBase groupPicture) { if (Session["UserName"] == null) { return(RedirectToAction("Error")); } int groupOwnerId = Int32.Parse(Session["UserId"].ToString()); string groupImgUrl = null; if (groupPicture != null) { var fileName = Path.GetFileName(groupPicture.FileName); List <string> imgExtension = new List <string>(new string[] { ".gif", ".png", ".PNG", ".jpg", ".jpeg", ".bmp", ".tiff" }); string extension = Path.GetExtension(fileName); if (imgExtension.Contains(extension)) { var path = Path.Combine(Server.MapPath("~/Content/images/group"), groupOwnerId.ToString() + fileName); if (!System.IO.File.Exists(fileName)) { groupPicture.SaveAs(path); } groupImgUrl = "~/Content/images/group/" + groupOwnerId.ToString() + Path.GetFileName(groupPicture.FileName); } } KoombuBll kBll = new KoombuBll(); kBll.CreateGroup(groupOwnerId, groupName, groupDescription, groupImgUrl); return(RedirectToAction("Groups")); }
public ActionResult SignIn(string email, string password) { KoombuBll kBll = new KoombuBll(); var user = kBll.SignIn(email, password); if (user != null) { Session["UserName"] = user.FirstName + " " + user.LastName; Session["UserId"] = user.UserId; if (user.ProfilPicture != null) { Session["UserPic"] = user.ProfilPicture; } else { Session["UserPic"] = "~/Content/images/user.png"; } return(RedirectToAction("Home")); } ViewData["SignError"] = "true"; return(View("Index")); }
public ActionResult CreatePost(int groupId, string content, HttpPostedFileBase picture, HttpPostedFileBase attachement) { if (Session["UserName"] == null) { return(RedirectToAction("Error")); } if (content == "" && picture == null && attachement == null) { return(RedirectToAction("Home", "Home")); } else { int postOwnerId = Int32.Parse(Session["UserId"].ToString()); string postAttachementUrl = null; string pictureUrl = null; string attachementName = null; if (picture != null && picture.ContentLength > 0) { var fileName = Path.GetFileName(picture.FileName); List <string> imgExtension = new List <string>(new string[] { ".gif", ".png", ".PNG", ".jpg", ".jpeg", ".bmp", ".tiff" }); string extension = Path.GetExtension(fileName); if (imgExtension.Contains(extension)) { var path = Path.Combine(Server.MapPath("~/Content/post/images"), postOwnerId.ToString() + DateTime.Now.ToString("yyyyMMdd") + fileName); if (!System.IO.File.Exists(fileName)) { picture.SaveAs(path); } pictureUrl = "~/Content/post/images/" + postOwnerId.ToString() + DateTime.Now.ToString("yyyyMMdd") + Path.GetFileName(picture.FileName); } } if (attachement != null && attachement.ContentLength > 0) { attachementName = Path.GetFileName(attachement.FileName); List <string> filesExtension = new List <string>(new string[] { ".txt", ".pdf", ".ppt", ".docx" }); string extension = Path.GetExtension(attachementName); if (filesExtension.Contains(extension)) { var path = Path.Combine(Server.MapPath("~/Content/post/attachement"), postOwnerId.ToString() + DateTime.Now.ToString("yyyyMMdd") + attachementName); if (!System.IO.File.Exists(attachementName)) { attachement.SaveAs(path); } postAttachementUrl = "~/Content/post/attachement/" + postOwnerId.ToString() + DateTime.Now.ToString("yyyyMMdd") + Path.GetFileName(attachement.FileName); } } KoombuBll kBll = new KoombuBll(); kBll.CreatePost(content, postOwnerId, groupId, pictureUrl, postAttachementUrl, attachementName); if (groupId != 0) { return(RedirectToAction("GroupWall", "Group", new { groupId = groupId })); } } return(RedirectToAction("Home", "Home")); }