public bool UpdateProjectComment(ProjectComment instance) { try { ProjectComment comment = Db.ProjectComments.Find(instance.ProjectCommentId); Type type = comment.GetType(); foreach(var info in type.GetProperties()) { if(info.CanWrite) { var value = info.GetValue(instance); if(value != null) { info.SetValue(comment, value, null); } } } Db.SaveChanges(); return true; } catch { return false; } }
public bool CreateProjectComment(ProjectComment instance) { try { if (instance.ProjectCommentId == 0) { Db.ProjectComments.Add(instance); Db.SaveChanges(); return true; } return false; } catch { return false; } }