public ActionResult Index(WhiteBoardModel WhiteBoards, IEnumerable <HttpPostedFileBase> Images, IEnumerable <HttpPostedFileBase> Files) { if (Session["UserId"] != null) { TempData["DeletedMessage"] = "your post successfully posted"; int UserId = Convert.ToInt32(Session["UserId"]); List <Batches> batches = new List <Batches>(); View_UserDetails Userdetails = UserDetailsViewService.GetUserByUserId(Convert.ToInt32(UserId)); switch (Convert.ToInt32(Userdetails.RoleId)) { case 1: batches.Add(new Batches { Batch = UtilitiesClass.BatchVisibleToAll, BatchName = UtilitiesClass.BatchVisibleToAll }); batches.Add(new Batches { Batch = Convert.ToString(Userdetails.Batch), BatchName = UtilitiesClass.BatchName }); break; case 2: batches.Add(new Batches { Batch = UtilitiesClass.BatchVisibleToAll, BatchName = UtilitiesClass.BatchVisibleToAll }); batches.Add(new Batches { Batch = Convert.ToString(Userdetails.Batch), BatchName = UtilitiesClass.BatchName }); break; } if (Userdetails.RoleId == "4") { } WhiteBoardModel WhiteBoard = new WhiteBoardModel() { Viewdetails = batches, RoleId = Userdetails.RoleId, Batch = Userdetails.Batch, Stream = Userdetails.CourseName, Events = EventCategoryService.GetCategorys() }; if (ModelState.IsValid) { int?EventId = null; if (WhiteBoards.EventId == null || WhiteBoards.EventId == 0) { EventId = 5; } else { EventId = WhiteBoards.EventId; } UserPost UserPosts = new UserPost() { EventId = EventId, UserId = UserId, UserMessage = WhiteBoards.Message, ViewBy = WhiteBoards.Batchyear, Status = true, CreatedOn = DateTime.Now }; int PostId = UserPostService.InsertUserPosts(UserPosts); string Batch = ""; Int64 BatchFrom = 0; Int64 BatchTo = 0; if (WhiteBoards.Batchyear == UtilitiesClass.BatchVisibleToAll) { Batch = UtilitiesClass.BatchVisibleToAll; } else { BatchFrom = Convert.ToInt64(WhiteBoards.Batchyear); BatchTo = Convert.ToInt64(WhiteBoards.Batchyear) - (Convert.ToInt64(Userdetails.Years)); } if (Batch == UtilitiesClass.BatchVisibleToAll) { UserPosts_Visisble UserPostVisible = new UserPosts_Visisble() { PostId = PostId, Batch = Batch, Branch = Userdetails.CourseCategoryName, Degreee = Userdetails.CourseId, CreatedOn = DateTime.Now, Status = true }; UserPostVisibleServices.Create(UserPostVisible); } else { UserPosts_Visisble UserPostVisible = new UserPosts_Visisble() { PostId = PostId, Batch = Convert.ToString(BatchTo), BatchTo = Convert.ToString(BatchFrom), Branch = Userdetails.CourseCategoryName, Degreee = Userdetails.CourseId, CreatedOn = DateTime.Now, Status = true }; UserPostVisibleServices.Create(UserPostVisible); } if (Images != null) { foreach (var Pictures in Images) { if (Pictures != null) { var fileName = Path.GetFileName(Pictures.FileName); var path = Path.Combine(Server.MapPath(UtilitiesClass.ImagePath + fileName)); Pictures.SaveAs(path); var FilePath = "/UserPostingImages/" + fileName; UserPost_Images UserImages = new UserPost_Images() { PostId = PostId, ImagePath = FilePath, CreatedOn = DateTime.Now, Status = true }; UserpostPictureServices.Create(UserImages); } } } return(RedirectToAction(AlumniWhiteBoard.Index, AlumniWhiteBoard.WhiteBoard, new { area = AreasforAlumni.Alumini })); } return(View(WhiteBoard)); } return(RedirectToAction(LoginPages.Login, LoginPages.Account, new { area = "" })); }
public ActionResult Index(WhiteBoardModel WhiteBoards, IEnumerable <HttpPostedFileBase> Images, IEnumerable <HttpPostedFileBase> Files) { var defaultPageSize = 5; int? Page = 1; List <Batches> Batches = new List <Batches>(); if (Session["UserId"] != null) { int UserId = Convert.ToInt32(Session["UserId"]); View_UserDetails Userdetails = UserDetailsViewService.GetUserByUserId(Convert.ToInt32(UserId)); if (Userdetails.RoleId == "4") { Batches.Add(new Batches { Batch = "Visible To All", BatchName = "Visible To All" }); Batches.Add(new Batches { Batch = Convert.ToString(Userdetails.Batch), BatchName = "My BatchMates" }); } WhiteBoardModel WhiteBoard = new WhiteBoardModel() { Viewdetails = Batches, RoleId = Userdetails.RoleId, Batch = Userdetails.Batch, Stream = Userdetails.CourseName, Events = EventCategoryService.GetCategorys() }; if (ModelState.IsValid) { int?EventId = null; if (WhiteBoard.EventId == null || WhiteBoard.EventId == 0) { EventId = 5; } UserPost UserPosts = new UserPost() { EventId = EventId, UserId = UserId, UserMessage = WhiteBoards.Message, ViewBy = WhiteBoards.Batchyear, Status = true, CreatedOn = DateTime.Now }; int PostId = UserPostService.InsertUserPosts(UserPosts); string Batch = ""; Int64 BatchFrom = 0; Int64 BatchTo = 0; if (WhiteBoards.Batchyear == "Visible To All") { Batch = "Visible To All"; } else { BatchFrom = Convert.ToInt64(WhiteBoards.Batchyear); BatchTo = Convert.ToInt64(WhiteBoards.Batchyear) - (Convert.ToInt64(Userdetails.Years)); } if (Batch == "Visible To All") { UserPosts_Visisble UserPostVisible = new UserPosts_Visisble() { PostId = PostId, Batch = Batch, Branch = Userdetails.CourseCategoryName, Degreee = Userdetails.CourseId, CreatedOn = DateTime.Now, Status = true }; UserPostVisibleServices.Create(UserPostVisible); } else { UserPosts_Visisble UserPostVisible = new UserPosts_Visisble() { PostId = PostId, Batch = Convert.ToString(BatchTo), BatchTo = Convert.ToString(BatchFrom), Branch = Userdetails.CourseCategoryName, Degreee = Userdetails.CourseId, CreatedOn = DateTime.Now, Status = true }; UserPostVisibleServices.Create(UserPostVisible); } if (Images != null) { foreach (var Pictures in Images) { if (Pictures != null) { var fileName = Path.GetFileName(Pictures.FileName); var path = Path.Combine(Server.MapPath("~/UserPostingImages/" + fileName)); Pictures.SaveAs(path); var FilePath = "/UserPostingImages/" + fileName; UserPost_Images UserImages = new UserPost_Images() { PostId = PostId, ImagePath = FilePath, CreatedOn = DateTime.Now, Status = true }; UserpostPictureServices.Create(UserImages); } } } ViewBag.Userdata = GenericMethods.GetUserPostsonId(UserId, Convert.ToString(Userdetails.Batch), Convert.ToInt32(Userdetails.Years), Userdetails.CourseCategoryName, Page, defaultPageSize); return(RedirectToAction("Index", "WhiteBoard", new { area = "AlumniFaculty" })); } return(View(WhiteBoard)); } return(RedirectToAction(LoginPages.Login, LoginPages.Account, new { area = "" })); }
public ActionResult Index(WhiteBoardModel WhiteBoards, IEnumerable <HttpPostedFileBase> Images, IEnumerable <HttpPostedFileBase> Files) { if (Session["UserId"] != null) { List <YearsforFaculty> Years = new List <YearsforFaculty>(); int UserId = Convert.ToInt32(Session["UserId"]); View_UserDetails Userdetails = UserDetailsViewService.GetUserByUserId(Convert.ToInt32(UserId)); List <Batches> Batches = new List <Batches>(); int PostId = 0; if (ModelState.IsValid) { if (WhiteBoards.selections == "Visible To All") { UserPost UserPosts = new UserPost() { EventId = WhiteBoards.EventId, ViewBy = WhiteBoards.selections, UserId = UserId, UserMessage = WhiteBoards.Message, Status = true, CreatedOn = DateTime.Now }; PostId = UserPostService.InsertUserPosts(UserPosts); UserPosts_Visisble UserPostVisible = new UserPosts_Visisble() { PostId = PostId, Batch = WhiteBoards.selections, Branch = WhiteBoards.Degree, Degreee = Userdetails.CourseId, CreatedOn = DateTime.Now, Status = true, BatchTo = (WhiteBoards.WorkFromTo) }; UserPostVisibleServices.Create(UserPostVisible); } else { UserPost UserPosts = new UserPost() { EventId = WhiteBoards.EventId, UserId = UserId, UserMessage = WhiteBoards.Message, ViewBy = WhiteBoards.Batchyear, Status = true, CreatedOn = DateTime.Now }; PostId = UserPostService.InsertUserPosts(UserPosts); UserPosts_Visisble UserPostVisible = new UserPosts_Visisble() { PostId = PostId, Batch = WhiteBoards.WorkFromYear, Branch = WhiteBoards.Degree, Degreee = Userdetails.CourseId, CreatedOn = DateTime.Now, Status = true, BatchTo = (WhiteBoards.WorkFromTo) }; UserPostVisibleServices.Create(UserPostVisible); } if (Images != null) { foreach (var Pictures in Images) { if (Pictures != null) { var fileName = Path.GetFileName(Pictures.FileName); var path = Path.Combine(Server.MapPath("~/UserPostingImages/" + fileName)); Pictures.SaveAs(path); var FilePath = "/UserPostingImages/" + fileName; UserPost_Images UserImages = new UserPost_Images() { PostId = PostId, ImagePath = FilePath, CreatedOn = DateTime.Now, Status = true }; UserpostPictureServices.Create(UserImages); } } } ViewBag.Userdata = GenericMethods.GetUserdetailsonFaculty(UserId, Convert.ToString(Userdetails.Batch)); return(RedirectToAction("Index", "WhiteBoard", new { area = "Faculty" })); } if (Userdetails.RoleId == "2") { for (int?i = Userdetails.WorkingFrom; i <= Userdetails.WorkingTo; i++) { Years.Add(new YearsforFaculty { Year = Convert.ToString(i) }); } } WhiteBoardModel WhiteBoard = new WhiteBoardModel() { Viewdetails = Batches, RoleId = Userdetails.RoleId, Batch = Userdetails.Batch, Stream = Userdetails.CourseName, Events = EventCategoryService.GetCategorys(), yearsList = Years, Coursecategorys = CategoryServices.GetAllCourseCategories(), }; ViewBag.Userdata = GenericMethods.GetUserdetailsonFaculty(UserId, Convert.ToString(Userdetails.Batch)); return(View(WhiteBoard)); } return(RedirectToAction(LoginPages.Login, LoginPages.Account, new { area = "" })); }
public ActionResult PostasFaculty(WhiteBoardModel WhiteBoards, IEnumerable <HttpPostedFileBase> Images, IEnumerable <HttpPostedFileBase> Files) { int PostId = 0; if (Session["UserId"] != null) { int UserId = Convert.ToInt32(Session["UserId"]); View_UserDetails Userdetails = UserDetailsViewService.GetUserByUserId(Convert.ToInt32(UserId)); if (WhiteBoards.selections == "Visible To All") { UserPost UserPosts = new UserPost() { EventId = WhiteBoards.EventId, UserId = UserId, UserMessage = WhiteBoards.Message, ViewBy = WhiteBoards.selections, Status = true, CreatedOn = DateTime.Now }; PostId = UserPostService.InsertUserPosts(UserPosts); UserPosts_Visisble UserPostVisible = new UserPosts_Visisble() { PostId = PostId, Batch = WhiteBoards.selections, Branch = WhiteBoards.Degree, Degreee = Userdetails.CourseId, CreatedOn = DateTime.Now, Status = true, BatchTo = (WhiteBoards.WorkFromTo) }; UserPostVisibleServices.Create(UserPostVisible); } else { UserPost UserPosts = new UserPost() { EventId = WhiteBoards.EventId, UserId = UserId, UserMessage = WhiteBoards.Message, ViewBy = WhiteBoards.Batchyear, Status = true, CreatedOn = DateTime.Now }; PostId = UserPostService.InsertUserPosts(UserPosts); UserPosts_Visisble UserPostVisible = new UserPosts_Visisble() { PostId = PostId, Batch = WhiteBoards.WorkFromYear, Branch = WhiteBoards.Degree, Degreee = Userdetails.CourseId, CreatedOn = DateTime.Now, Status = true, BatchTo = (WhiteBoards.WorkFromTo) }; UserPostVisibleServices.Create(UserPostVisible); } if (Images != null) { foreach (var Pictures in Images) { if (Pictures != null) { var fileName = Path.GetFileName(Pictures.FileName); var path = Path.Combine(Server.MapPath("~/UserPostingImages/" + fileName)); Pictures.SaveAs(path); var FilePath = "/UserPostingImages/" + fileName; UserPost_Images UserImages = new UserPost_Images() { PostId = PostId, ImagePath = FilePath, CreatedOn = DateTime.Now, Status = true }; UserpostPictureServices.Create(UserImages); } } } return(RedirectToAction("Index", "WhiteBoard", new { area = "AlumniFaculty" })); } return(RedirectToAction(LoginPages.Login, LoginPages.Account, new { area = "" })); }