public bool SaveDataSet(DataSet dsComments) { bool result = false; Database db = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING); DbConnection connection = db.CreateConnection(); connection.Open(); DbTransaction transaction = connection.BeginTransaction(); try { result = new CommentDAO().InsertUpdateDelete(dsComments, db, transaction); transaction.Commit(); } catch (System.Exception ex) { transaction.Rollback(); result = false; throw ex; } finally { connection.Close(); } return(result); }
public decimal GetOverrallFeedbackByContext(Enums.ContextType contextType, Guid contextId) { decimal returnVal; List <Comment> comments = CommentDAO.SelectCommentListByContext((int)contextType, contextId); comments.RemoveAll(comm => comm.CommentTypeId != (int)Enums.CommentType.Feedback); decimal totalFeedbackScore = 0; foreach (Comment comment in comments) { if (comment.RatingValue > 0) { totalFeedbackScore += comment.RatingValue; } } if (totalFeedbackScore > 0) { returnVal = totalFeedbackScore / comments.Count(); } else { returnVal = 0.1M; } return(returnVal); }
public void save(Comment comment) { try { string AccessCode = Utility.GetQueryStringValueByKey(Request, "AccessCode"); if (AccessCode != null && AccessCode != string.Empty) { comment.ContextId = Guid.Parse(AccessCode); if (comment.Insert(comment)) { DataSet ds; ds = new CommentDAO().SelectByContext(1, Guid.Parse(Membership.GetUser().ProviderUserKey.ToString())); ds.Tables[0].PrimaryKey = new DataColumn[] { ds.Tables[0].Columns["CommentId"] }; Session[Constants.SESSION_COMMENTS] = ds; // Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Save_Success + "'); window.location = '/Student/Student_Public_Profile.aspx?AccessCode='" + AccessCode + "';}", true); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Save_Unsuccess + "'); }", true); } } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Save_Unsuccess + "');}", true); } } catch (Exception ex) { Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Save_Unsuccess + "'); }", true); throw ex; } }
public void LoadComments(Guid AccessCode) { DataSet ds; ds = new CommentDAO().SelectByContext(2, AccessCode); ds.Tables[0].PrimaryKey = new DataColumn[] { ds.Tables[0].Columns["CommentId"] }; DataListStudentComments.DataSource = ds.Tables[0]; DataListStudentComments.DataBind(); }
//public void LoadComments(Guid AccessCode) //{ // DataSet ds; // ds = new CommentDAO().SelectByContext(1, AccessCode); // ds.Tables[0].PrimaryKey = new DataColumn[] { ds.Tables[0].Columns["CommentId"] }; // DataListStudentComments.DataSource = ds.Tables[0]; // DataListStudentComments.DataBind(); //} public void LoadComments() { DataSet ds = null; ds = new CommentDAO().SelectByContext(1, Guid.Parse(Membership.GetUser().ProviderUserKey.ToString())); ds.Tables[0].PrimaryKey = new DataColumn[] { ds.Tables[0].Columns["CommentId"] }; DataListStudentComments.DataSource = ds.Tables[0]; DataListStudentComments.DataBind(); }
public List <Comment> SelectListByLandLordId(Guid landlordId) { return(CommentDAO.GetAllByFieldValue("ContextId", landlordId, Enums.ContextType.Landlord)); }
public List <Comment> SelectListByStudentId(Guid studentId) { return(CommentDAO.GetAllByFieldValue("ContextId", studentId, Enums.ContextType.Student)); }
public bool Update(Comment comment) { bool result; Database db = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING); DbConnection connection = db.CreateConnection(); connection.Open(); DbTransaction transaction = connection.BeginTransaction(); try { result = new CommentDAO().Update(comment, db, transaction); transaction.Commit(); } catch (System.Exception ex) { transaction.Rollback(); result = false; throw ex; } finally { connection.Close(); } return result; }