Пример #1
0
        public async Task <IActionResult> CreateProject([FromBody] ProjectResource projectResource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var project = mapper.Map <ProjectResource, Project> (projectResource);

            var major = await majorRepository.GetMajor(projectResource.MajorId);

            project.Major = major;

            var lecturer = await lecturerRepository.GetLecturer(projectResource.LecturerId);

            project.Lecturer = lecturer;

            projectRepository.AddProject(project);

            projectRepository.UpdateGroups(project, projectResource);
            projectRepository.UpdateTagProjects(project, projectResource);

            //Add categories into projects
            var categories = GetCategoriesFromDescription(projectResource.Description);
            await projectRepository.UpdateCategories(project, categories);

            await unitOfWork.Complete();

            project = await projectRepository.GetProject(project.ProjectId);

            var result = mapper.Map <Project, ProjectResource> (project);

            return(Ok(result));
        }
Пример #2
0
        public int AddProject(ProjectDTO dto)
        {
            int id = 0;

            try
            {
                log.Debug(ProjectDTO.FormatProjectDTO(dto));

                R_Project t = ProjectDTO.ConvertDTOtoEntity(dto);

                // add
                id            = Repository.AddProject(t);
                dto.ProjectId = id;

                log.Debug("result: 'success', id: " + id);
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }

            return(id);
        }
Пример #3
0
        public async Task <ActionResult> CreateProject([Bind(include: "IDCode, Name, Description, ProjectManagerUserID, AddUsers")] Project project)
        {
            if (ModelState.IsValid)
            {
                var userFromDb = await _userRepository.GetUser(project.ProjectManagerUserID);

                project.ProjectManagerUserID   = userFromDb.ID;
                project.ProjectManagerUserName = userFromDb.UserName;

                project.Created       = DateTime.UtcNow.ToString();
                project.Issues        = new List <string>();
                project.Updated       = project.Created;
                project.DeleteProject = false;


                await _projectRepository.AddProject(project);


                await UpdateProjectAssignment(project);



                TempData["Message"] = "User Createed Successfully";
            }
            return(RedirectToAction("Index", project));
        }
        public async Task <IActionResult> Create(SuObjectAndStatusViewModel FromForm)
        {
            if (ModelState.IsValid)
            {
                var Project = new SuProjectModel
                {
                    ModifiedDate    = DateTime.Now,
                    CreatedDate     = DateTime.Now,
                    ProjectStatusId = FromForm.SuObject.Status
                };
                if (FromForm.SuObject.NullId != 0)
                {
                    Project.ParentProjectId = FromForm.SuObject.NullId;
                }
                var NewProject = _Project.AddProject(Project);


                var CurrentUser = await _userManager.GetUserAsync(User);

                var ProjectLanguage = new SuProjectLanguageModel
                {
                    Name        = FromForm.SuObject.Name,
                    Description = FromForm.SuObject.Description,
                    MouseOver   = FromForm.SuObject.MouseOver,
                    ProjectId   = NewProject.Id,
                    LanguageId  = CurrentUser.DefaultLanguageId
                };
                _ProjectLanguage.AddProjectLanguage(ProjectLanguage);
            }
            return(RedirectToAction("Index"));
        }
        public IHttpActionResult SaveProject(Projects objProject)
        {
            Projects projectData = new Projects();

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                objProjectRepo.AddProject(objProject);
            }
            catch (DbUpdateException)
            {
                projectData = objProjectRepo.GetProjectById(objProject.ProjectID);

                if (projectData == null)
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(Ok(objProject.ProjectID));
        }
Пример #6
0
        public async Task <JsonResult> MaintainProject(int id, string projectName, string projectDesc)
        {
            try
            {
                var result   = false;
                var userName = _ssoUser.GetUserIdentity();
                var msg      = "操作成功";
                if (id > 0)
                {
                    _logRepository.Add($"修改项目", projectName, "", $"项目id:{id},项目:{projectName},项目描述:{projectDesc}");
                    result = await _projectRepository.UpdateProjectAsync(id, projectName, projectDesc);
                }
                else
                {
                    _logRepository.Add($"新增项目", projectName, "", $"项目:{projectName},项目描述:{projectDesc}");
                    result = _projectRepository.AddProject(projectName, projectDesc, userName);
                }
                if (!result)
                {
                    msg = "操作失败";
                }


                return(Json(new { success = result, msg }));
            }
            catch (Exception ex)
            {
                return(Json(new { success = false, msg = ex.ToString() }));
            }
        }
