Exemple #1
0
        public void ResponsedOnProject(InvestorResponse response)
        {
            if (_currentProject == null)
            {
                throw new ArgumentNullException("Проект не найден");
            }

            if (_workflow.IsMoveablde(ProjectWorkflow.Trigger.InvestorResponsed))
            {
                if (_currentProject.Responses == null ||
                    !_currentProject.Responses.Any() ||
                    _currentProject.WorkflowState.CurrentState == ProjectWorkflow.State.OnMap)
                {
                    _currentProject.Responses = new List <InvestorResponse>();
                }

                _currentProject.Responses.Add(response);
                _repository.Update(_currentProject);

                if (!_workflow.Move(ProjectWorkflow.Trigger.InvestorResponsed))
                {
                    throw new InvalidOperationException("Не могу осуществить операцию InvestorResponsed");
                }
            }
            else
            {
                throw new InvalidOperationException("Не могу осуществить операцию InvestorResponsed");
            }
        }
 public ActionResult NewResponseToProject(InvestorResponse model)
 {
     if (ModelState.IsValid)
     {
         ProjectStateManager.StateManagerFactory(model.ProjectId, null, null).ResponsedOnProject(model);
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
        public ActionResult NewResponseToProject(string id)
        {
            var project = RepositoryContext.Current.GetOne <Project>(pr => pr._id == id);

            if (project != null)
            {
                var responseViewModel = new InvestorResponse();
                responseViewModel.ProjectId    = id;
                responseViewModel.ResponseId   = ObjectId.GenerateNewId().ToString();
                responseViewModel.ResponseDate = DateTime.Now;
                return(PartialView(responseViewModel));
            }
            return(HttpNotFound("Проект не найден, свяжитесь с администратором"));
        }
Exemple #4
0
        public ActionResult SelectUser(string projectId, string responseId)
        {
            var project = RepositoryContext.Current.GetOne <Project>(p => p._id == projectId);
            IEnumerable <InvestorResponse> prevResponses = project.Responses.Where(r => r.IsVerified);

            foreach (var prevResponse in prevResponses)
            {
                prevResponse.IsVerified = false;
            }
            InvestorResponse response = project.Responses.Find(r => r.ResponseId == responseId);

            response.IsVerified = true;
            RepositoryContext.Current.Update(project);

            return(RedirectToAction("Project", "BaseProject", new { id = projectId }));
        }
        public async Task GetByIdAsyncWhenNoInvestorFoundReturnsInvestorNotFoundResponse()
        {
            // Arrange
            var mockInvestorRepository = GetDefaultIInvestorRepositoryInstance();
            var mockUnitOfWork         = GetDefaultIUnitOfWorkInstance();
            var investorId             = 1;

            mockInvestorRepository.Setup(r => r.FindById(investorId))
            .Returns(Task.FromResult <Investor>(null));

            var service = new InvestorService(mockInvestorRepository.Object, mockUnitOfWork.Object);

            // Act
            InvestorResponse result = await service.GetByIdAsync(investorId);

            var message = result.Message;

            // Assert
            message.Should().Be("Investor not found");
        }