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 Comment(Enums.ContextType contextType, Guid contextId) { ContextTypeId = (int)contextType; ContextType = contextType; ContextId = contextId; }
public Comment(Enums.ContextType contextType) { ContextTypeId = (int)contextType; ContextType = contextType; }
public DataSet SelectDataSetBycontextId(Guid contextId, Enums.ContextType ContextType) { return(new PhotoDAO().SelectByContext((int)ContextType, contextId)); }
public Photo(Enums.ContextType contextType, Guid contextId) { ContextTypeId = (int)contextType; ContextType = contextType; ContextId = contextId; }
/// <summary> /// Returns a collection of T. T must be an Entity class /// </summary> public static List <Comment> GetAllByFieldValue(string fieldName, Guid fieldValue, Enums.ContextType contextType) { List <Comment> returnEntityCollection = new List <Comment>(); Database db = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING); DbCommand dbCommand = db.GetStoredProcCommand("usp_CommentSelectAllBy" + fieldName); db.AddInParameter(dbCommand, fieldName, DbType.Guid, fieldValue); db.AddInParameter(dbCommand, "ContextTypeId", DbType.Int32, (int)contextType); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { Comment entity = new Comment(); Utility.Generic.AssignDataReaderToEntity(dataReader, entity); returnEntityCollection.Add(entity); } } return(returnEntityCollection); }