public void Should_Return_ContentFirst_When_Feedback_Submitted()
        {
            // Arrange
            var vm = new FeedbackViewModel
                { Email = "*****@*****.**", SelectedValue = "1", Name = "PO", Text = "All good" };
            var zero = new FeedbackViewModel
                { Email = "*****@*****.**", SelectedValue = "0", Name = "PO", Text = "All good" };
            var second = new FeedbackViewModel
                { Email = "*****@*****.**", SelectedValue = "2", Name = "PO", Text = "All good" };
            var third = new FeedbackViewModel
                { Email = "*****@*****.**", SelectedValue = "3", Name = "PO", Text = "All good" };
            var fouth = new FeedbackViewModel { Email = "*****@*****.**", SelectedValue = "4", Name = "PO", Text = "All good" };

            // Act
            var result = this.feedbackController.FeedbackForm(vm);
            var resultZero = this.feedbackController.FeedbackForm(zero);
            var resultSecond = this.feedbackController.FeedbackForm(second);
            var resultThird = this.feedbackController.FeedbackForm(third);
            var resultFouth = this.feedbackController.FeedbackForm(fouth);

            int count = this.unitOfWork.FeedbackRepository.All().Count();

            // Assert
            Assert.IsNotNull(result, "Should have returned a ContentResult");
            Assert.AreEqual(8, count);
        }
        /// <summary>
        /// Verify the entered values for feedback
        /// </summary>
        /// <param name="feedbackViewModel"></param>
        /// <returns></returns>
        public ValidationResult FeedBackDataIsValid( FeedbackViewModel feedbackViewModel)
        {
            var fbm = (FeedbackViewModel)feedbackViewModel;

               /// Verify that the entered data is valid
               if(fbm.Text != string.Empty
                && (OnlyDigitsExist(fbm.SelectedValue.ToString()) && fbm.SelectedValue != null))
               return ValidationResult.Success;
               return new ValidationResult(Resources.Resources.ValidationFeedback);
        }
        public ContentResult FeedbackForm(FeedbackViewModel fvm)
        {
            var vsh = new ValidateServerHelper();
            ValidationResult validationResult = vsh.FeedBackDataIsValid(fvm);

            if (validationResult == ValidationResult.Success)
            {
                var feedback = new Feedback
                {
                    Email = fvm.Email,
                    Name = fvm.Name ?? "Anonymous",
                    Text = fvm.Text,
                    Type = int.Parse(fvm.SelectedValue)
                };

                this.feedbackRepository.Add(feedback);
                this.feedbackRepository.Save();
                switch (feedback.Type)
                {
                    case 0:
                        this.RedirectToAction("Index", "MakeRoute");
                        return
                            this.Content(
                                "<div class=\"greetings\" oncreate style=\"text-align:center; padding:20px;\">Спасибо, ваше мнение очень важно для нас. <a class='close' data-dismiss='modal'>×</a></div>",
                            "text/html");

                    case 1:
                        return
                            this.Content(
                                "<div class=\"greetings\" oncreate style=\"text-align:center; padding:20px;\">Спасибо, ваше предложение будет расмотрено. <a class='close' data-dismiss='modal'>×</a></div>",
                            "text/html");
                    case 2:
                        return
                            this.Content(
                                "<div class=\"greetings\" oncreate style=\"text-align:center; padding:20px;\">Спасибо, ошибка будет вскоре исправлена.<a class='close' data-dismiss='modal'>×</a></div>",
                            "text/html");
                    case 3:
                        return
                            this.Content(
                                "<div class=\"greetings\" oncreate style=\"text-align:center; padding:20px;\">Спасибо за проявленый интерес к нашему сайту. Мы вскоре свяжемся с вами. <a class='close' data-dismiss='modal'>×</a></div>",
                            "text/html");
                    default:
                        return
                            this.Content(
                                "<div class=\"greetings\" oncreate style=\"text-align:center; padding:20px;\" >Спасибо за ваш отзыв, он для нас очень важен. <a class='close' data-dismiss='modal'>×</a></div> ",
                            "text/html");
                }
            }
            else
                return
                    this.Content(
                        "<div class=\"greetings\" oncreate style=\"text-align:center\">" + validationResult.ErrorMessage
                        + "</div>",
                        "text/html");
        }
        public void CanValidateDataToFeedmackForm()
        {
            FeedbackViewModel feedbackViewModel = new FeedbackViewModel();

            feedbackViewModel.Email = "*****@*****.**";
            feedbackViewModel.Name = "Вася Пупкин";
            feedbackViewModel.Text = "Какой то текст";
            feedbackViewModel.SelectedValue = "1";

            // Create the instance of the ValidateServerHelper and compare the expected result with real one
            ValidateServerHelper validateServer = new ValidateServerHelper();
            // Verify that the entered data is valid
            ValidationResult vr = validateServer.FeedBackDataIsValid(feedbackViewModel);
            Assert.IsTrue(vr == ValidationResult.Success);
        }
        /// <summary>
        /// Feedbacks the form.
        /// </summary>
        /// <returns>
        /// feedback form
        /// </returns>
        public PartialViewResult FeedbackForm()
        {
            var feedBackModel = new FeedbackViewModel();
            var feedBackTypes = new List<SelectListItem>
                {
                    new SelectListItem { Text = "Мнение", Value = "0" },
                    new SelectListItem { Text = "Предложение", Value = "1" },
                    new SelectListItem { Text = "Ошибка", Value = "2" },
                    new SelectListItem { Text = "Партнерство", Value = "3" }
                };

            feedBackModel.Type = feedBackTypes;

            return this.PartialView("FeedbackForm", feedBackModel);
        }