public async Task <IActionResult> CreatePost([FromRoute] string CID, [FromBody] InsertPostViewModel post) { var result = await _MongocourseService.CreatePost(CID, post); if (result) { return(Ok(new { status = 1, Message = "Successfully Created" })); } return(BadRequest()); }
public ActionResult InsertPost(InsertPostViewModel model) { var user = System.Web.HttpContext.Current.User.Identity.GetUserId(); model.userId = user; if (model.postText == null) { return(Redirect(Request.UrlReferrer.ToString())); } repository.InsertPost(model.postText, model.threadId, model.userId); return(Redirect(Request.UrlReferrer.ToString())); }
public async Task <IActionResult> CreatePost([FromRoute] string CID, [FromBody] InsertPostViewModel model) { if (model.Title == null) { return(BadRequest("titie is req")); } var result = await _MongocourseService.CreatePost(CID, model); if (result) { return(Ok(new { status = 1, Message = "Successfully Created" })); } return(BadRequest()); }
public async Task <bool> CreatePost(string CID, InsertPostViewModel model) { var ec = "5ee053a44fa35c34c42819b2"; var cc = "5ee053cb4fa35c34c42819b3"; var dn = "5ee053354fa35c34c42819b1"; CID = cc; model.IssuerId = "mohamed"; //await httpClient.PutJsonAsync<InsertPostViewModel>($"api/v1/Community/CreatePost/{CID}", model); StringContent modelJson = new StringContent(JsonSerializer.Serialize(model), Encoding.UTF8, "application/json"); var response = await httpClient.PutAsync($"api/v1/Community/CreatePost/{CID}", modelJson); if (response.IsSuccessStatusCode) { return(true); } return(false); }
public async Task <bool> CreatePost(string CID, InsertPostViewModel model) { var com = await GetCommunity(CID); Post post = new Post { Id = Guid.NewGuid().ToString(), Description = model.Description, IssuerId = model.IssuerId, IssuerType = model.IssuerType, Time = DateTime.Now, Title = model.Title, Comments = new List <Comment>(), Emotions = new List <Emotion>(), Image = "" }; com.Posts.Add(post); var result = await _Community.ReplaceOneAsync(x => x.Id == CID, com); return(result.IsAcknowledged); }
private void ResetDialog() { Post = new InsertPostViewModel(); }
public async Task <bool> CreatePost(string CID, InsertPostViewModel model) { await httpClient.PutJsonAsync <InsertPostViewModel>($"", model); return(true); }