public void Can_Add_Project()
        {
            //Arrange

            IProjectRepository _repo = new ProjectRepository(context);
            var newProject           = new Project
            {
                Id          = 5,
                Information = new ClientInformation {
                    ContactData = "contactData5"
                },
                Name = "name5"
            };

            //Act

            _repo.Add(newProject);
            var datas = _repo.GetAll().Last();

            //Assert

            Assert.True(newProject.Information.ContactData == datas.Information.ContactData);
            Assert.True(newProject.Name == datas.Name);
            Assert.True(context.Set <Project>().Count() == 5);
        }
Esempio n. 2
0
        public async Task <ActionResult> Create(ProjectView view)
        {
            ProjectRepository projectRepo;
            CodeRepository    codeRepo;

            try
            {
                using (DBConnection dbc = new DBConnection(settings.Database.ConnectionString, logger))
                {
                    codeRepo = new CodeRepository(settings, logger, dbc);

                    if (ModelState.IsValid)
                    {
                        projectRepo = new ProjectRepository(settings, logger, dbc);

                        await projectRepo.Add(view.Project);

                        return(RedirectToAction("Index", "Project"));
                    }

                    // Only get here if couldn't add project and all tasks
                    view.ProjectTypes = (await codeRepo.FindAllByCategory(CodeCategory.PROJECT_TYPE)).ToList();
                    view.StatusTypes  = (await codeRepo.FindAllByCategory(CodeCategory.STATUS)).ToList();
                    return(View("Create", view));
                }
            }
            catch (Exception ex)
            {
                throw (Exception)Activator.CreateInstance(ex.GetType(), ex.Message + ex.StackTrace);
            }
        }
Esempio n. 3
0
        public void CreateSampleOrganizationAndProject(string userId)
        {
            if (_projectRepository.GetByApiKey(SAMPLE_API_KEY) != null)
            {
                return;
            }

            User user         = _userRepository.GetByIdCached(userId);
            var  organization = new Organization {
                Name = "Acme"
            };

            _billingManager.ApplyBillingPlan(organization, BillingManager.UnlimitedPlan, user);
            organization = _organizationRepository.Add(organization);

            var project = new Project {
                Name = "Disintegrating Pistol", TimeZone = TimeZone.CurrentTimeZone.StandardName, OrganizationId = organization.Id
            };

            project.NextSummaryEndOfDayTicks = TimeZoneInfo.ConvertTime(DateTime.Today.AddDays(1), project.DefaultTimeZone()).ToUniversalTime().Ticks;
            project.ApiKeys.Add(SAMPLE_API_KEY);
            project.Configuration.Settings.Add("IncludeConditionalData", "true");
            project.AddDefaultOwnerNotificationSettings(userId);
            project = _projectRepository.Add(project);

            _organizationRepository.IncrementStats(project.OrganizationId, projectCount: 1);

            user.OrganizationIds.Add(organization.Id);
            _userRepository.Update(user);
        }
