Need Help with Repository Program (Beginner)

Joined
Jul 7, 2023
Messages
1
Reaction score
0
Hi, everyone - this is my first post, so be kind :). I'm building a practice repository program for a non-existent insurance companies. The premise of the project is that I need a program that the "Managers" can use to access their software developer and software developer team information. I've built a lot of the UI, one of the POCOS, and two of the repositories. Everything is still missing CRUD methodology. My goal for this is for the "Managers" to be able to add/remove team members using their name or ID information. They need to be able to see a list of existing developers and add developers to existing teams. I've included the code below that I have written, so far. I'm missing the Dev Team Pocos (I don't know exactly how to get started on that and would appreciate some help). I would also love some help with the CRUD methods for both repo's and the UI. If I've explained anything terribly I'm sorry and I will elaborate if I need to. Thanks for your help in advance!

Program UI:

using System.Collections.Generic;

public class Developer
{
public int Id { get; set; }
public string Name { get; set; }
public string Email { get; set; }
public bool HasPluralSight { get; set; }
public bool NeedsLicense { get; set; }
}

public class Team
{
public string TeamName { get; set; }
// Add any other properties related to a team here
}

public class DevTeamRepo
{
private int Counter = 1;
private readonly List<Team> _teams = new List<Team>();

public DevTeamRepo()
{
SeedData();
}

private void SeedData()
{
List<Developer> group1 = new List<Developer>();
List<Developer> group2 = new List<Developer>();
List<Developer> group3 = new List<Developer>();

Developer developer1 = new Developer();
developer1.Id = Counter++;
developer1.Name = "Mick";
developer1.Email = "(e-mail address removed)";
developer1.HasPluralSight = false;
developer1.NeedsLicense = false;
group1.Add(developer1);

Developer developer2 = new Developer();
developer2.Id = Counter++;
developer2.Name = "Chloe";
developer2.Email = "(e-mail address removed)";
developer2.HasPluralSight = true;
developer2.NeedsLicense = false;
group1.Add(developer2);

Developer developer3 = new Developer();
developer3.Id = Counter++;
developer3.Name = "Dan";
developer3.Email = "(e-mail address removed)";
developer3.HasPluralSight = false;
developer3.NeedsLicense = true;
group1.Add(developer3);

Developer developer4 = new Developer();
developer4.Id = Counter++;
developer4.Name = "Lex";
developer4.Email = "(e-mail address removed)";
developer4.HasPluralSight = true;
developer4.NeedsLicense = false;
group2.Add(developer4);

Developer developer5 = new Developer();
developer5.Id = Counter++;
developer5.Name = "Iggy";
developer5.Email = "(e-mail address removed)";
developer5.HasPluralSight = false;
developer5.NeedsLicense = false;
group2.Add(developer5);

Developer developer6 = new Developer();
developer6.Id = Counter++;
developer6.Name = "Moneypenny";
developer6.Email = "(e-mail address removed)";
developer6.HasPluralSight = true;
developer6.NeedsLicense = false;
group2.Add(developer6);

Developer developer7 = new Developer();
developer7.Id = Counter++;
developer7.Name = "James";
developer7.Email = "(e-mail address removed)";
developer7.HasPluralSight = true;
developer7.NeedsLicense = false;
group3.Add(developer7);

Developer developer8 = new Developer();
developer8.Id = Counter++;
developer8.Name = "Hailey";
developer8.Email = "(e-mail address removed)";
developer8.HasPluralSight = true;
developer8.NeedsLicense = false;
group3.Add(developer8);

Developer developer9 = new Developer();
developer9.Id = Counter++;
developer9.Name = "Lemmy";
developer9.Email = "(e-mail address removed)";
developer9.HasPluralSight = false;
developer9.NeedsLicense = true;
group3.Add(developer9);
}

public void AddTeam(Team team)
{
_teams.Add(team);
}

public void RemoveTeam(string teamName)
{
Team team = GetTeamByName(teamName);
if (team != null)
{
_teams.Remove(team);
}
}

public Team GetTeamByName(string teamName)
{
foreach (Team team in _teams)
{
if (team.TeamName == teamName)
{
return team;
}
}
return null;
}

public List<Team> GetTeams()
{
return _teams;
}
}

Developer POCOS:

class Developer
{
public int id { get; set; }
public string Name { get; set; }
public string Email { get; set; }
public bool HasPluralSight { get; set; }
public bool NeedsLicense { get; set; }
}

Developer Repo:

using System.Collections.Generic;

public class Developer
{
public int Id { get; set; }
public string Name { get; set; }
public string Email { get; set; }
public bool HasPluralSight { get; set; }
public bool NeedsLicense { get; set; }
}

public class Team
{
public string TeamName { get; set; }
// Add any other properties related to a team here
}

public class DevTeamRepo
{
private int Counter = 1;
private readonly List<Team> _teams = new List<Team>();

public DevTeamRepo()
{
SeedData();
}

private void SeedData()
{
List<Developer> group1 = new List<Developer>();
List<Developer> group2 = new List<Developer>();
List<Developer> group3 = new List<Developer>();

Developer developer1 = new Developer();
developer1.Id = Counter++;
developer1.Name = "Mick";
developer1.Email = "(e-mail address removed)";
developer1.HasPluralSight = false;
developer1.NeedsLicense = false;
group1.Add(developer1);

Developer developer2 = new Developer();
developer2.Id = Counter++;
developer2.Name = "Chloe";
developer2.Email = "(e-mail address removed)";
developer2.HasPluralSight = true;
developer2.NeedsLicense = false;
group1.Add(developer2);

Developer developer3 = new Developer();
developer3.Id = Counter++;
developer3.Name = "Dan";
developer3.Email = "(e-mail address removed)";
developer3.HasPluralSight = false;
developer3.NeedsLicense = true;
group1.Add(developer3);

Developer developer4 = new Developer();
developer4.Id = Counter++;
developer4.Name = "Lex";
developer4.Email = "(e-mail address removed)";
developer4.HasPluralSight = true;
developer4.NeedsLicense = false;
group2.Add(developer4);

Developer developer5 = new Developer();
developer5.Id = Counter++;
developer5.Name = "Iggy";
developer5.Email = "(e-mail address removed)";
developer5.HasPluralSight = false;
developer5.NeedsLicense = false;
group2.Add(developer5);

Developer developer6 = new Developer();
developer6.Id = Counter++;
developer6.Name = "Moneypenny";
developer6.Email = "(e-mail address removed)";
developer6.HasPluralSight = true;
developer6.NeedsLicense = false;
group2.Add(developer6);

Developer developer7 = new Developer();
developer7.Id = Counter++;
developer7.Name = "James";
developer7.Email = "(e-mail address removed)";
developer7.HasPluralSight = true;
developer7.NeedsLicense = false;
group3.Add(developer7);

Developer developer8 = new Developer();
developer8.Id = Counter++;
developer8.Name = "Hailey";
developer8.Email = "(e-mail address removed)";
developer8.HasPluralSight = true;
developer8.NeedsLicense = false;
group3.Add(developer8);

Developer developer9 = new Developer();
developer9.Id = Counter++;
developer9.Name = "Lemmy";
developer9.Email = "(e-mail address removed)";
developer9.HasPluralSight = false;
developer9.NeedsLicense = true;
group3.Add(developer9);
}

public void AddTeam(Team team)
{
_teams.Add(team);
}

public void RemoveTeam(string teamName)
{
Team team = GetTeamByName(teamName);
if (team != null)
{
_teams.Remove(team);
}
}

public Team GetTeamByName(string teamName)
{
foreach (Team team in _teams)
{
if (team.TeamName == teamName)
{
return team;
}
}
return null;
}

public List<Team> GetTeams()
{
return _teams;
}
}

Developer Team Repo:

public Team GetTeamByName(string teamName)
{
foreach (Team team in _teams)
{
if (team.TeamName == teamName)
{
return team;
}
}
return null;
}

public List<Team> GetTeams()
{
return _teams;
}
}
 
