public ActionResult GetUplodedImage() { string FolderPath; string ServerPath; string result; FolderPath = Constant_UploadImagePath.UserUploadImage; ServerPath = string.Format("{0}://{1}:{2}{3}", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, (Request.ApplicationPath == "/" ? "" : Request.ApplicationPath)); var tempFolderPath = FolderPath.Replace("~/", ServerPath + "/"); if (Directory.Exists(Server.MapPath(FolderPath))) { ; } { var ImageInfos = new DirectoryInfo(Server.MapPath(FolderPath)).GetFiles().ToList(); } DataTable dtGetUserPost = WebAppDAL.GetUserPostData(ProjectSession.clientID); NewsFeed newsFeed = new NewsFeed(); if (dtGetUserPost != null && dtGetUserPost.Rows.Count > 0) { for (var i = 0; i < 1; i++) { if (!string.IsNullOrEmpty(Convert.ToString(dtGetUserPost.Rows[0]["Imagename"]))) { newsFeed.Data.Add(new UserData { UserPostData = Convert.ToString(dtGetUserPost.Rows[0]["NewsFeed"]), UserName = Convert.ToString(dtGetUserPost.Rows[0]["Username"]), DateTime = Convert.ToDateTime(dtGetUserPost.Rows[i]["CreatedDateTime"]), ImagePath = tempFolderPath + Convert.ToInt32(dtGetUserPost.Rows[0]["UserID"]) + "/" + Convert.ToString(dtGetUserPost.Rows[0]["Imagename"]), }); } else { newsFeed.Data.Add(new UserData { UserPostData = Convert.ToString(dtGetUserPost.Rows[0]["NewsFeed"]), UserName = Convert.ToString(dtGetUserPost.Rows[0]["Username"]), UserID = Convert.ToInt32(dtGetUserPost.Rows[0]["UserID"]), DateTime = Convert.ToDateTime(dtGetUserPost.Rows[0]["CreatedDateTime"]), }); } } } string jsonResult = JsonConvert.SerializeObject(newsFeed); return(new ContentResult { Content = jsonResult, ContentType = "application/json" }); }
public ActionResult GetUserPost() { string FolderPath; string ServerPath; //if (string.IsNullOrEmpty(FolderPath)) //{ FolderPath = Constant_UploadImagePath.UserUploadImage; //} //if(string.IsNullOrEmpty(ServerPath)) //{ ServerPath = string.Format("{0}://{1}:{2}{3}", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, (Request.ApplicationPath == "/" ? "" : Request.ApplicationPath)); //} var tempFolderPath = FolderPath.Replace("~/", ServerPath + "/"); if (Directory.Exists(Server.MapPath(FolderPath))) { ; } { var ImageInfos = new DirectoryInfo(Server.MapPath(FolderPath)).GetFiles().ToList(); } DataTable dtGetUserPost = WebAppDAL.GetUserPostData(ProjectSession.clientID); NewsFeed newsFeed = new NewsFeed(); if (dtGetUserPost != null && dtGetUserPost.Rows.Count > 0) { for (var i = 0; i < dtGetUserPost.Rows.Count; i++) { //NewsFeed data = new NewsFeed(); //data.UserPostData = Convert.ToString(dtGetUserPost.Rows[i]["NewsFeed"]); if (!string.IsNullOrEmpty(Convert.ToString(dtGetUserPost.Rows[i]["Imagename"]))) { newsFeed.Data.Add(new UserData { UserPostData = Convert.ToString(dtGetUserPost.Rows[i]["NewsFeed"]), UserName = Convert.ToString(dtGetUserPost.Rows[i]["Username"]), UserID = Convert.ToInt32(dtGetUserPost.Rows[i]["UserID"]), DateTime = Convert.ToDateTime(dtGetUserPost.Rows[i]["CreatedDateTime"]), ImagePath = tempFolderPath + Convert.ToInt32(dtGetUserPost.Rows[i]["UserID"]) + "/" + Convert.ToString(dtGetUserPost.Rows[0]["Imagename"]), }); } else { newsFeed.Data.Add(new UserData { UserPostData = Convert.ToString(dtGetUserPost.Rows[i]["NewsFeed"]), UserName = Convert.ToString(dtGetUserPost.Rows[i]["Username"]), UserID = Convert.ToInt32(dtGetUserPost.Rows[i]["UserID"]), DateTime = Convert.ToDateTime(dtGetUserPost.Rows[i]["CreatedDateTime"]), //ImagePath = tempFolderPath + "/" + Convert.ToString(dtGetUserPost.Rows[i]["Imagename"]), }); } //model.Add(new SelectListItem { // Value = Convert.ToString(dtGetUserPost.Rows[i]["NewsFeed"]), // Text = Convert.ToString(dtGetUserPost.Rows[i]["NewsFeed"]), //}); } } //dynamic mymodel = new ExpandoObject(); //mymodel.UserData = model; //ViewBag.NewsFeed = model; return(View("Index", newsFeed)); }