Esempio n. 4
0
        public void TestAddItemWithRelationships()
        {
            ContactInformation contactInformation = new ContactInformation()
            {
                Phone = "phone", Email = "*****@*****.**"
            };
            Customer customer = new Customer()
            {
                Name = "Customer", ContactInformation = contactInformation
            };
            Resource r = new Resource()
            {
                ContactInformation = contactInformation, Name = "Demo"
            };
            ProjectDetail projectDetail = new ProjectDetail()
            {
                Budget = 1000, Critical = true
            };
            Project p = new Project()
            {
                Customer = customer, Name = "Project", Description = "Description", End = DateTime.Now.AddDays(1), ProjectDetail = projectDetail, Start = DateTime.Now
            };


            projectRepository.Add(p);
            projectRepository.UnitOfWork.Commit();


            p.ProjectId.Should().NotBe(0, "User id is zero.");
            p.ProjectDetail.Project.Should().Be(p);
            p.Customer.CustomerId.Should().NotBe(0, "Customer id is zero.");
        }
        public void AddNewProject_Success()
        {
            var sut = new ProjectRepository();

            var newProjectId = Guid.NewGuid();

            var newProject = new Project
            {
                Id           = newProjectId,
                Client       = "KMS",
                DepartmentId = Guid.Parse("bbe8cb8d-4248-4dc2-b5d3-ead7aa783b08"),
                Description  = "Desc",
                Name         = "KMS Staffing",
                Status       = 1,
                TeamSize     = 3
            };

            var result = sut.Add(newProject);

            Assert.Equal(1, result);

            var savedProject = sut.FindById(newProjectId);

            Assert.Equal("KMS Staffing", savedProject.Name);

            sut.Delete(newProjectId);
        }
        public void User_Can_Add_Project()
        {
            // Get a userId
            int userId = 1;

            // Create a new project
            Project project = new Project()
            {
                UserId       = 1,
                Name         = "Check out this sweeeeeet new project!",
                CreationDate = DateTime.Now - TimeSpan.FromDays(10)
            };

            // Instantiate ProjectRepo
            var repo = new ProjectRepository(_context);

            // Add project
            repo.Add(project);

            // Get new count of all projects
            var count = repo.Get(userId).Count;

            // User with Id 1 should have 3
            Assert.True(count == 3);
        }
        public void Check_DomainEvents_ActivityAdded_Raise()
        {
            //given

            //existing project
            var project = Project.From(EntityId.From(1u), Description.From("descriptionText"));

            //a activity it is attached to it
            var activity = Activity.From(Description.From("activity to do"), EntityId.From(1u),
                                         EntityId.From(1u), ActivityStatus.From(1));

            var projectOptionsBuilder = new DbContextOptionsBuilder <ProjectDbContext>();

            projectOptionsBuilder.UseSqlite("Data Source=todoagility_proj_activity_reference.db;");
            var projectDbContext = new ProjectDbContext(projectOptionsBuilder.Options);
            var repProject       = new ProjectRepository(projectDbContext);

            using var projectDbSession = new DbSession <IProjectRepository>(projectDbContext, repProject);
            repProject.Add(project);
            projectDbSession.SaveChanges();
            var handlerActivityAdded = new ActivityAddedHandler(projectDbSession);
            var dispatcher           = new DomainEventDispatcher();

            dispatcher.Subscribe(typeof(ActivityAddedEvent).FullName, handlerActivityAdded);

            //when
            dispatcher.Publish(ActivityAddedEvent.For(activity));

            //then
            var proj = repProject.Get(EntityId.From(1u));

            Assert.True(proj.Activities.Count > 0);
        }
Esempio n. 8
0
        public void AddNewProject(NewProjectDTO newProject)
        {
            var project = new Project()
            {
                Title        = newProject.Title,
                Description  = newProject.Description,
                Budget       = newProject.Budget,
                EstStart     = newProject.EstStart,
                EstCompleted = newProject.EstCompleted,
                Client       = new Client()
                {
                    Name         = newProject.Client.Name,
                    PhoneNumber  = newProject.Client.PhoneNumber,
                    PhoneNumber2 = newProject.Client.PhoneNumber2,
                    Email        = newProject.Client.Email,
                    Description  = newProject.Client.Description,
                    Location     = new Location()
                    {
                        Street1 = newProject.Client.Location.Street1,
                        Street2 = newProject.Client.Location.Street2,
                        City    = newProject.Client.Location.City,
                        State   = newProject.Client.Location.State,
                        Country = newProject.Client.Location.Country
                    }
                },
            };

            _projectRepo.Add(project);
            _projectRepo.SaveChanges();
        }
Esempio n. 9
0
        private void ProjectAddNewSaveClick(object sender, EventArgs e)
        {
            if (projectSelectEmployeesComboBox.Items.Count == EmployeeRepository.Employees.Count)
            {
                var errorForm = new ErrorForm("There must be at least one employee in project.");
                errorForm.ShowDialog();
                return;
            }

            Project.Name      = newProjectNameTextBox.Text;
            Project.StartDate = newProjectStartDateDatePicker.Value;
            Project.EndDate   = newProjectEndDateDatePicker.Value;
            if (string.IsNullOrEmpty(Project.Name))
            {
                var errorForm = new ErrorForm("Please fill all boxes.");
                errorForm.ShowDialog();
                return;
            }

            var result = ProjectRepository.Add(Project, EmployeeRepository, EmployeeWithWorkHoursList);

            if (result != null)
            {
                var errorForm = new ErrorForm(result);
                errorForm.ShowDialog();
                return;
            }


            Close();
        }
 public static void SaveProject(Project project)
 {
     using (ProjectRepository repository = new ProjectRepository())
     {
         repository.Add(project);
         repository.Commit();
     }
 }
