Exemplo n.º 1
0
        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;
            }
        }
Exemplo n.º 2
0
        public bool Delete(Comment comment, Database db, DbTransaction transaction)
        {
            DbCommand command = db.GetStoredProcCommand("usp_CommentDelete");

            db.AddInParameter(command, "CommentId", DbType.Int32, comment.CommentId);
            db.AddInParameter(command, "UpdatedBy", DbType.Guid, comment.UpdatedBy);

            if (transaction == null)
            {
                db.ExecuteNonQuery(command);
            }
            else
            {
                db.ExecuteNonQuery(command, transaction);
            }

            return true;
        }
Exemplo n.º 3
0
        public static List<Comment> SelectCommentListByContext(int contextTypeId, Guid contextId)
        {
            List<Comment> commentsList = new List<Comment>();

            Database db = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING);
            DbCommand command = db.GetStoredProcCommand("usp_CommentSelectAllByContextId");
            db.AddInParameter(command, "ContextTypeId", DbType.Int32, contextTypeId);
            db.AddInParameter(command, "ContextId", DbType.Guid, contextId);

            using (IDataReader dataReader = db.ExecuteReader(command))
            {
                while(dataReader.Read())
                {
                    Comment entity = new Comment();
                    Generic.AssignDataReaderToEntity(dataReader, entity);
                    commentsList.Add(entity);
                }
            }

            return commentsList;
        }
        public decimal CalculateReting(Comment comment)
        {
            comment.FeedbackQuestions = comment.SelectFeedbackQuestions();

            comment.FeedbackQuestions.Find(a => a.QuestionId == 1).RatingValue = ASPxRatingpayment.Value;
            comment.FeedbackQuestions.Find(a => a.QuestionId == 2).RatingValue = ASPxRatingcleanliness.Value;
            comment.FeedbackQuestions.Find(a => a.QuestionId == 3).RatingValue = ASPxRatingcondition.Value;
            comment.FeedbackQuestions.Find(a => a.QuestionId == 4).RatingValue = ASPxRatingresponsiveness.Value;
            comment.FeedbackQuestions.Find(a => a.QuestionId == 5).RatingValue = ASPxRatingfriendliness.Value;
            comment.FeedbackQuestions.Find(a => a.QuestionId == 6).RatingValue = ASPxRatingresponsible.Value;
            comment.FeedbackQuestions.Find(a => a.QuestionId == 7).RatingValue = ASPxRatinggoodroommate.Value;

            decimal ratevalue = 0;

            //Rating system for the Students by other roommates
            ratevalue = comment.CalculateFeedbackByUserRole(user.RoleId == Constants.USER_ROLE_LANDLORD ? Enums.UserRoles.Landlord : Enums.UserRoles.Student);

            //decimal finalrating = ratevalue / 6;

            return ratevalue;
        }
Exemplo n.º 5
0
        /// <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;
        }
Exemplo n.º 6
0
        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;
        }
Exemplo n.º 7
0
        public bool Insert(Comment comment, Database db, DbTransaction transaction)
        {
            DbCommand command = db.GetStoredProcCommand("usp_CommentInsert");
            //comment.CommentId = Guid.NewGuid();
              //  db.AddInParameter(command, "CommentId", DbType.Guid, comment.CommentId);
            db.AddInParameter(command, "CommentText", DbType.String, comment.CommentText);
            db.AddInParameter(command, "RatingValue", DbType.Decimal, comment.RatingValue);
            db.AddInParameter(command, "ContextId", DbType.Guid, comment.ContextId);
            db.AddInParameter(command, "ContextTypeId", DbType.Int32, (int)comment.ContextType);
            db.AddInParameter(command, "CommentTypeId", DbType.Int32, (int)comment.CommentType);
            db.AddInParameter(command, "FilePath", DbType.String, comment.FilePath);

            db.AddInParameter(command, "IsDeleted", DbType.String, comment.IsDeleted);
            db.AddInParameter(command, "CreatedBy", DbType.Guid, comment.CreatedBy);
            db.AddOutParameter(command, "CreatedDate", DbType.DateTime, 30);

            if (transaction == null)
            {
                db.ExecuteNonQuery(command);
            }
            else
            {
                db.ExecuteNonQuery(command, transaction);
            }

            comment.CreatedDate = Convert.ToDateTime(db.GetParameterValue(command, "CreatedDate").ToString());
            comment.UpdatedDate = comment.CreatedDate;

            return true;
        }