public IEnumerable<ProjectDto> GetProjects(int teamId) { var projectList = new List<TeamBins.Common.ProjectDto>(); using (var c = new SqlConnection(db.Database.Connection.ConnectionString)) { var cmd = new SqlCommand("SELECT ID,Name from Project where TeamId=@teamId",c); cmd.Parameters.AddWithValue("teamId", teamId); c.Open(); var reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { var p = new ProjectDto { Id = reader.GetInt32(reader.GetOrdinal("ID")), Name = reader.GetString(reader.GetOrdinal("Name")) }; projectList.Add(p); } } } return projectList; }
// DELETE api/TodoList/5 public HttpResponseMessage DeleteProject(int id) { Project project = db.Projects.Find(id); if (project == null) { return Request.CreateResponse(HttpStatusCode.NotFound); } if (db.Entry(project).Entity.UserId != User.Identity.Name) { // Trying to delete a record that does not belong to the user return Request.CreateResponse(HttpStatusCode.Unauthorized); } ProjectDto projectDto = new ProjectDto(project); db.Projects.Remove(project); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { return Request.CreateResponse(HttpStatusCode.InternalServerError); } return Request.CreateResponse(HttpStatusCode.OK, projectDto); }
public async Task <ActionResult <ProjectDto> > GetProjectByIdAsync(Guid projectId) { ProjectDto project = await _projectService.GetProjectByIdAsync(projectId); if (project == null) { return(NotFound("Could not find project with provided ID.")); } return(Ok(project)); }
protected async override void OnAppearing() { //Haalt alle projecten op projectById = await projectServices.GetProjectByIdAsync(int.Parse(projectId)); projects = await companyServices.GetAllCompanyProjectsAsync(int.Parse(idCompany)); EntryName.Text = projectById.Name; EntryDescription.Text = projectById.Description; projectSave = EntryName.Text; }
public async Task TestCreateProjectValidInput() { // Arrange var projectDto = new ProjectDto { Title = "Title1", Notes = "Note1", Outcome = "Outcome1", StartDate = new DateTime(), EndDate = new DateTime(), CourseIds = Enumerable.Empty <int>(), OrganisationId = 1, ContactId = 1 }; var organisation = new Organisation { Id = 1 }; Contact contact = new Contact { Id = 1, Name = "Test Name", Email = "*****@*****.**", PhoneNumber = "111", OrganisationId = 1, Projects = new List <Project> { new Project { Id = 1, Title = "HCI Extreme", Notes = "Notes Test", Outcome = "Outcome Test", StartDate = new DateTime(), EndDate = new DateTime(), ProjectCourses = Enumerable.Empty <ProjectCourse>().ToList(), Organisation = organisation } } }; _mockProjectRepository.Setup(x => x.InsertAsync(It.IsAny <Project>())).Returns(Task.FromResult(1)); _mockOrganisationRepository.Setup(x => x.GetByIdAsync(1)).ReturnsAsync(organisation); _mockContactRepository.Setup(x => x.GetByIdAsync(1)).Returns(Task.FromResult(contact)); // Act var id = await _projectService.CreateProject(projectDto); //Assert Assert.AreEqual(0, id); _mockProjectRepository.Verify(x => x.InsertAsync(It.IsAny <Project>()), Times.Once); }
private void EditProject(ProjectDto projectDto) { Project project = _repository.GetById(projectDto.Id); var viewModel = new ExistingProjectViewModel(project); if (_dialogService.ShowDialog(viewModel) == true) { int index = Projects.IndexOf(projectDto); Projects[index] = _repository.GetProjectDto(viewModel.Project.Id); } }
private void SetPageParams(ProjectDto project) { ProjectFormat = project.Format; if (DocumentName.IsNullOrWhiteSpace()) { DocumentName = project.DefaultDocumentName; } DocumentNameWithExtension = DocumentName + "." + project.Format; }
async Task ICustomerService.AddAsync(int id, int projectid) { ProjectDto project = await projectService.GetProjectAsync(projectid); project.CustomerId = id; var json = JsonSerializer.Serialize(project); var data = new StringContent(json, Encoding.UTF8, "application/json"); var response = await Client.PutAsync(_customerRequestUri + "/AddCustomerToProject", data).ConfigureAwait(false); response.EnsureSuccessStatusCode(); }
public ActionResult AddEdit(string id) { ProjectDto model = new ProjectDto(); if (!string.IsNullOrEmpty(id)) { model = _projectService.GetById(Convert.ToInt32(id)); } return(View(model)); }
private async Task <ProjectDto> PrepareProject() { var createProjectDto = new ProjectDto { Name = "My Fancy project" }; var response = await this.context.Client.PostAsJsonAsync("api/projects", createProjectDto); return(await response.ReadAsAsync <ProjectDto>()); }
public Project ToProject(ProjectDto projectD) { Project project = new Project() { Name = projectD.Name, Description = projectD.Description, StartDate = projectD.StartDate, EndDate = projectD.EndDate }; return project; }
public ActionResult <bool> Update(ProjectDto projectDto) { var response = projectService.Update(projectDto); if (!response.Success) { return(NotFound(new { message = response.ErrorMessage })); } return(response.Success); }
public async Task <ProjectDto> CreateProjectAsync(ProjectDto project) { ApplicationUser currentUser = _session.User; Project projectToCreate = _mapper.Map <Project>(project); Project createdProject = _unitOfWork.Projects.AddProject(projectToCreate); await _unitOfWork.SaveAsync(); await SetProjectManagerAsync(createdProject.Id, currentUser.Id, createdProject); return(_mapper.Map <ProjectDto>(createdProject)); }
public List <LogDto> GetLogs(ProjectDto proj) { if (proj != null) { return(context.LogsDto.Where(x => x.ProjectId == proj.Id).ToList()); } else { return(null); } }
public IActionResult OnGet(int projectId) { Project = repository.GetProjectById(projectId); if (Project == null) { return(RedirectToPage("./NotFound")); } return(Page()); }
public static LabelCreateModel MapLabelCreateModel(ProjectDto dto) { var model = new LabelCreateModel(); model.OrganizationUid = dto.OrganizationUid; model.ProjectUid = dto.Uid; model.ProjectName = dto.Name; model.SetInputModelValues(); return(model); }
private bool AddProject(string userId, ProjectViewModel project) { var addRecord = new ProjectDto() { UserId = userId, Title = project.Title, Summary = project.Summary }; return(_projectService.InsertProject(userId, addRecord)); }
public static LabelUploadFromCSVModel MapLabelUploadFromCSVModel(ProjectDto project) { var model = new LabelUploadFromCSVModel(); model.OrganizationUid = project.OrganizationUid; model.ProjectUid = project.Uid; model.ProjectName = project.Name; model.SetInputModelValues(); return(model); }
public static CreateBulkLabelModel MapCreateBulkLabelModel(ProjectDto project) { var model = new CreateBulkLabelModel(); model.OrganizationUid = project.OrganizationUid; model.ProjectUid = project.Uid; model.ProjectName = project.Name; model.SetInputModelValues(); return(model); }
public virtual void ShowDetails(ProjectDto projectDto) { ProjectType projectType = projectDto.Type == (char)ProjectType.Internal? ProjectType.Internal: ProjectType.External; Console.WriteLine("{0}", "".PadRight(100, '-')); Console.WriteLine("Project Details"); Console.WriteLine("---------------"); Console.WriteLine($"Id : {projectDto.Id}\t\t\tType : {projectDto.Type}-{projectType.ToString()}\n"); Console.WriteLine($"Name : {projectDto.Name}\n"); Console.WriteLine($"Description :\n{projectDto.Description}\n"); }
public Project CreateNewProject(ProjectDto projectDto) { var projectToCreate = new Project() { ProjectDescription = projectDto.ProjectDescription, ProjectName = projectDto.ProjectName, ProjectVersion = projectDto.ProjectVersion }; return(projectService.CreateElement(projectToCreate)); }
public void CanBeConstructed() { //Arrange ProjectDto sut; //Act sut = new ProjectDto(); //Assert Assert.NotNull(sut); }
public List <ProjectDto> GetProjects(int researcherId) { List <ProjectDto> projectDtos = new List <ProjectDto>(); using (ScheduleExEntities ctx = new ScheduleExEntities()) { DataAccess.User user = ctx.Users.First(u => u.UserId == researcherId); List <ResearcherAvailability> availabilities = user.ResearcherAvailabilities.ToList(); //get all projects List <Project> projects = ctx.Projects.Where(p => p.IsPublished == true && p.Approved == true).ToList(); for (int projIndex = 0; projIndex < projects.Count; projIndex++) { int projectId = projects[projIndex].ProjectId; List <ResearcherApproval> approvals = ctx.ResearcherApprovals.Where(a => a.ResearcherId == researcherId && a.ProjectId == projectId).ToList(); if (projects[projIndex].State.Equals(user.State)) { continue; } bool hasAvailabilityMatch = false; DataAccess.ResearcherApproval researcherApproval = null; foreach (ResearcherAvailability availability in availabilities) { if (availability.Month >= projects[projIndex].StartDate.Month && availability.Month <= projects[projIndex].EndDate.Month) { hasAvailabilityMatch = true; } } if (!hasAvailabilityMatch) { continue; } researcherApproval = ctx.ResearcherApprovals.Where(ra => ra.ProjectId == projectId && ra.ResearcherId == researcherId).FirstOrDefault(); ProjectDto projectDto = new ProjectDto(); projectDto.ProjectId = projects[projIndex].ProjectId; projectDto.ProjectName = projects[projIndex].ProjectName; projectDto.Description = projects[projIndex].Description; projectDto.State = projects[projIndex].State; projectDto.StartDate = projects[projIndex].StartDate; projectDto.EndDate = projects[projIndex].EndDate; projectDto.Approved = projects[projIndex].Approved; projectDto.Status = (researcherApproval != null ? researcherApproval.ApprovalStatus.Status : "Available"); projectDto.InfoRequested = (researcherApproval != null ? researcherApproval.InfoRequested : string.Empty); projectDtos.Add(projectDto); } } return(projectDtos); }
public async Task CreateOrEditProject(ProjectDto input) { if (input.Id.HasValue) { await UpdateAsync(input); } else { await CreateAsync(input); } }
public async Task Execute(ProjectDto request) { //await _tableCli.MergeEntityAsync(new Project("partition1", request.Id, request.Name)); // Mapping to dto to entity object - compatibile for storage operations var tableEntity = _mapper.Map <Project>(request); var dynTableEntity = new DynamicTableEntity(tableEntity.PartitionKey, tableEntity.RowKey); dynTableEntity.Properties.Add("Deleted", new EntityProperty(true)); var batchDelete = new TableBatchOperation(); await _tableCli.MergeDynamicEntityAsync(dynTableEntity); }
public Project UpdateProject(ProjectDto projectDto, long id) { var projectToUpdate = new Project() { Id = id, ProjectDescription = projectDto.ProjectDescription, ProjectName = projectDto.ProjectName, ProjectVersion = projectDto.ProjectVersion }; return(projectService.UpdateElement(projectToUpdate)); }
public async Task <ActionResult <ProjectDto> > CreateProject([FromBody] ProjectCreateDto dto) { List <WorkItemStatus> availableStatues = dto.AvailableStatuses.Select(x => new WorkItemStatus(x)).ToList(); var project = new Project(dto.Title, dto.Description, availableStatues); project = await _projectsRepository.SaveProject(project); ProjectDto createdDto = _mapper.Map <ProjectDto>(project); return(CreatedAtAction(nameof(GetProject), new { id = project.Id }, createdDto)); }
public IActionResult UpdateProject(ProjectDto project) { var val = _validator.Validate(project, ruleSet: "Update"); if (!val.IsValid) { return(BadRequest(val.Errors)); } var prj = _mapper.Map <Project>(project); return(StatusCode((int)HttpStatusCode.NoContent, _projects.UpdateProject(prj))); }
public IActionResult CreateProject(ProjectDto project) { var val = _validator.Validate(project, ruleSet: "Create"); if (!val.IsValid) { return(BadRequest(val.Errors)); } var prj = _mapper.Map <Project>(project); return(Created("", _projects.CreateProject(prj))); }
public async Task <int> AddProject(ProjectDto projecttype) { int result = 0; var addProject = await projectClient.PostAsync(projecttype).ConfigureAwait(false); if (addProject != null) { result = 1; } return(result); }
public void EditProject(ProjectDto dto) { var entity = Mapper.Map <ProjectDto, Project>(dto); entity.CreateDate = DateTime.Now; using (var dbScope = _dbScopeFactory.Create()) { var db = dbScope.DbContexts.Get <FireProjDbContext>(); db.Update(entity, r => new { r.ProjectDesc, r.ProjectName, r.ProjectRepo, ProjectId = r.RepoId, r.ProjectSlnName }); db.SaveChanges(); } }
public ProjectDto CreateAsync(ProjectCreateDto createDto) { var command = new List <ProjectsCreateCommand> { new ProjectsCreateCommand(new ProjectCreateDto()) }; var result = new ProjectDto { Name = createDto.Name, }; return(result); }
// POST api/TodoList public HttpResponseMessage PostProject(ProjectDto projectDto) { if (ModelState.IsValid) { projectDto.UserId = User.Identity.Name; Project todoList = projectDto.ToEntity(); db.Projects.Add(todoList); db.SaveChanges(); projectDto.ProjectId = todoList.ProjectId; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, projectDto); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = projectDto.ProjectId })); return response; } else { return Request.CreateResponse(HttpStatusCode.BadRequest); } }
// PUT api/TodoList/5 public HttpResponseMessage PutProject(int id, ProjectDto projectDto) { if (ModelState.IsValid && id == projectDto.ProjectId) { Project todoList = projectDto.ToEntity(); if (db.Entry(todoList).Entity.UserId != User.Identity.Name) { // Trying to modify a record that does not belong to the user return Request.CreateResponse(HttpStatusCode.Unauthorized); } db.Entry(todoList).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { return Request.CreateResponse(HttpStatusCode.InternalServerError); } return Request.CreateResponse(HttpStatusCode.OK); } else { return Request.CreateResponse(HttpStatusCode.BadRequest); } }