Esempio n. 11
0
        public void notify_that_project_was_not_found_when_trying_to_add_an_task_to_nonexistent_project()
        {
            var projectRepository = new ProjectRepository();
            projectRepository.Add(new Project("training"));

            _addTaskCommand.Execute();

            _console.Received().WriteLine("Could not find a project with the name \"{0}\".", "secrets");
        }
        public IActionResult Post(Project project)
        {
            var currentUser = GetCurrentUserProfile();

            project.UserProfileId = currentUser.Id;
            project.DateCreated   = DateTime.Now;
            _projectRepository.Add(project);
            return(CreatedAtAction("Get", new { id = project.Id }, project));
        }
Esempio n. 13
0
        public Project Add(Project project)
        {
            var projectsType     = projectTypeRepository.GetAll();
            var exactProjectType = projectsType.First(x => x.ProjectTypeId == project.ProjectType.ProjectTypeId);

            project.ProjectType = exactProjectType;

            return(projectRepository.Add(project));
        }
        private static Project SeedProject(PreservationContext dbContext, string plant)
        {
            var projectRepository = new ProjectRepository(dbContext);
            var project           = new Project(plant, KnownTestData.ProjectName, KnownTestData.ProjectDescription);

            projectRepository.Add(project);
            dbContext.SaveChangesAsync().Wait();
            return(project);
        }
Esempio n. 15
0
        public RedirectToActionResult CreateProject(Project project)
        {
            Project           newProject    = _projectRepository.Add(project);
            ProjectAssignment newAssignment = new ProjectAssignment {
                ProjectId = newProject.ProjectId, UsersId = userManager.GetUserId(HttpContext.User)
            };

            _projectRepository.Assign(newAssignment);
            return(RedirectToAction("projectdetails", new { id = newProject.ProjectId }));
        }
        public void Add(ProjectViewModels client)
        {
            Project project = new Project();

            project.Project_ID = Guid.NewGuid();

            Repository.Add(Mapper.ModelToData(project, client));

            Repository.save();
        }
Esempio n. 17
0
        public void ReadNewProjectFormularData(object sender, EventArgs e)
        {
            Project newProject = (Project)sender;

            if (ProjectRepo != null)
            {
                ProjectRepo.Add(newProject);
                ProjectList.Add(newProject);
                FillListBoxProject();
            }
        }
Esempio n. 18
0
 public bool AddProject(Project proj)
 {
     try
     {
         return(ProjectRepo.Add(proj));
     }
     catch (ProjectManagerException e)
     {
         throw e;
     }
 }
Esempio n. 19
0
        public void Should_add_project()
        {
            var project = CreateProject();

            _repository.Add(project);

            var projects = _projectQuery.Where(p => p.Name == TestName).ToList();

            Assert.GreaterOrEqual(projects.Count, 1);
            Assert.AreEqual(projects[0].Identify, TestIdentify);
        }
        public void ProjectExists_WhenExists_ReturnTrue()
        {
            var project = new Project {
                Id = Guid.NewGuid().ToString(), Name = "SomeName"
            };

            _repo.Add(project);
            var projectExists = _repo.ProjectExists();

            Assert.True(projectExists);
        }
 public IActionResult Create([Bind("Name")] Project project)
 {
     if (ModelState.IsValid)
     {
         projectRepository.Add(project);
         projectRepository.Save();
         return(RedirectToAction(nameof(Index)));
     }
     log.Debug("Invalid state");
     return(View(project));
 }
        public static int AskForTheProject()
        {
            ProjectRepository projectRepository = new ProjectRepository();

            Project project = new Project();
            project.name = projectName;
            project.deadLine = DateTime.Now.Add(TimeSpan.Parse(periodOfExecution));

            projectRepository.Add(project);

            return projectRepository.GetAll().Last().id;
        }
 public void Can_saveproject()
 {
     try
     {
         var newProject = new Project("Word", "Some Word-Processes are defined in this project");
         repo.Add(newProject);
     }
     catch (Exception e)
     {
         Console.WriteLine("Project still in DB");
     }
 }
Esempio n. 24
0
        public void Add()
        {
            const int expectedCount = projectCount + 1;
            var       project       = new Project {
                Name = "NewProject"
            };
            var repo = new ProjectRepository(_context);

            repo.Add(project);
            var res = repo.GetAll();

            Assert.Equal(expectedCount, res.Count());
        }
