public ActionResult AddComent(int PlaceId, PlaceComment comment) { using (var a = new MeetUkraineContext()) { Place test = a.Places.Where(item => item.PlaceId == PlaceId).FirstOrDefault(); test.PlaceComments.Add(comment); a.SaveChanges(); } return(View()); }
private void btnPlaceComment_Click(object sender, RoutedEventArgs e) { if (!txtComment.Text.Equals("")) { PlaceComment pc = new PlaceComment(); pc.Comment = txtComment.Text; pc.PlaceId = uas.Place.PlaceId; pc.UserId = _vm.ActiveUser.UserId; _vm.SavePlaceComment(pc); txtComment.Text = ""; } }
//ADDPLACECOMMENT & LIST OF PLACECOMMENTS public async void AddPlaceComment(PlaceComment placecomment) { using (HttpClient client = new HttpClient()) { try { string url = string.Format("{0}{1}", URL, "placecomment"); string json = JsonConvert.SerializeObject(placecomment); HttpContent content = new StringContent(json); content.Headers.Clear(); content.Headers.Add("Content-Type", "application/json"); await client.PostAsync(url, content); } catch (Exception ex) { throw ex; } } }
public async Task <IHttpActionResult> Post(UserComment commnet) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } PlaceComment PlaceComment = new PlaceComment(); PlaceComment.Id = Guid.NewGuid(); PlaceComment.PlaceId = new Guid("dac11b39-c8a9-4c7f-9324-b626d8d61076"); PlaceComment.Comment = commnet.Comment; _db.PlaceCommens.Add(PlaceComment); try { await _db.SaveChangesAsync(); return(Ok(commnet)); } catch (Exception e) { return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e))); } }
public PlaceComment AddPlaceComment(PlaceComment placecomment) { placecomment = uow.PlaceCommentRepository.AddPlaceComment(placecomment); uow.Save(); return(placecomment); }
public void SavePlaceComment(PlaceComment placecomment) { shredderService.AddPlaceComment(placecomment); }
public PlaceComment AddPlaceComment(PlaceComment placecomment) { return(this.context.PlaceComments.Add(placecomment)); }