public bool CreateReply(ReplyCreate model) { var entity = new Reply() { ReplyComment = model.ReplyComment, }; using (var ctx = new ApplicationDbContext()) { ctx.Reply.Add(entity); return(ctx.SaveChanges() == 1); } }
public IHttpActionResult Post(ReplyCreate reply) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateReplyService(); if (!service.CreateReply(reply)) { return(InternalServerError()); } return(Ok()); }
public bool CreateReply(ReplyCreate model) { var entity = new Reply() { Text = model.Text, AuthorId = _userId }; using (var ctx = new ApplicationDbContext()) { ctx.Entry(entity); return(ctx.SaveChanges() == 1); } }
public async Task <IHttpActionResult> CreateReply(ReplyCreate model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } ReplyService service = CreateReplyService(); if (!await service.CreateReply(model)) { return(InternalServerError()); } return(Ok()); }
public bool CreateReply(ReplyCreate model) { using (var ctx = new ApplicationDbContext()) { var entity = new Reply() { User = _userId, ReplyText = model.ReplyContent, CommentId = model.CommentId, }; ctx.Reply.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool CreatePost(ReplyCreate model) { var entity = new Reply() { Text = model.Text, CommentId = model.CommentId, UserId = _userId, }; using (var ctx = new ApplicationDbContext()) { ctx.Replies.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool CreateReply(ReplyCreate model) { var entity = new Reply() { AuthorId = _userId, Text = model.Content, }; using (var ctx = new ApplicationDbContext()) { ctx.Replies.Add(entity); return(ctx.SaveChanges() == 1); } }
//REPLY METHODS //Create a reply toa comment using a foreign key relationship public bool CreateReply(ReplyCreate model) { var entity = new Reply() { AuthorId = _authorId, Text = model.Text, CreatedUtc = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.Replies.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool CreateReply(ReplyCreate model) { var entity = new Reply() { Text = model.CommentText, CommentId = model.CommentId, PostId = model.PostId }; using (var ctx = new ApplicationDbContext()) { entity.Author = ctx.SocMediaUsers.Where(e => e.Id == _userId).First(); ctx.Replys.Add(entity); return(ctx.SaveChanges() == 2); } }
public IHttpActionResult Post(ReplyCreate post, int id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreatePostService(id); if (!service.CreatePost(post)) { return(InternalServerError()); } return(Ok()); }
public bool CreateReply(ReplyCreate model) { var entity = new Reply() { UserId = _userId, PostId = model.PostId, ReplyComment = model.ReplyComment }; using (var ctx = new ApplicationDbContext()) { ctx.Replies.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool CreateReply(ReplyCreate model) { var entity = new Reply() { ReplyTitle = model.ReplyTitle, ReplyText = model.ReplyText, UserID = model.UserID, CreatedUtc = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.Replies.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool CreateReply(ReplyCreate model) { var entity = new Reply() { CommentID = model.CommentID, CommentText = model.CommentText, ReplyComment = model.ReplyComment, CommentAuthor = model.CommentAuthor }; using (var ctx = new ApplicationDbContext()) { ctx.Replies.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult AddReply(int id) { var profileService = CreateProfileService(); var userProfile = profileService.GetProfile(); var model = new ReplyCreate { SenderFullName = userProfile.FullName, SenderUsername = userProfile.Username, SenderProfilePicture = userProfile.ProfilePicture, CommentID = id, Created = DateTimeOffset.Now, }; return(PartialView("_AddReply", model)); }
public bool CreateReply(ReplyCreate model) { var entity = new Reply() { Id = replyId, Text = model.Text, Author = model.Author, CommentPost = model.CommentPost, ReplyComment = model.ReplyComment, }; using (var ctx = new ApplicationDbContext()) { ctx.Entry(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult CreateReply(ReplyCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateReplyService(); if (service.CreateReply(model)) { TempData["SaveResult"] = "Your reply was successfully uploaded."; return(RedirectToAction($"../Post/Details/{model.PostID}")); } ; return(View(model)); }
//Post public bool CreateReply(ReplyCreate model) { var entity = new Reply() { Text = model.Text, AuthorID = model.AuthorID, CommentPostID = model.CommentPostID, ReplyCommentID = model.ReplyCommentID }; using (var ctx = new ApplicationDbContext()) { ctx.Reply.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool NewReply(ReplyCreate model) { using (var ctx = new ApplicationDbContext()) { var entity = new Reply { SenderFullName = model.SenderFullName, SenderUsername = model.SenderFullName, CommentID = model.CommentID, Created = DateTimeOffset.Now, ReplyContent = model.ReplyContent, }; ctx.Replies.Add(entity); ctx.SaveChanges(); return(true); } }
public bool CreateReply(ReplyCreate model) { var entity = new Reply() { OwnerId = _userId, ReplyId = model.ReplyId, ReplyText = model.ReplyText, ReplyCreatedUtc = DateTimeOffset.Now, CommentId = model.CommentId, }; using (var ctx = new ApplicationDbContext()) { ctx.Replies.Add(entity); return(ctx.SaveChanges() == 1); } }
//POST public bool CreateReply(ReplyCreate model) { var newReply = new Reply() { OwnerId = _userId, Content = model.Content, Created = DateTimeOffset.Now, CommentId = model.CommentId, Title = $"Re: {model.comment.Title}" }; using (var db = new ApplicationDbContext()) { db.Replies.Add(newReply); return(db.SaveChanges() == 1); } }
public ActionResult Create(ReplyCreate model) { if (!ModelState.IsValid) { return(View(model)); } var userId = Guid.Parse(User.Identity.GetUserId()); var service = new ReplyServices(userId); if (service.CreateReply(model)) { TempData["SaveResult"] = "Your reply has been saved."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Resource could not be created."); return(View(model)); }
public bool CreateReply(ReplyCreate model) { var replyEntity = new Reply { Text = model.Text, PostId = model.PostID, CommentId = model.CommentId, ApplicationUserId = _userId.ToString(), CreatedUtc = DateTimeOffset.Now, ReplyId = Guid.NewGuid() }; using (var ctx = new ApplicationDbContext()) { ctx.Replies.Add(replyEntity); return(ctx.SaveChanges() == 1); } }
// Post --Create a reply public bool CreateReply(ReplyCreate model) { var entity = new Reply() { Text = model.CommentText, CommentId = model.CommentId, //Using user Id to identify commenter CommenterId = _userId }; using (var ctx = new ApplicationDbContext()) { // grabbing exchange Id from comment entity.ExchangeId = ctx.Comments.Single(e => e.Id == entity.CommentId).ExchangeId; ctx.Comments.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool CreateReply(ReplyCreate model) { using (var ctx = new ApplicationDbContext()) { //var user = //ctx.User //.Single(e => e.UniqueID == _userID); var entity = new Reply() { Content = model.Reply, //UserId = user.UserID, CreatedUTC = model.CreatedUTC }; ctx.Replies.Add(entity); return(ctx.SaveChanges() > 0); } }
public ActionResult Create(ReplyCreate model) { model.CommentId = Convert.ToInt32(TempData["CommentId"]); if (!ModelState.IsValid) { return(View(model)); } var service = CreateReplyService(); if (service.CreateReply(model)) { TempData["SaveResult"] = "Reply was created!"; return(RedirectToAction("Details", "Comment", new { id = model.CommentId })); } ModelState.AddModelError("", "Reply was not created."); return(View(model)); }
// Create: Create a reply public bool CreateReply(ReplyCreate model) // edited naming conventions { var entity = new Reply() { Id = _userId.ToString(), ReplyId = model.ReplyId, ReplyText = model.ReplyText, TipId = model.TipId, ModifiedUtc = null, CreatedUtc = DateTime.Now //Owner = model.Owner, }; using (var ctx = new ApplicationDbContext()) { ctx.Replies.Add(entity); return(ctx.SaveChanges() == 1); } }
//CREATE public bool CreateReply(ReplyCreate model) { using (var db = new ApplicationDbContext()) { if (db.Profiles.SingleOrDefault(p => p.UserID == _userId) == null) { var svc = new ProfileService(_userId); svc.CreateProfile(_userId); } var entity = new Reply() { UserID = _userId, Body = model.Body, TimePosted = DateTimeOffset.Now, PostID = model.PostID, }; db.Replies.Add(entity); return(db.SaveChanges() == 1); } }
public bool CreateReply(ReplyCreate model) { using (var ctx = new ApplicationDbContext()) { bool isValid = int.TryParse(model.CommentId, out int id); if (!isValid) { id = 0; } var entity = new Reply() { Author = _userId, Content = model.Content, CommentId = id, }; ctx.Replies.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool CreateReply(ReplyCreate model) { var entity = new Reply() { OwnerId = _userId, UserName = model.UserName, Content = model.Content, CreateUtc = DateTimeOffset.Now, CommentId = model.CommentId }; using (var ctx = new ApplicationDbContext()) { var comment = ctx.Comments.Find(entity.CommentId); comment.ListOfReplies.Add(entity); ctx.Replies.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult PostReply(ReplyCreate model) { if (!ModelState.IsValid) { return(View(model)); } var profileService = CreateProfileService(); var comment = profileService.GetComment((int)model.CommentID); if (profileService.NewReply(model)) { TempData["SaveResult"] = "Reply Posted."; return(PartialView("_ReloadReplies", comment)); } ModelState.AddModelError("", "Your reply could not be posted."); return(PartialView("_ReloadReplies", comment)); }