public async Task <IActionResult> CreateComment(int id, [FromBody] CommentCreate createModel) { if (createModel == null || !ModelState.IsValid) { return(BadRequest()); } var review = await _reviewData.GetReview(id); if (review == null) { return(NotFound()); } try { await _reviewData.CreateComment(createModel); return(NoContent()); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public bool CreateComment(CommentCreate model) { var entity = new Comment() { OwnerID = _userID, BookID = model.BookID, Book = model.Book, //MovieID = model.MovieID, //Movie = model.Movie, // ShowID = model.ShowID, // Show = model.Show, // TheaterProductionID = model.TheaterProductionID, // TheaterProduction = model.TheaterProduction, TypeOfMedia = model.TypeOfMedia, MyComment = model.MyComment, IsRecommended = model.IsRecommended, CreatedUtc = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.Comments.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool CreateComment(CommentCreate model, int ProfileID) { var entity = new Comment() { UserID = _userId, ProfileID = model.ProfileID, Title = model.Title, Content = model.Content, Name = model.Name, DateSent = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { var query = ctx .Profile .Include("Comments") .Where(e => e.ProfileID == ProfileID) .Single(); query.Comments.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool CreateComment(CommentCreate model, int id) { var userInfoService = new UserInfoService(_userID); var getUser = userInfoService.GetUsersByID(_userID); var username = getUser.Username; var vibeService = new VibeService(_userID, username); var getVibeID = vibeService.GetVibeDetailsByVibeId(id); id = getVibeID.VibeID; var ctx = new ApplicationDbContext(); var user = ctx.Users.Find(_userID); _user = user; var entity = new CommentsAndReactions() { Id = _userID, VibeID = id, Username = username, CommentText = model.CommentText, DateCreated = DateTimeOffset.UtcNow }; using (ctx) { ctx.Comments_Reactions.Add(entity); return(ctx.SaveChanges() == 1); } }
public async Task <Comment> CreateComment(CommentCreate commentObject, int postId) { var postBody = new StringContent(JsonConvert.SerializeObject(commentObject).ToString(), Encoding.UTF8, "application/json"); (var comment, HttpResponseMessage response) = await PostRequest <Comment>($"{defaultPath}comments", postBody); return(comment); }
public static Comment ConvertCommentWhenCreate(this CommentCreate commentCreated) { return(new Comment { Content = commentCreated.Content, TaskId = commentCreated.TaskId }); }
public async Task <ActionResult <Comment> > PostComments(CommentDTO commentDTO) { var create = new CommentCreate { commentDTO = commentDTO }; return(await create.Excute()); }
public CommentCreate CommentModelCreate(CommentCreate model, int id) { model.CommentorUserID = _userID; model.PostID = id; model.Status = CommentStatus.Pending; model.CreateUTC = DateTimeOffset.Now; return(model); }
public async Task <IRestResponse> CreateComment(CommentCreate createModel) { RestRequest restRequest = new RestRequest($"/{createModel.ReviewId}/comments", Method.POST); restRequest.AddHeader("Content", "application/json"); restRequest.AddJsonBody(createModel); return(await _restClient.ExecuteTaskAsync(restRequest)); }
public async Task <Comment> CreateComment(CommentCreate commentCreate) { var comment = _mapper.Map <Domain.Comment>(commentCreate); _shopDbContext.CommentRepository.Add(comment); await _shopDbContext.SaveAsync(); return(_mapper.Map <Comment>(comment)); }
public ActionResult Create(int id) { var model = new CommentCreate { LessonId = id, UserId = Guid.Parse(User.Identity.GetUserId()) }; return(View(model)); }
//public void Assign() //{ // _emailSender.Send( // to: "*****@*****.**", // body: $"demo", // from: "*****@*****.**", // isBodyHtml: true, // subject: "test" // ); //} public async Task Create(CommentCreate input) { var comment = input.MapTo <Models.Comment>(); comment.Status = true; await _commentRepository.InsertAsync(comment); eventBus.Trigger(new CommentCompletedEventData { Id = 2 }); }
public bool CreateComment(CommentCreate model) { var entity = new Comment() { }; using (var ctx = new ApplicationDbContext()) { ctx.Comments.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool CreateComment(CommentCreate model) { Comment comment = new Comment() { OwnerId = _userId, CommentText = model.CommentText, CreatedUtc = DateTimeOffset.Now, ReviewId = model.ReviewId }; _context.Comments.Add(comment); return(_context.SaveChanges() == 1); }
//// GET -- Create //public ActionResult Create() //{ // return View(); //} //// POST -- Create //[HttpPost] //[ValidateAntiForgeryToken] //public ActionResult Create(CommentCreate model) //{ // if (!ModelState.IsValid) return View(model); // var service = CreateCommentService(); // if (service.CreateComment(model)) // { // TempData["SaveResult"] = "Comment was created."; // return RedirectToAction("Index"); // }; // ModelState.AddModelError("", "Comment could not be created."); // return View(model); //} //// CREATE COMMENT WITH BULLETINID public ActionResult CreateCommentWithBulletinId(int id) { var service = CreateCommentService(); var detail = service.GetBulletinById(id); var model = new CommentCreate { BulletinId = detail.BulletinId }; return(View(model)); }
public async Task Should_Create_New_Comment() { // Arrange var commentCreate = new CommentCreate { CommentText = "CommentText" }; // Act var comment = await _commentProvider.CreateComment(commentCreate); // Assert Assert.AreEqual(_comments.First().CommentText, comment.CommentText); }
public bool CreateComment(CommentCreate model) { var entity = new Comment { CommentId = _commentID, Text = model.Text }; using (var ctx = new ApplicationDbContext()) { ctx.Comments.Add(entity); return(ctx.SaveChanges() > 0); } }
public IHttpActionResult Post(CommentCreate comment) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateCommentService(); if (!service.CreateComment(comment)) { return(InternalServerError()); } return(Ok()); }
public IHttpActionResult Post(CommentCreate model) { var svc = CreateCommentService(); var newCat = svc.CommentCreate(model); if (newCat == false) { return(BadRequest()); } else { return(Ok()); } }
public bool CreateComment(CommentCreate Model) { var entity = new Comment() { AuthorId = _userId, Text = Model.Content, }; using (var ctx = new ApplicationDbContext()) { ctx.Comments.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool CreateComment(CommentCreate model) { var entity = new Comment() { AuthorID = model.AuthorID, Text = model.Text, CommentPostID = model.CommentPostID, }; using (var ctx = new ApplicationDbContext()) { ctx.Comment.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool CreateComment(CommentCreate model) { var entity = new Comment() { UserId = _userId, CommentPost = model.CommentPost, Text = model.Text }; using (var ctx = new ApplicationDbContext()) { ctx.Comments.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult CreateComment(CommentCreate model, int id) { var service = CreateCommentService(); var entity = service.CommentModelCreate(model, id); // Create Model bc I am only bringing over the post ID if(service.CreateComment(model, id)) { ViewBag.SaveResult = "You Commented!"; return RedirectToAction("Index"); } ModelState.AddModelError("", "Comment could not be created."); return View(model); }
public bool CreateComment(CommentCreate model) { var entity = new Comment() { Author = _userId, Text = model.Text, PostId = model.PostId }; using (var ctx = new ApplicationDbContext()) { ctx.Comments.Add(entity); return(ctx.SaveChanges() != 0); } }
public bool CreateComment(CommentCreate model) { var entity = new Comment() { AuthorId = _authorId, CommentText = model.CommentText, Id = model.Id }; using (var ctx = new ApplicationDbContext()) { ctx.Comments.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool CreateComment(CommentCreate model) { var entity = new Comment() { CommentAuthor = _userId, Text = model.Text, CreatedUtc = DateTime.Now }; using (var ctx = new ApplicationDbContext()) { ctx.Comments.Add(entity); return(ctx.SaveChanges() == 1); } }
public static async void SetupDialog(GetDialogInfo name) { var dialogCreate = new Windows.UI.Xaml.Controls.ContentDialog(); var commentCreate = new CommentCreate(); switch (name) { case 0: dialogCreate.Title = "Write your story of love here:"; dialogCreate.CloseButtonText = "Cancel"; dialogCreate.PrimaryButtonText = "Send"; dialogCreate.PrimaryButtonStyle = (Style)Application.Current.Resources["AccentButtonStyle"]; dialogCreate.SecondaryButtonText = "Save"; //dialogCreate.DefaultButton = ContentDialogButton.Primary; dialogCreate.Content = commentCreate; dialogCreate.Background = new SolidColorBrush(Colors.Black); if (!Generic.DeviceFamilyMatch(DeviceFamilyList.Mobile)) { dialogCreate.CloseButtonStyle = (Style)Application.Current.Resources["ButtonRevealStyle"]; dialogCreate.SecondaryButtonStyle = (Style)Application.Current.Resources["ButtonRevealStyle"]; dialogCreate.BorderBrush = (Brush)Application.Current.Resources["SystemControlBackgroundListMediumRevealBorderBrush"]; } break; case (GetDialogInfo)1: dialogCreate.Title = "Release Notes"; dialogCreate.CloseButtonText = "Okay"; dialogCreate.Content = new ReleaseNotes(); dialogCreate.Background = new SolidColorBrush(Colors.Black); //if (!Generic.DeviceFamilyMatch(DeviceFamilyList.Mobile)) //{ // dialogCreate.CloseButtonStyle = (Style)Application.Current.Resources["ButtonRevealStyle"]; // dialogCreate.BorderBrush = (Brush)Application.Current.Resources["SystemControlBackgroundListMediumRevealBorderBrush"]; //} break; } try { var loaded = await dialogCreate.ShowAsync(); if (loaded == ContentDialogResult.Secondary) { commentCreate.SavingDate(); } } catch (System.Runtime.InteropServices.COMException) { } // Nothing todo. }
// Post --Create a comment public bool CreateComment(CommentCreate model) { var entity = new Comment() { CommenterId = _userId, // this is cool ExchangeId = model.ExchangeId, Text = model.CommentText }; using (var ctx = new ApplicationDbContext()) { ctx.Comments.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool CreateComment(CommentCreate model) { var commentEntity = new Comment { Text = model.Text, PostId = model.PostId, ApplicationUserId = _userId.ToString(), CreatedUtc = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.Comments.Add(commentEntity); return(ctx.SaveChanges() == 1); } }
public bool CreateComment(CommentCreate model) { var entity = new Comment() { Id = commentId, Text = model.Text, Author = model.Author, CommentPost = model.CommentPost, }; using (var ctx = new ApplicationDbContext()) { ctx.Entry(entity); return(ctx.SaveChanges() == 1); } }