コード例 #1
0
        public void TestProjectAPI_EditProjects_ShouldUpdatedMultipleProjectAtOnces()
        {
            SetupProjectAPIForTesting();

            ProjectsGridViewModel model        = new ProjectsGridViewModel();
            ProjectModel          projectModel = projectService.GetProjectModel(user, projectId).Model as ProjectModel;

            ProjectViewModel projectVM     = MapToProjectViewModel(projectModel);
            string           _originalName = projectVM.Name;

            projectVM.Name = "Test1234"; //change project Name for testing

            model.Items.Add(projectVM);

            serviceResponse = projectApi.EditProjects(model);

            Assert.That(serviceResponse.HasError, Is.EqualTo(false));
            ProjectsGridViewModel projectsGridViewModel = serviceResponse.Model as ProjectsGridViewModel;

            Assert.That(projectsGridViewModel, Is.Not.EqualTo(null));
            Assert.That(projectsGridViewModel.Items.Count, Is.GreaterThan(0));
            Assert.That(projectsGridViewModel.Items.Any(p => p.Name.Contains("Test1234")), Is.EqualTo(true));

            model.Items.Clear();
            projectVM.Name = _originalName; //roll back original project Name so the project will be restore to original value.
            model.Items.Add(projectVM);

            serviceResponse = projectApi.EditProjects(model);
            Assert.That(projectsGridViewModel.Items.Any(p => p.Name.Contains(_originalName)), Is.EqualTo(true));
        }
コード例 #2
0
        public void TestProjectApi_GetProjects_ShouldReturnProjectsBasedOnQueryInfo()
        {
            SetupProjectAPIForTesting();

            ProjectsGridViewModel model     = new ProjectsGridViewModel();
            ProjectsGridQueryInfo queryInfo = new ProjectsGridQueryInfo();

            Sort sort = new Sort();

            sort.Field = "biddate";
            queryInfo.Sort.Add(sort);

            serviceResponse = projectApi.GetProjects(queryInfo);

            Assert.That(serviceResponse, Is.Not.EqualTo(null));
            Assert.That(serviceResponse.Model, Is.Not.EqualTo(null));
            Assert.IsInstanceOf <ProjectsGridViewModel>(serviceResponse.Model);

            model = serviceResponse.Model as ProjectsGridViewModel;
            int projectCount = this.db.Projects.Where(p => p.OwnerId == user.UserId &&
                                                      p.ProjectStatusTypeId == ProjectStatusTypeEnum.Open &&
                                                      p.Deleted == false && p.ActiveVersion == 1).Count();

            Assert.That(model.Items.Count, Is.GreaterThanOrEqualTo(projectCount));
        }
コード例 #3
0
        public ServiceResponse GetProjects(ProjectsGridQueryInfo queryInfo)
        {
            ProjectsGridViewModel model = new ProjectsGridViewModel();

            if (queryInfo.Filter != null && queryInfo.Filter.Filters.Find(x => x.Field == "alert") != null && queryInfo.Filter.Filters.Find(x => x.Field == "expirationDays") != null)
            {
                model.ExpirationDays = Int32.Parse(queryInfo.Filter.Filters.Find(x => x.Field == "expirationDays").Value);
            }

            return(projectService.GetAllProjects(CurrentUser, model, queryInfo));
        }
コード例 #4
0
        public void RulesOnValidateModel(ProjectsGridViewModel model)
        {
            if (model == null || model.Items == null || model.Items.Count == 0)
            {
                return;
            }

            foreach (var project in model.Items)
            {
                Validation.IsDateSet(this.Response.Messages, project.BidDate, "BidDate", "Bid Date");
                Validation.IsDateSet(this.Response.Messages, project.EstimatedClose, "EstimatedClose", "Estimated Close");
                Validation.IsDateSet(this.Response.Messages, project.EstimatedDelivery, "EstimatedDelivery", "Estimated Delivery");

                // TODO:  Cleanup all these casts
                Validation.IsDropDownSet(this.Response.Messages, (int)project.ProjectStatusId, "ProjectStatusId", "Project Status");
                Validation.IsDropDownSet(this.Response.Messages, project.ProjectTypeId, "ProjectTypeId", "Project Type");
                Validation.IsDropDownSet(this.Response.Messages, project.ProjectOpenStatusId, "ProjectOpenStatusId", "Project Open Status");
            }
        }
コード例 #5
0
        public IEnumerable <ProjectsGridViewModel> MappingDataToProjectsGrid(IEnumerable <ProjectGridEntity> grid)
        {
            var list = new List <ProjectsGridViewModel>();

            if (grid != null)
            {
                foreach (var item in grid)
                {
                    ProjectsGridViewModel project;

                    if (list.Any(a => a.ID == item.ID))
                    {
                        project = list.Find(a => a.ID == item.ID);
                    }
                    else
                    {
                        project = new ProjectsGridViewModel
                        {
                            ID           = item.ID,
                            Title        = item.Title,
                            Description  = item.Description,
                            NewMembers   = item.NewMembers,
                            Technologies = new List <TechnologyViewModel>()
                        };
                        list.Add(project);
                    }
                    if (item.TechnologyId != 0)
                    {
                        project.Technologies.Add(new TechnologyViewModel
                        {
                            TechName = item.TechName,
                            Id       = item.TechnologyId
                        });
                    }
                }
            }

            return(list);
        }
コード例 #6
0
 public ServiceResponse EditProjects(ProjectsGridViewModel model)
 {
     return(projectService.PostModel(this.CurrentUser, model));
 }