Пример #7
0
        public Project AddProject(Project project)
        {
            var projectDb       = ToProjectDb(project);
            var projectDbWithId = repository.AddProject(projectDb);

            return(ToProject(projectDbWithId));
        }
Пример #8
0
        public async Task AddProject(Project model, int resumeId)
        {
            var resume = await _resumeRepository.FindResume(resumeId);

            model.Resume = resume;

            await _projectRepository.AddProject(model);
        }
Пример #9
0
        public async Task <ActionResult> PostNewProject(ProjectInsertDTO project)
        {
            var projectId = await _projectRepository.AddProject(ProjectExtensions.ToEntity(project));

            _userProjectRepository.InsertUserProjects(projectId, project.UserIds);
            await _projectTaskRepository.AddProjectTasks(project.Tasks.ToProjectTaskList(projectId));

            return(Ok());
        }
Пример #10
0
 public Project Post([FromBody] Project Project)
 {
     if (ModelState.IsValid && Project.ModuleId == _entityId)
     {
         Project = _Projects.AddProject(Project);
         _logger.Log(LogLevel.Information, this, LogFunction.Create, "Project Added {Project}", Project);
     }
     return(Project);
 }
Пример #11
0
        public IActionResult Post(Project project)
        {
            var currentUser = GetCurrentUserProfile();

            project.UserProfileId = currentUser.Id;

            _projectRepository.AddProject(project);
            return(Ok(CreatedAtAction("Get", new { id = project.Id }, project)));
        }
Пример #12
0
 public async Task <Project> AddProject(Project project)
 {
     try{
         project.ProjectId = Guid.NewGuid();
         return(await _projectRepository.AddProject(project));
     }
     catch (Exception ex) {
         throw ex;
     }
 }
Пример #13
0
        public bool AddProject(ProjectDTO project)
        {
            Domain.Models.Project newProject = new Domain.Models.Project()
            {
                Name = project.Name, Description = project.Description, Administrator = project.Administrator, Moderators = new List <int>(), Users = new List <int>()
            };

            _projectRepository.AddProject(newProject);
            return(_projectRepository.Save());
        }
Пример #14
0
        public async Task AddProject_AddOneProject_AddGivenProjectToDB()
        {
            _client = new IntegrationWebApplicationFactory <Startup>().WithWebHostBuilder(builder =>
            {
                builder.ConfigureTestServices(services =>
                {
                    var sp             = services.BuildServiceProvider();
                    _dbContext         = sp.GetRequiredService <TaskterDbContext>();
                    _projectRepository = sp.GetRequiredService <IProjectRepository>();
                });
            }).CreateClient();

            var seed = new Project("Test1", 1);

            var id = await _projectRepository.AddProject(seed);

            _dbContext.SaveChanges();

            _dbContext.Projects.Find(id).Should().NotBeNull();
        }
Пример #15
0
 public IActionResult Post(Project p)
 {
     try
     {
         _repo.AddProject(p);
         return(Ok());
     }
     catch (Exception e)
     {
         return(NotFound(e.Message));
     }
 }
Пример #16
0
        public async Task <AddProjectResponseModel> Handle(AddProjectRequestModel request, CancellationToken cancellationToken)
        {
            await _projectRepository.AddProject(request.Project);

            AddProjectResponseModel response = new AddProjectResponseModel
            {
                Id        = request.Project.Id,
                IsSuccess = true
            };

            return(response);
        }
