Example #1
0
 public void AddProject(int userId, string projectName, string projectDescription)
 {
     _projectRepo.AddProject(new ProjectsDTO()
     {
         UserId = userId, ProjectName = projectName, ProjectDescription = projectDescription
     });
 }
        public ActionResult Create([Bind(Include = "ProjectID,ProjectName,SelectedClient")] Project project)
        {
            project.ClientID = Convert.ToInt32(project.SelectedClient);

            if (ModelState.IsValid)
            {
                _repository.AddProject(project);
                return(RedirectToAction("Index"));
            }

            return(View(project));
        }
Example #3
0
        public async Task <IActionResult> CreateProject([FromBody] ProjectForCreation projectForCreation)
        {
            var projectEntity = _mapper.Map <Entities.Project>(projectForCreation);

            _projectsRepository.AddProject(projectEntity);

            await _projectsRepository.SaveChangesAsync();

            // Fetch (refetch) the project from the data store
            await _projectsRepository.GetProjectByIdAsync(projectEntity.ProjectId);

            return(CreatedAtRoute("GetProjectById",
                                  new { projectId = projectEntity.ProjectId },
                                  projectEntity));
        }