Esempio n. 25
0
        public static int AskForTheProject()
        {
            ProjectRepository projectRepository = new ProjectRepository();

            Project project = new Project();

            project.name     = projectName;
            project.deadLine = DateTime.Now.Add(TimeSpan.Parse(periodOfExecution));

            projectRepository.Add(project);

            return(projectRepository.GetAll().Last().id);
        }
Esempio n. 26
0
        public async Task SaveProjectDataAsync(string color)
        {
            // validate address

            APIAddressResource selectedAddressResource = null;

            this.Color = color;
            try
            {
                Address newAddress = new Address();
                newAddress.Address1   = this.Address1;
                newAddress.Address2   = this.Address2;
                newAddress.City       = this.City;
                newAddress.Province   = this.State;
                newAddress.PostalCode = this.Zip;

                APIAddressResource apiAddress = await AddressService.ReturnValidatedAddress(newAddress);

                if (apiAddress.address != null)
                {
                    selectedAddressResource = apiAddress;
                }
                else
                {
                    throw new InvalidAddressException();
                }
            }
            catch (Exception ex)
            {
                throw new InvalidAddressException();
            }

            Project newProject = new Project
            {
                Color       = this.Color,
                Address1    = this.Address1,
                Address2    = this.Address2,
                City        = this.City,
                State       = this.State,
                Description = this.Description,
                Name        = this.Name,
                Latitude    = 0,
                Longitude   = 0,
                Zip         = this.Zip
            };

            newProject.Latitude  = Convert.ToDecimal(selectedAddressResource.point.coordinates[0]);
            newProject.Longitude = Convert.ToDecimal(selectedAddressResource.point.coordinates[1].ToString());

            await projectRepository.Add(newProject);
        }
        public void ProjectRepositoryTest()
        {
            ProjectRepository repository = new ProjectRepository();
            DateTime time = DateTime.MinValue;
            Project expectedProject = new Project(repository.GetAll().Count() + 1, "projectsomeproject", time);

            repository.Add(expectedProject);

            Project realProject = repository.GetItem(expectedProject.id);

            Assert.AreEqual(expectedProject, realProject);

            repository.Delete(expectedProject);

            realProject = repository.GetItem(expectedProject.id);

            Assert.AreEqual(null, realProject);
        }
Esempio n. 28
0
 public IHttpActionResult AddProject([FromBody] Project project)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest("Missing data for creating the project"));
         }
         var date = DateTime.Now;
         project.Created = date;
         project.Update  = date;
         _projectRepo.Add(project);
         return(Ok("Project was created successfully"));
     }
     catch
     {
         return(Json(new { error = "Occurred an error while add the project" }));
     }
 }
Esempio n. 29
0
        public async Task <ActionResult <Project> > PostProject(ProjectViewModel projViewModel)
        {
            Project proj = new Project(projViewModel);
            await _projectRepository.Add(proj);

            Project thisProj = await(_projectRepository).GetProjectByCode(projViewModel.ProjectCode);
            int     projId   = thisProj.ProjectId;

            EmployeeProjectAssignment supProjectAssignment = new EmployeeProjectAssignment(projViewModel.ProjectManager.EmployeeId,
                                                                                           projId, true);
            await _employeeProjectAssignmentRepository.Add(supProjectAssignment);

            foreach (EmployeeNameViewModel emp in projViewModel.Employees)
            {
                EmployeeProjectAssignment empProjAssignment = new EmployeeProjectAssignment(emp.EmployeeId, projId, false);
                await _employeeProjectAssignmentRepository.Add(empProjAssignment);
            }

            return(Ok(projViewModel));
        }