Joined
Sep 3, 2023
Messages
2
Reaction score
0
Hi, everyone - this is my first post, so be kind :). I'm building a practice repository program for a non-existent insurance companies. The premise of the project is that I need a program that the "Managers" can use to access their software developer and software developer team information. I've built a lot of the UI, one of the POCOS, and two of the repositories. Everything is still missing CRUD methodology. My goal for this is for the "Managers" to be able to add/remove team members using their name or ID information. They need to be able to see a list of existing developers and add developers to existing teams. I've included the code below that I have written, so far. I'm missing the Dev Team Pocos (I don't know exactly how to get started on that and would appreciate some help). I would also love some help with the CRUD methods for both repo's and the UI. If I've explained anything terribly I'm sorry and I will elaborate if I need to. Thanks for your help in advance!

Program UI:

using System.Collections.Generic;

public class Developer
{
public int Id { get; set; }
public string Name { get; set; }
public string Email { get; set; }
public bool HasPluralSight { get; set; }
public bool NeedsLicense { get; set; }
}

public class Team
{
public string TeamName { get; set; }
// Add any other properties related to a team here
}

public class DevTeamRepo
{
private int Counter = 1;
private readonly List<Team> _teams = new List<Team>();

public DevTeamRepo()
{
SeedData();
}

private void SeedData()
{
List<Developer> group1 = new List<Developer>();
List<Developer> group2 = new List<Developer>();
List<Developer> group3 = new List<Developer>();

Developer developer1 = new Developer();
developer1.Id = Counter++;
developer1.Name = "Mick";
developer1.Email = "(e-mail address removed)";
developer1.HasPluralSight = false;
developer1.NeedsLicense = false;
group1.Add(developer1);

Developer developer2 = new Developer();
developer2.Id = Counter++;
developer2.Name = "Chloe";
developer2.Email = "(e-mail address removed)";
developer2.HasPluralSight = true;
developer2.NeedsLicense = false;
group1.Add(developer2);

Developer developer3 = new Developer();
developer3.Id = Counter++;
developer3.Name = "Dan";
developer3.Email = "(e-mail address removed)";
developer3.HasPluralSight = false;
developer3.NeedsLicense = true;
group1.Add(developer3);

Developer developer4 = new Developer();
developer4.Id = Counter++;
developer4.Name = "Lex";
developer4.Email = "(e-mail address removed)";
developer4.HasPluralSight = true;
developer4.NeedsLicense = false;
group2.Add(developer4);

Developer developer5 = new Developer();
developer5.Id = Counter++;
developer5.Name = "Iggy";
developer5.Email = "(e-mail address removed)";
developer5.HasPluralSight = false;
developer5.NeedsLicense = false;
group2.Add(developer5);

Developer developer6 = new Developer();
developer6.Id = Counter++;
developer6.Name = "Moneypenny";
developer6.Email = "(e-mail address removed)";
developer6.HasPluralSight = true;
developer6.NeedsLicense = false;
group2.Add(developer6);

Developer developer7 = new Developer();
developer7.Id = Counter++;
developer7.Name = "James";
developer7.Email = "(e-mail address removed)";
developer7.HasPluralSight = true;
developer7.NeedsLicense = false;
group3.Add(developer7);

Developer developer8 = new Developer();
developer8.Id = Counter++;
developer8.Name = "Hailey";
developer8.Email = "(e-mail address removed)";
developer8.HasPluralSight = true;
developer8.NeedsLicense = false;
group3.Add(developer8);

Developer developer9 = new Developer();
developer9.Id = Counter++;
developer9.Name = "Lemmy";
developer9.Email = "(e-mail address removed)";
developer9.HasPluralSight = false;
developer9.NeedsLicense = true;
group3.Add(developer9);
}

public void AddTeam(Team team)
{
_teams.Add(team);
}

public void RemoveTeam(string teamName)
{
Team team = GetTeamByName(teamName);
if (team != null)
{
_teams.Remove(team);
}
}

public Team GetTeamByName(string teamName)
{
foreach (Team team in _teams)
{
if (team.TeamName == teamName)
{
return team;
}
}
return null;
}

public List<Team> GetTeams()
{
return _teams;
}
}

Developer POCOS:

class Developer
{
public int id { get; set; }
public string Name { get; set; }
public string Email { get; set; }
public bool HasPluralSight { get; set; }
public bool NeedsLicense { get; set; }
}

Developer Repo:

using System.Collections.Generic;

public class Developer
{
public int Id { get; set; }
public string Name { get; set; }
public string Email { get; set; }
public bool HasPluralSight { get; set; }
public bool NeedsLicense { get; set; }
}

public class Team
{
public string TeamName { get; set; }
// Add any other properties related to a team here
}

public class DevTeamRepo
{
private int Counter = 1;
private readonly List<Team> _teams = new List<Team>();

public DevTeamRepo()
{
SeedData();
}

private void SeedData()
{
List<Developer> group1 = new List<Developer>();
List<Developer> group2 = new List<Developer>();
List<Developer> group3 = new List<Developer>();

Developer developer1 = new Developer();
developer1.Id = Counter++;
developer1.Name = "Mick";
developer1.Email = "(e-mail address removed)";
developer1.HasPluralSight = false;
developer1.NeedsLicense = false;
group1.Add(developer1);

Developer developer2 = new Developer();
developer2.Id = Counter++;
developer2.Name = "Chloe";
developer2.Email = "(e-mail address removed)";
developer2.HasPluralSight = true;
developer2.NeedsLicense = false;
group1.Add(developer2);

Developer developer3 = new Developer();
developer3.Id = Counter++;
developer3.Name = "Dan";
developer3.Email = "(e-mail address removed)";
developer3.HasPluralSight = false;
developer3.NeedsLicense = true;
group1.Add(developer3);

Developer developer4 = new Developer();
developer4.Id = Counter++;
developer4.Name = "Lex";
developer4.Email = "(e-mail address removed)";
developer4.HasPluralSight = true;
developer4.NeedsLicense = false;
group2.Add(developer4);

Developer developer5 = new Developer();
developer5.Id = Counter++;
developer5.Name = "Iggy";
developer5.Email = "(e-mail address removed)";
developer5.HasPluralSight = false;
developer5.NeedsLicense = false;
group2.Add(developer5);

Developer developer6 = new Developer();
developer6.Id = Counter++;
developer6.Name = "Moneypenny";
developer6.Email = "(e-mail address removed)";
developer6.HasPluralSight = true;
developer6.NeedsLicense = false;
group2.Add(developer6);

Developer developer7 = new Developer();
developer7.Id = Counter++;
developer7.Name = "James";
developer7.Email = "(e-mail address removed)";
developer7.HasPluralSight = true;
developer7.NeedsLicense = false;
group3.Add(developer7);

Developer developer8 = new Developer();
developer8.Id = Counter++;
developer8.Name = "Hailey";
developer8.Email = "(e-mail address removed)";
developer8.HasPluralSight = true;
developer8.NeedsLicense = false;
group3.Add(developer8);

Developer developer9 = new Developer();
developer9.Id = Counter++;
developer9.Name = "Lemmy";
developer9.Email = "(e-mail address removed)";
developer9.HasPluralSight = false;
developer9.NeedsLicense = true;
group3.Add(developer9);
}

public void AddTeam(Team team)
{
_teams.Add(team);
}

public void RemoveTeam(string teamName)
{
Team team = GetTeamByName(teamName);
if (team != null)
{
_teams.Remove(team);
}
}

public Team GetTeamByName(string teamName)
{
foreach (Team team in _teams)
{
if (team.TeamName == teamName)
{
return team;
}
}
return null;
}

public List<Team> GetTeams()
{
return _teams;
}
}

Developer Team Repo:

public Team GetTeamByName(string teamName)
{
foreach (Team team in _teams)
{
if (team.TeamName == teamName)
{
return team;
}
}
return null;
}

public List<Team> GetTeams()
{
return _teams;
}
}
I understand that you're building a program for managing software developers and teams for a fictional insurance company. Let's continue to work on the structure of your project, including the missing Dev Team POCOs and implementing the CRUD methods for both repositories and the UI.

