public void AddComment(SComment comment) { using (var ctx = new DiscCtx(ConfigManager.ConnStr)) { var argPoint = ctx.ArgPoint.FirstOrDefault(ap => ap.Id == comment.ArgPointId); if (argPoint == null) { return; } var person = ctx.Person.FirstOrDefault(ap => ap.Id == comment.PersonId); if (person == null) { return; } var newComment = new Comment { ArgPoint = argPoint, Person = person, Text = comment.Text }; argPoint.Comment.Add(newComment); ctx.SaveChanges(); } }
public override string ToString() { return(IsTask ? string.Format("{0};{1};{2};0;{3};\"{4}\";\"{5}\";{6}", Id, Points.ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat), MaxPoints, State, TComment.Replace("\"", """), SComment.Replace("\"", """), File ) : Raw); }
public ActionResult Delete(SComment comToDelete) { int comId = comToDelete.Id; var Song_Id = comToDelete.Songs_Id; var context = new ApplicationDbContext(); var Record_Id = context.Songs.Where(s => s.Id == Song_Id).First().Records_Id; SComment commentASupprimer = new SComment(); commentASupprimer = context.SComment.Where(sc => sc.Id == comId).FirstOrDefault(); if (commentASupprimer != null) { context.SComment.Remove(commentASupprimer); context.SaveChanges(); } return(Redirect("/Records/Details/" + Record_Id)); }
public ActionResult GetCommentForStore(SComment sc) { int id = (int)Session["id"]; var find = db.Stores.Find(id); db.SComments.Add(new SComment { NameAndFname = sc.NameAndFname, Date = DateTime.Now, AdminConfirm = false, Txt = sc.Txt, Email = sc.Email, Store_Id = find.Id }); db.SaveChanges(); return(RedirectToAction("storeview", new { id = find.Id })); }
public ActionResult Add(SComment resultat) { if (!Request.IsAuthenticated) { return(Redirect("https://localhost:44388/Account/Login")); } else { var context = new ApplicationDbContext(); SComment comment = resultat; comment.Users_Id = User.Identity.GetUserId(); comment.PostedAt = DateTime.Now; context.SComment.Add(comment); context.SaveChanges(); ViewBag.CurrentUser = User.Identity.Name; ViewBag.CurrentId = User.Identity.GetUserId(); var Record_Id = context.Songs.Where(s => s.Id == comment.Songs_Id).FirstOrDefault().Records_Id; return(new EmptyResult()); } }