public Comment UpdateOldComment(Comment c) { c = UpdateComment(c); entity.SaveChanges(); return c; }
public Comment UpdateOldComment(Comment c) { return _old.UpdateOldComment(c); }
public Comment AddNewComment(Comment c) { return _new.AddNewComment(c); }
void btnSendComment_Command(object sender, CommandEventArgs e) { if (Session["Admin"] != null) { foreach (TableRow row in tblComments.Rows) foreach (TableCell cell in row.Cells) foreach (Control ctrl in cell.Controls) { TextBox txt = ctrl as TextBox; if (txt != null && txt.Text != "") { Comment c = new Comment(); BE.Admin admin = Session["Admin"] as BE.Admin; c.UsernameId = admin.Username; c.Text = txt.Text; c.TicketId = Convert.ToInt32(e.CommandArgument); _bllTicket.AddNewComment(c); MailMe.SendMail("Centex Support - Ticket ref. " + _tick.Id, "Hej,\n\nDer er sket ændringer på din forespørgsel. \nFølg linket for at se ændringerne: " + "<a href=" + Request.Url.GetLeftPart(UriPartial.Authority) + "/ticket" + Encryption.Encrypt("TicketId=" + _tick.Id) + ">link</a>", _tick.User.Mail); Response.Redirect("ViewTicket.aspx?TicketId=" + _tick.Id); //Response.Write("<scrip>alert('boo');</script>"); //ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString("N"), "alert('ok');", true); //lblError.Text += "Der er sendt en mail af sted til brugeren angående din nye kommentar!"; } else { lblError.Text = "Comment field is required"; } break; } } }
private Comment UpdateComment(Comment c) { var entry = entity.Entry<Comment>(c); if (entry.State == System.Data.EntityState.Detached) { var set = entity.Set<Comment>(); Comment attachedEntity = entity.Set<Comment>().Local.SingleOrDefault(e => e.Id == c.Id); // You need to have access to key if (attachedEntity != null) { var attachedEntry = entity.Entry(attachedEntity); attachedEntry.CurrentValues.SetValues(c); } else { entry.State = System.Data.EntityState.Modified; // This should attach entity } return attachedEntity; } return entry.Entity; }