public async Task <bool> UpdateProjectByIdAsync(ProjectToUpdateDto Project, int id) { GetClient(); ProjectDto updatedProject = null; HttpResponseMessage response = await client.PutAsJsonAsync($"api/Projects/{id}", Project); if (response.IsSuccessStatusCode) { updatedProject = await response.Content.ReadAsAsync <ProjectDto>(); return(true); } return(false); }
private async void EditProjectButton_Clicked(object sender, EventArgs e) { if (CheckDescriptionAndName() == true) { ProjectToUpdateDto project = new ProjectToUpdateDto { CompanyID = int.Parse(idCompany), Description = EntryDescription.Text, Name = EntryName.Text }; bool projectDto = await projectServices.UpdateProjectByIdAsync(project, int.Parse(projectId)); EditProjectButton.IsEnabled = false; Application.Current.MainPage = new ProjectListPage(); } }
public async Task <ProjectDto> UpdateProject(int projectId, ProjectToUpdateDto updatedProject) { Project project = await _context.Projects.FirstOrDefaultAsync(x => x.Id == projectId); if (project == null) { return(null); } project.CompanyId = updatedProject.CompanyId; project.Name = updatedProject.Name; project.Description = updatedProject.Description; await UpdateAsync(project); return(null); }
static void Main() { //Create address AddressToCreateDto createdAddress = new AddressToCreateDto { Country = "Belgium", City = "Brussel", PostalCode = "1000", Street = "testStraat", HouseNumber = "20" }; //Create user UserToCreateDto createdUser = new UserToCreateDto { FirstName = "Mich", LastName = "dg", Email = "*****@*****.**", PhoneNumber = "+3256798487", Psw = "hallo", Address = createdAddress }; //Update address AddressToUpdateDto updatedAddress = new AddressToUpdateDto { Country = "Belgium", City = "Brussel", PostalCode = "1000", Street = "testStraat1", HouseNumber = "35" }; //Update user UserToUpdateDto updatedUser = new UserToUpdateDto { FirstName = "Michael", LastName = "DG", Email = "*****@*****.**", PhoneNumber = "+3256798489", Address = updatedAddress }; //Login UserToLoginDto login = new UserToLoginDto { Email = "*****@*****.**", Password = "******" }; //Create company CompanyToCreateDto createdCompany = new CompanyToCreateDto { Name = "Microsoft1", Address = createdAddress }; //Update company CompanyToUpdateDto updatedCompany = new CompanyToUpdateDto { Name = "Microsoft 2", Address = updatedAddress }; //Create companyrole CompanyRoleToCreateDto createdCompanyRole = new CompanyRoleToCreateDto { Name = "CompanyRole1", Description = "It's just a test", IsDefault = true, ManageCompany = true, ManageUsers = false, ManageProjects = true, ManageRoles = true }; //Update companyrole CompanyRoleToUpdateDto updatedCompanyRole = new CompanyRoleToUpdateDto { Name = "CompanyRole1Updated", Description = "It's just a test for something", IsDefault = true, ManageCompany = true, ManageUsers = true, ManageProjects = true, ManageRoles = true }; //Create project ProjectToCreateDto createdProject = new ProjectToCreateDto { CompanyID = 1, Name = "Tim", Description = "desc" }; //Update project ProjectToUpdateDto updatedProject = new ProjectToUpdateDto { CompanyID = 2, Name = "Kevin", Description = "desc 2" }; //Testen API calls UserServices userServices = new UserServices(); CompanyServices companyServices = new CompanyServices(); ProjectServices projectServices = new ProjectServices(); CompanyRoleServices companyRoleServices = new CompanyRoleServices(); LogServices logServices = new LogServices(); SessionServices sessionServices = new SessionServices(); UserDto user1 = new UserDto(); CompanyDto c = new CompanyDto(); CompanyRoleDto cr = new CompanyRoleDto(); ProjectDto p = new ProjectDto(); //Userservices //OK //user1 = userServices.GetUserByIdAsync(1).GetAwaiter().GetResult(); //List<UserDto> userlist = userServices.GetAllUsersAsync().GetAwaiter().GetResult(); //user1 = userServices.CreateUserAsync(createdUser).GetAwaiter().GetResult(); //user1 = userServices.UpdateUserByIdAsync(updatedUser, 1).GetAwaiter().GetResult(); //user1 = userServices.DeleteUserByIdAsync(3).GetAwaiter().GetResult(); //List<LogDto> user = userServices.GetAllUserLogsAsync(1).GetAwaiter().GetResult(); //List<UserDto> users = userServices.GetUserByEmailAsync("*****@*****.**").GetAwaiter().GetResult(); //List<LogDto> lk = userServices.GetAllUserLogsAsync(5).GetAwaiter().GetResult(); //Sessionservices //OK //string str = sessionServices.CreateSession(login); //string str = sessionServices.DeleteSessionAsync().GetAwaiter().GetResult(); //Companyservices //OK //List<CompanyDto> companylist = companyServices.GetAllCompaniesAsync().GetAwaiter().GetResult(); //c = companyServices.GetCompanyByIdAsync(1).GetAwaiter().GetResult(); //c = companyServices.CreateCompanyAsync(createdCompany).GetAwaiter().GetResult(); //c = companyServices.UpdateCompanyByIdAsync(updatedCompany, 1).GetAwaiter().GetResult(); //List<UserDto> cl = companyServices.GetUsersFromCompanyByIdAsync(1).GetAwaiter().GetResult(); //bool b = companyServices.AddUserToCompanyByIdAsync(1, 8).GetAwaiter().GetResult(); //CompanyRoleservices //OK //cr = companyRoleServices.CreateCompanyRoleAsync(createdCompanyRole, 1).GetAwaiter().GetResult(); //List<CompanyRoleDto> crlist = companyRoleServices.GetAllCompanyRolesAsync(1).GetAwaiter().GetResult(); //cr = companyRoleServices.GetCompanyRoleByIdAsync(1, 3).GetAwaiter().GetResult(); //cr = companyRoleServices.UpdateCompanyRoleByIdAsync(updatedCompanyRole, 1, 3).GetAwaiter().GetResult(); //Projectservices //OK //bool bp = projectServices.UpdateProjectByIdAsync(updatedProject, 1).GetAwaiter().GetResult(); //List<ProjectDto> projects = companyServices.GetAllCompanyProjectsAsync(1).GetAwaiter().GetResult(); //List<ProjectDto> projects = userServices.GetAllUserProjectsAsync(1).GetAwaiter().GetResult(); //bool pu = projectServices.RemoveUserToProjectAsync(1, 1).GetAwaiter().GetResult(); //bool u = projectServices.AddUserToProjectAsync(1, "*****@*****.**").GetAwaiter().GetResult(); //bool u = projectServices.RemoveUserToProjectAsync(1, 7).GetAwaiter().GetResult(); }
public async Task <IActionResult> UpdateProject(int id, ProjectToUpdateDto updatedProject) { var project = await _service.UpdateProject(id, updatedProject); return(StatusCode(200, project)); }