public ActionResult Dashboard(int Id = 0) { PostCommentModel model = new PostCommentModel(); UserPostBL blObj = new UserPostBL(); model.UserPostList = blObj.GetUserPost().OrderByDescending(p => p.CreationDate).Take(10).ToList(); ViewBag.Id = Id; UserBL userBL = new BL.BusinessLayer.UserBL(); model.User = Id == 0 ? SessionManager.InstanceCreator.Get<UserBM>(SessionKey.User) : userBL.GetUserById(Id); model.User.Image = UserGeneralInformationBL.GetGeneralInformationByUserId(model.User.Id) != null ? UserGeneralInformationBL.GetGeneralInformationByUserId(model.User.Id).Image : string.Empty; return View(model); }
public ActionResult UserPost() { PostCommentModel Model = new PostCommentModel(); Model.UserPost = new UserPostBM(); Model.UserPostList = UserPostBL.GetUserPost(); Model.SucessMessage = (TempData["Success"] != null ? TempData["Success"].ToString() : string.Empty).ToString(); Model.ErrorMessage = (TempData["Error"] != null ? TempData["Error"].ToString() : string.Empty).ToString(); return View(Model); }
public ActionResult NewPost(PostCommentModel Model, HttpPostedFileBase file, FormCollection collection) { UserBM CurrentUser = SessionManager.InstanceCreator.Get<UserBM>(SessionKey.User); string type = collection["type"].ToString(); if (CurrentUser != null) { UserPostBM UserPostBM = new UserPostBM(); UserPostBM.Post = Model.UserPost.Post; UserPostBM.Subject = Model.UserPost.Subject; UserPostBM.FileUrl=Model.UserPost.FileUrl; if (file != null) { string ImageName = System.IO.Path.GetFileName(file.FileName); string physicalPath = Server.MapPath("~/Images/" + ImageName); file.SaveAs(physicalPath); UserPostBM.FilePath = "/Images/" + ImageName; } UserPostBM.UserId = CurrentUser.Id; if (!string.IsNullOrEmpty(type)) UserPostBM.PostType = Convert.ToInt32(type); UserPostBM.CreatedBy = CurrentUser.Id; UserPostBM.CreationDate = DateTime.Now; UserPostBL.Create(UserPostBM); TempData["Success"] = "Record saved Successfully."; } else { TempData["Error"] = "Please Login."; } return RedirectToAction("UserPost"); }