First, let's define the missing Dev Team POCOs:

public class Developer
{
public int Id { get; set; }
public string Name { get; set; }
public string Email { get; set; }
public bool HasPluralSight { get; set; }
public bool NeedsLicense { get; set; }
}

public class Team
{
public string TeamName { get; set; }
public List<Developer> Developers { get; set; } = new List<Developer>();
}

Now, let's work on the CRUD methods for both repositories.

using System;
using System.Collections.Generic;
using System.Linq;

public class DeveloperRepository
{
private List<Developer> _developers = new List<Developer>();
private int _nextId = 1;

public void CreateDeveloper(Developer developer)
{
developer.Id = _nextId++;
_developers.Add(developer);
}

public Developer GetDeveloperById(int id)
{
return _developers.FirstOrDefault(dev => dev.Id == id);
}

public Developer GetDeveloperByName(string name)
{
return _developers.FirstOrDefault(dev => dev.Name == name);
}

public void UpdateDeveloper(Developer updatedDeveloper)
{
var existingDeveloper = _developers.FirstOrDefault(dev => dev.Id == updatedDeveloper.Id);
if (existingDeveloper != null)
{
// Update properties of the existing developer
existingDeveloper.Name = updatedDeveloper.Name;
existingDeveloper.Email = updatedDeveloper.Email;
existingDeveloper.HasPluralSight = updatedDeveloper.HasPluralSight;
existingDeveloper.NeedsLicense = updatedDeveloper.NeedsLicense;
}
}

public void DeleteDeveloper(int id)
{
var developerToRemove = _developers.FirstOrDefault(dev => dev.Id == id);
if (developerToRemove != null)
{
_developers.Remove(developerToRemove);
}
}

public List<Developer> GetAllDevelopers()
{
return _developers;
}
}