Пример #17
0
        public async Task <IActionResult> AddProject(ProjectForCreateDto projectForCreateDto)
        {
            projectForCreateDto.ProjectName = projectForCreateDto.ProjectName.ToLower();
            if (await _repo.ProjectExists(projectForCreateDto.ProjectName))
            {
                return(BadRequest("Ce project exist déjà"));
            }

            var ProjectToReturn = _mapper.Map <Project>(projectForCreateDto);
            var projectToCreate = await _repo.AddProject(ProjectToReturn);

            return(CreatedAtRoute("GetProject", new{ id = projectToCreate.Id }, projectToCreate));
        }
        public void AddProjectBenchmark()
        {
            Projects newProject = new Projects()
            {
                ProjectName = "Lycos",
                Priority    = 5,
                StartDate   = DateTime.ParseExact("8/25/2018", "M/d/yyyy", CultureInfo.InvariantCulture),
                EndDate     = DateTime.ParseExact("9/26/2018", "M/d/yyyy", CultureInfo.InvariantCulture),
                ManagerID   = 4
            };

            projectRepository.AddProject(newProject);
            _counter.Increment();
        }
Пример #19
0
 public IActionResult AddProject(Project project)
 {
     try
     {
         projectRepository.AddProject(project);
         return(Ok());
     }
     catch (DuplicateItem dc)
     {
         return(StatusCode((int)HttpStatusCode.Conflict, dc.message));
     }
     catch
     {
         return(StatusCode((int)HttpStatusCode.InternalServerError, "A server error occurred"));
     }
 }
