public Collection <Feedback> ManagementGetFeedbacks()
        {
            var feedbacks = new ManagementTeam.Collection <ManagementTeam.Feedback>();

            feedbacks.Entities = new List <ManagementTeam.Feedback>();
            using (SqlConnection connection = new SqlConnection
                                                  (ConfigurationManager.ConnectionStrings["SQLProviderConnectionString"].ConnectionString))
            {
                var cmd = new SqlCommand("dbo.umsp_GetFeedbacks", connection);
                cmd.CommandType = CommandType.StoredProcedure;
                connection.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    //SELECT Id, EmployeeId, ReviewerId, WorkedTogether,
                    //WishToWorkTogether, PossitiveSide, NegativeSide, ThingsToImprove, Message
                    var feedback = new ManagementTeam.Feedback();
                    // TODO: modify sp, as information about employees maybe needed
                    feedback.Id                 = Int32.Parse(reader[0].ToString());
                    feedback.EmployeeId         = int.Parse(reader[1].ToString());
                    feedback.ReviewerId         = int.Parse(reader[2].ToString());
                    feedback.WorkedTogether     = Boolean.Parse(reader[3].ToString());
                    feedback.WishToWorkTogether = Boolean.Parse(reader[4].ToString());
                    feedback.PossitiveSide      = reader[5].ToString();
                    feedback.NegativeSide       = reader[6].ToString();
                    feedback.ThingsToImprove    = reader[7].ToString();
                    feedback.Message            = reader[8].ToString();

                    feedbacks.Entities.Add(feedback);
                }
            }
            return(feedbacks);
        }
        public EntityBase ManagementLeaveFeedback(ManagementTeam.Feedback feedback)
        {
            var resultEntityBase = new EntityBase();

            try
            {
                using (var connection = new SqlConnection
                                            (ConfigurationManager.ConnectionStrings["SQLProviderConnectionString"].ConnectionString))
                {
                    var command = new SqlCommand("umsp_LeaveFeedback", connection);
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@employeeId", feedback.EmployeeId);
                    command.Parameters.AddWithValue("@reviewerId", feedback.ReviewerId);
                    command.Parameters.AddWithValue("@workedTogether", feedback.WorkedTogether);
                    command.Parameters.AddWithValue("@wishToWorkTogether", feedback.WishToWorkTogether);
                    command.Parameters.AddWithValue("@possitiveSide", feedback.PossitiveSide);
                    command.Parameters.AddWithValue("@negativeSide", feedback.NegativeSide);
                    command.Parameters.AddWithValue("@thingsToImprove", feedback.ThingsToImprove);
                    command.Parameters.AddWithValue("@message", feedback.Message);

                    connection.Open();
                    command.ExecuteNonQuery();
                }
                resultEntityBase.StatusInfo = "Feedback was successfully submited";
            }
            catch (SqlException ex)
            {
                resultEntityBase.StatusInfo = ex.ToString() + "ERROR! Couldn't pass data to DB";
            }
            return(resultEntityBase);
        }
Exemple #3
0
        /// <summary>
        /// Casts Feedback entity to a Feedback Model
        /// </summary>
        /// <param name="feedback"></param>
        /// <returns></returns>
        internal FeedbackModel CastToFeedbackModel(ManagementTeam.Feedback feedback)
        {
            var feedbackModel = new FeedbackModel()
            {
                Id = feedback.Id,
                //Employee.Id = feedback.EmployeeId,
                //EmployeeId = feedback.EmployeeId,
                ReviewerId         = feedback.ReviewerId,
                WorkedTogether     = feedback.WorkedTogether,
                WishToWorkTogether = feedback.WishToWorkTogether,
                PossitiveSide      = feedback.PossitiveSide,
                NegativeSide       = feedback.NegativeSide,
                ThingsToImprove    = feedback.ThingsToImprove,
                Message            = feedback.Message
            };

            feedbackModel.Employee.Id = feedback.EmployeeId;
            return(feedbackModel);

            //return new FeedbackModel()
            //{
            //    Id = feedback.Id,
            //    EmployeeId = feedback.EmployeeId,
            //    ReviewerId = feedback.ReviewerId,
            //    WorkedTogether = feedback.WorkedTogether,
            //    WishToWorkTogether = feedback.WishToWorkTogether,
            //    PossitiveSide = feedback.PossitiveSide,
            //    NegativeSide = feedback.NegativeSide,
            //    ThingsToImprove = feedback.ThingsToImprove,
            //    Message = feedback.Message
            //};
        }