Esempio n. 1
0
        /// <summary>
        /// Возвращает представление для создания и редактирования отзыва
        /// </summary>
        /// <param name="id">Id существующего отзыва для редактирования</param>
        /// <returns></returns>
        public async Task <ActionResult> StoreFeedback(Guid?id)
        {
            var model = new FeedbackStoreViewModel(_repository, _creator);
            await model.Initialize(id ?? Guid.Empty);

            return(View(model));
        }
Esempio n. 2
0
        public MockFeedbackStoreCommand()
        {
            Setup(p => p.LoadData(It.IsAny <FeedbackStoreViewModel>(), It.IsAny <string>())).Callback((FeedbackStoreViewModel model, string path) =>
            {
                _model = model;
            });

            Setup(p => p.Execute()).Returns(() => Task.FromResult(Execute()));
        }
Esempio n. 3
0
        public async Task <ActionResult> StoreFeedback(FeedbackStoreViewModel model)
        {
            if (!model.EditMode)
            {
                model.UserName = User.Identity.Name;
            }

            _storeCommand.LoadData(model, PathToUploadedFiles);
            await _storeCommand.Execute();

            return(RedirectToAction("ViewFeedbacks", "Admin"));
        }
        public void Execute_Test()
        {
            var command = DependencyResolver.Current.GetService <FeedbackStoreCommand>();

            Guid   id   = Guid.NewGuid();
            string user = "******";
            string text = "test-text";

            var model = new FeedbackStoreViewModel
            {
                Id         = id,
                CategoryId = Guid.Empty,
                UserName   = user,
                Text       = text
            };

            command.LoadData(model, string.Empty);
            command.Execute();
            var lastAdded = MockFeedbackRepository.Feedbacks.Last();

            Assert.AreEqual(id, lastAdded.Id);
            Assert.AreEqual(user, lastAdded.UserName);
            Assert.AreEqual(text, lastAdded.Text);
        }
 public void LoadData(FeedbackStoreViewModel model, string path)
 {
     _model = model;
     _path  = path;
 }