Пример #20
0
 public bool AddProject(ProjectModel project)
 {
     try
     {
         if (project == null)
         {
             throw new Exception("Project Service: AddProject received null");
         }
         projectRepository.AddProject(project);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #21
0
        /// <summary>
        /// this method is used to add skill into database
        /// </summary>
        /// <param name="project">new project object contains name only</param>
        /// <returns>return newly created skill object</returns>
        public async Task <Project> AddProjectAsync(ProjectDetailsDto project)
        {
            //check if project exists or not

            var existingProject = await _projectRepository.GetProjectByNameAsync(project.Name);

            if (existingProject != null)
            {
                throw new Exception("Project already exists!!");
            }
            var newProject = _mapper.Map <Project>(project);

            newProject.CreatedAt = DateTime.UtcNow;
            _projectRepository.AddProject(newProject);
            await _projectRepository.SaveChangesAsync();

            return(newProject);
        }
Пример #22
0
        public int Add([FromBody] Project project)
        {
            if (String.IsNullOrWhiteSpace(project.Title))
            {
                throw new ArgumentException("Project must have a title", "Title");
            }

            try
            {
                var id = _projectRepository.AddProject(project);
                _logger.LogInformation("Project added: {0}, ID: {1}", project.Title, project.ProjectId);
                return(id);
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Error adding project: " + project.Title);
                return(0);
            }
        }
        public void TestAddProject()
        {
            Projects newProject = new Projects()
            {
                ProjectName = "Lycos",
                Priority    = 5,
                StartDate   = DateTime.ParseExact("8/25/2018", "M/d/yyyy", CultureInfo.InvariantCulture),
                EndDate     = DateTime.ParseExact("9/26/2018", "M/d/yyyy", CultureInfo.InvariantCulture),
                ManagerID   = 4
            };

            projectRepository.AddProject(newProject);
            randomProjects = SetupProjects();
            Projects lastProject = randomProjects.Last();

            Assert.That(lastProject.StartDate, Is.EqualTo(DateTime.ParseExact("8/25/2018", "M/d/yyyy", CultureInfo.InvariantCulture)));
            Assert.That(lastProject.EndDate, Is.EqualTo(DateTime.ParseExact("9/26/2018", "M/d/yyyy", CultureInfo.InvariantCulture)));
            Assert.AreEqual(newProject.ManagerID, lastProject.ManagerID);
            Assert.AreEqual(newProject.Priority, lastProject.Priority);
        }
Пример #24
0
        public async Task <IActionResult> AddProject([FromBody] Project project)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var c        = User.Identity.Name;
            var identity = (ClaimsIdentity)User.Identity;
            IEnumerable <Claim> claims = identity.Claims;
            var userId = claims.FirstOrDefault();

            await _proRepo.AddProject(project, Convert.ToInt32(userId.Value));

            if (await _proRepo.SaveAll())
            {
                return(NoContent());
            }

            throw new Exception($"Fail to add project!");
        }
Пример #25
0
        public IHttpActionResult Post(Project project)
        {
            try
            {
                _projectRepository.AddProject(project);
            }
            catch (ArgumentNullException)
            {
                return(BadRequest());
            }
            catch (ArgumentException)
            {
                return(BadRequest());
            }
            catch (InvalidOperationException)
            {
                return(Conflict());
            }

            return(Ok("Record saved successfully"));
        }
Пример #26
0
 public void AddProject(ProjectViewModel pjVm)
 {
     if (!IsProjectNameExist(pjVm))
     {
         var proj = new Project()
         {
             ProjectName = pjVm.ProjectName,
             StartDate   = pjVm.StartDate,
             EndDate     = pjVm.EndDate,
             Priority    = pjVm.Priority,
             UserId      = pjVm.UserId
         };
         projRepo.AddProject(proj);
     }
     else
     {
         var customException = new CustomException();
         customException.ExceptionMsg = "Same Project Name is already exist in the system";
         throw customException;
     }
 }
Пример #27
0
        public void ImportModule(Module module, string content, string version)
        {
            List <Project> Projects = null;

            if (!string.IsNullOrEmpty(content))
            {
                Projects = JsonSerializer.Deserialize <List <Project> >(content);
            }
            if (Projects != null)
            {
                var projects = _Projects.GetProjects(-1, module.SiteId);
                foreach (Project Project in Projects)
                {
                    var project = projects.FirstOrDefault(item => item.Url == Project.Url);
                    if (project == null)
                    {
                        Project _Project = new Project();
                        _Project.ModuleId = module.ModuleId;
                        _Project.SiteId   = module.SiteId;
                        _Project.Url      = Project.Url;
                        project           = _Projects.AddProject(_Project);
                    }
                    if (Project.Date != null)
                    {
                        ProjectActivity activity = new ProjectActivity();
                        activity.ProjectId    = project.ProjectId;
                        activity.Date         = Project.Date.Value;
                        activity.Watchers     = Project.Watchers;
                        activity.Stars        = Project.Stars;
                        activity.Forks        = Project.Forks;
                        activity.Contributors = Project.Contributors;
                        activity.Commits      = Project.Commits;
                        activity.Issues       = Project.Issues;
                        activity.PullRequests = Project.PullRequests;
                        _Projects.AddProjectActivity(activity);
                    }
                }
            }
        }
        public async Task AddProjectSV(String companyID, ProjectDto project)
        {
            var lastid = await _projectRepository.getProjectLast(companyID);

            string[] splitString = lastid.Split(' ');
            if (lastid == null || splitString.Length == 1)
            {
                project.ProjectId = companyID + " PJ1";
            }
            else
            {
                Regex re     = new Regex(@"([a-zA-Z]+)(\d+)");
                Match result = re.Match(splitString[1]);

                string alphaPart  = result.Groups[1].Value;
                string numberPart = result.Groups[2].Value;

                int numberProject = Int32.Parse(numberPart) + 1;

                project.ProjectId = splitString[0] + " " + alphaPart + numberProject;
            }

            await _projectRepository.AddProject(project);
        }
Пример #29
0
        public async Task <string> AddProject(Project project)
        {
            int insertedprojectid = await ProjectRepository.AddProject(new Project
            {
                GroupId           = project.GroupId,
                CompanyId         = project.CompanyId,
                ProjectName       = project.ProjectName,
                ProjectSize       = project.ProjectSize,
                ProjectStartDate  = project.ProjectStartDate,
                ProjectEndDate    = project.ProjectEndDate,
                TotalDebt         = project.TotalDebt,
                Status            = project.Status,
                CurrentStage      = project.CurrentStage,
                Reason            = project.Reason,
                ProjectManagerId  = project.ProjectManagerId,
                SupervisorId      = project.SupervisorId,
                LoaDate           = project.LoaDate,
                RegisteredAddress = project.RegisteredAddress
            });

            int insertcostbreakup = await CostBreakupRepository.AddCostBreakup(new CostBreakup { ProjectID = insertedprojectid });

            return(insertedprojectid > 0 ? "Successfully added Project" : "Insertion failed");
        }
Пример #30
0
 public virtual bool AddProject(Project project)
 {
     return(_repo.AddProject(project));
 }