public class TeamRepository
{
private List<Team> _teams = new List<Team>();

public void CreateTeam(Team team)
{
_teams.Add(team);
}

public Team GetTeamByName(string teamName)
{
return _teams.FirstOrDefault(team => team.TeamName == teamName);
}

public void UpdateTeam(Team updatedTeam)
{
var existingTeam = _teams.FirstOrDefault(team => team.TeamName == updatedTeam.TeamName);
if (existingTeam != null)
{
// Update properties of the existing team if needed
}
}

public void DeleteTeam(string teamName)
{
var teamToRemove = _teams.FirstOrDefault(team => team.TeamName == teamName);
if (teamToRemove != null)
{
_teams.Remove(teamToRemove);
}
}

public List<Team> GetAllTeams()
{
return _teams;
}
}

Now, let's work on the program's UI to allow managers to interact with these repositories:

public class Program
{
public static void Main()
{
DeveloperRepository developerRepo = new DeveloperRepository();
TeamRepository teamRepo = new TeamRepository();

// Create some developers
var developer1 = new Developer
{
Name = "John Doe",
Email = "(e-mail address removed)",
HasPluralSight = true,
NeedsLicense = false
};

var developer2 = new Developer
{
Name = "Jane Smith",
Email = "(e-mail address removed)",
HasPluralSight = false,
NeedsLicense = true
};

developerRepo.CreateDeveloper(developer1);
developerRepo.CreateDeveloper(developer2);

// Create a team
var team = new Team
{
TeamName = "Development Team"
};

teamRepo.CreateTeam(team);

// Add developers to the team
team.Developers.Add(developer1);
team.Developers.Add(developer2);

// Retrieve all developers and teams
var allDevelopers = developerRepo.GetAllDevelopers();
var allTeams = teamRepo.GetAllTeams();

// Print out the developers and teams
Console.WriteLine("Developers:");
foreach (var dev in allDevelopers)
{
Console.WriteLine($"{dev.Id}: {dev.Name}");
}

Console.WriteLine("\nTeams:");
foreach (var t in allTeams)
{
Console.WriteLine($"{t.TeamName}: Developers - {t.Developers.Count}");
}
}
}


This code demonstrates how to create developers, teams, add developers to teams, and retrieve lists of developers and teams. You can expand on this foundation to include additional features and a user-friendly UI for managers to interact with the data.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,795
Messages
2,569,644
Members
45,358
Latest member
TreyTritt8

Latest Threads

Top