public JsonResult CreatePost(UploadPostModel model) { if (model.postContent != null) { string fileName = CommonConstant.IMAGE_DEFAULT; HttpPostedFileWrapper file = model.postImage; if (file != null) { fileName = postInteractService.saveFileToServer(file); } if (!string.IsNullOrEmpty(fileName)) { LoginedUser loginedUser = getUserInSession(); string postId = postInteractService.addPost(loginedUser.Id, model.postContent, fileName); if (postId != null) { Response.StatusCode = (int)HttpStatusCode.OK; return(Json(new { status = true, postId, imagePath = fileName, model.postContent, user = loginedUser })); } } } Response.StatusCode = (int)HttpStatusCode.InternalServerError; return(Json(new { status = false })); }
public IActionResult Upload() { var model = new UploadPostModel(); return(View(model)); }