Esempio n. 30
0
        public void ProjectRepositoryTest()
        {
            ProjectRepository repository      = new ProjectRepository();
            DateTime          time            = DateTime.MinValue;
            Project           expectedProject = new Project(repository.GetAll().Count() + 1, "projectsomeproject", time);

            repository.Add(expectedProject);


            Project realProject = repository.GetItem(expectedProject.id);

            Assert.AreEqual(expectedProject, realProject);

            repository.Delete(expectedProject);


            realProject = repository.GetItem(expectedProject.id);

            Assert.AreEqual(null, realProject);
        }
        public void TestAddMethod()
        {
            //
            // Functional Test against Azure Emulator
            //

            CloudStorageAccount cloudStorageAccount = CloudStorageAccount.DevelopmentStorageAccount;
            CloudTableClient tableClient = cloudStorageAccount.CreateCloudTableClient();

            InsertStorageConfiguration(tableClient);
            InsertStorageState(tableClient);
            InsertUserAttributes(tableClient);

            var projectRepository = new ProjectRepository(cloudStorageAccount, ProjectRepositoryTestConfig.StorageVersion);
            projectRepository.Add(ProjectRepositoryTestConfig.UserName,
                                  ProjectRepositoryTestConfig.ProjectName,
                                  ProjectRepositoryTestConfig.LocalVideoUri,
                                  ProjectRepositoryTestConfig.LocalDataUri,
                                  ProjectRepositoryTestConfig.VideoFileName,
                                  ProjectRepositoryTestConfig.DataFileName);
        }
        public void User_Can_Delete_Project_Without_Any_Other_Linking_Data()
        {
            // Get an object that's in the database
            var projectToAdd = new Project()
            {
                UserId       = 1,
                Name         = "New Project to Axe",
                CreationDate = DateTime.Now - TimeSpan.FromDays(15)
            };

            var projectDetails = new ProjectDetailsViewModel
            {
                Project            = projectToAdd,
                ProjectCollections = new List <ProjectCollection>()
            };

            // Instantiate ProjectRepo
            var repo = new ProjectRepository(_context);

            // Get a count of Projects for UserId 1
            var count = repo.Get(1).Count;

            // Add new project
            repo.Add(projectToAdd);

            // Get a new count
            var countAfterAdd = repo.Get(1).Count;

            // Attempt to delete the project
            repo.Delete(projectDetails);

            // New count after deleting
            var countAfterDeletion = repo.Get(1).Count;

            // We successfully added one project
            Assert.True(count < countAfterAdd);
            // We successfully deleted one project
            Assert.True(count == countAfterDeletion);
        }
        public void TestAddMethod()
        {
            //
            // Functional Test against Azure Emulator
            //

            CloudStorageAccount cloudStorageAccount = CloudStorageAccount.DevelopmentStorageAccount;
            CloudTableClient    tableClient         = cloudStorageAccount.CreateCloudTableClient();

            InsertStorageConfiguration(tableClient);
            InsertStorageState(tableClient);
            InsertUserAttributes(tableClient);

            var projectRepository = new ProjectRepository(cloudStorageAccount, ProjectRepositoryTestConfig.StorageVersion);

            projectRepository.Add(ProjectRepositoryTestConfig.UserName,
                                  ProjectRepositoryTestConfig.ProjectName,
                                  ProjectRepositoryTestConfig.LocalVideoUri,
                                  ProjectRepositoryTestConfig.LocalDataUri,
                                  ProjectRepositoryTestConfig.VideoFileName,
                                  ProjectRepositoryTestConfig.DataFileName);
        }
        public void ProjectRepositoryTest()
        {
            ProjectRepository repository      = new ProjectRepository();
            DateTime          time            = DateTime.MinValue;
            Project           expectedProject = new Project {
                name = "projectsomeproject", deadLine = time
            };

            repository.Add(expectedProject);


            Project realProject = repository.GetAll().Last();

            Assert.AreEqual(expectedProject.name, realProject.name);
            Assert.AreEqual(expectedProject.deadLine, realProject.deadLine);

            repository.Delete(realProject);


            realProject = repository.GetAll().Last();

            Assert.AreNotEqual(expectedProject.name, realProject.name);
            Assert.AreNotEqual(expectedProject.deadLine, realProject.deadLine);
        }
        public void ProjectRepositoryTest()
        {
            ProjectRepository repository = new ProjectRepository();
            DateTime time = DateTime.MinValue;
            Project expectedProject = new Project { name = "projectsomeproject", deadLine = time };

            repository.Add(expectedProject);

            Project realProject = repository.GetAll().Last();

            Assert.AreEqual(expectedProject.name, realProject.name);
            Assert.AreEqual(expectedProject.deadLine, realProject.deadLine);

            repository.Delete(realProject);

            realProject = repository.GetAll().Last();

            Assert.AreNotEqual(expectedProject.name, realProject.name);
            Assert.AreNotEqual(expectedProject.deadLine, realProject.deadLine);
        }