Exemplo n.º 1
0
 public FeaturesController(FeaturesServices _featureService)
 {
     this._featureService = _featureService;
 }
        private void InitializeViews(int?feedback_id, string action, int?type)
        {
            Feedback feedback;
            Dictionary <int, object> featuresByType = new Dictionary <int, object>();
            Dictionary <int, string> features;
            SelectList options;
            SelectList typesList;

            if (feedback_id.HasValue)
            {
                feedback = feedbackService.GetById(feedback_id.Value);
                Dictionary <int, int> scoreByFeature = GenerateScoreByFeature(feedback);
                features          = new FeaturesServices().GetFeauresForDropDownList(feedback.FeedbackType_Id);
                options           = new SelectList(new ScoresServices().GetOptionsForDropDownList(), "Key", "Value");
                feedbackViewModel = new FeedbackViewModel(feedback, features, options, feedback.Scores.Count, scoreByFeature);
            }
            else
            {
                switch (action)
                {
                case "Send":
                    bool show = false;
                    if (type.HasValue)
                    {
                        if (type == 0)
                        {
                            show = true;
                        }
                    }
                    feedback = new Feedback();
                    if (type.HasValue)
                    {
                        features = new FeaturesServices().GetFeauresForDropDownList(type.Value);
                    }
                    else
                    {
                        features = new Dictionary <int, string>();
                    }
                    options           = new SelectList(new ScoresServices().GetOptionsForDropDownList(), "Key", "Value");
                    feedbackViewModel = new FeedbackViewModel(feedback, features, options, show);
                    break;

                case "Index":
                    if (type.HasValue)
                    {
                        typesList = new SelectList(new FeedbackTypesServices().GetFeedbackTypesForDropDownList(), "Key", "Value", type);
                    }
                    else
                    {
                        typesList = new SelectList(new FeedbackTypesServices().GetFeedbackTypesForDropDownList(), "Key", "Value");
                    }
                    feedbackViewModel = new FeedbackViewModel(typesList);
                    break;

                case "Show":
                    string typeName;
                    Dictionary <int, List <int> > scoreAverageByFeature;
                    options = new SelectList(new ScoresServices().GetAllOptionsForDropDownList(), "Key", "Value");
                    List <string> addCommentsStrings;
                    List <string> commentsStrings;
                    if (type.HasValue)
                    {
                        typeName              = new FeedbackTypesServices().GetById(type.Value).Name;
                        addCommentsStrings    = feedbackService.GetStringsByType("AddComments", type.Value);
                        commentsStrings       = feedbackService.GetStringsByType("Comments", type.Value);
                        scoreAverageByFeature = GenerateScoreAverageByFeature(type.Value);
                        features              = new FeaturesServices().GetFeauresForDropDownList(type.Value);
                        typesList             = new SelectList(new FeedbackTypesServices().GetFeedbackTypesForDropDownList(), "Key", "Value", type.Value);
                    }
                    else
                    {
                        typeName              = "";
                        addCommentsStrings    = new List <string>();
                        commentsStrings       = new List <string>();
                        scoreAverageByFeature = new Dictionary <int, List <int> >();
                        features              = new Dictionary <int, string>();
                        typesList             = new SelectList(new FeedbackTypesServices().GetFeedbackTypesForDropDownList(), "Key", "Value");
                    }
                    feedbackViewModel = new FeedbackViewModel(features, options, scoreAverageByFeature, addCommentsStrings, commentsStrings, typesList, typeName);
                    break;
                }
            }
        }
Exemplo n.º 3
0
 public FeaturesController()
 {
     _featureService = new FeaturesServices();
 }