public IHttpActionResult Create(TeamworkModel teamWork) { if (!this.ModelState.IsValid) { return(BadRequest(this.ModelState)); } var currentUserId = this.userIdProvider.GetUserId(); var newTeamwork = new TeamWork() { Name = teamWork.Name, Description = teamWork.Description, GitHubLink = teamWork.GitHubLink, EndDate = teamWork.EndDate, Category = (Category)Enum.Parse(typeof(Category), teamWork.Category) }; newTeamwork.Users.Add(this.data.Users.Find(currentUserId)); this.data.TeamWorks.Add(newTeamwork); this.data.SaveChanges(); teamWork.Id = newTeamwork.Id; return(Ok(teamWork)); }
private void dgTeams_RowStateChanged(object sender, DataGridViewRowStateChangedEventArgs e) { if (e.StateChanged == DataGridViewElementStates.Selected) { TeamWork selectedRow = (TeamWork)e.Row.DataBoundItem; periodsSource = new BindingSource { DataSource = selectedRow.WorkTogether }; dgPeriods.DataSource = periodsSource; } }
public static TeamWork GetValidTeamWork() { var teamWork = new TeamWork() { Name = "WebServices", Description = "Description", EndDate = new DateTime(2015, 2, 1), Category = Category.CSharp }; teamWork.Requests.Add(GetValidTeamWorkRequest()); return(teamWork); }
private void LoadTeamsInGrid() { List <TeamWork> teamWork = Statistics.GetTeamWorkPeriods(records); BindingSource source = new BindingSource { DataSource = teamWork }; dgTeams.DataSource = source; TeamWork maxDays = teamWork.OrderBy(x => x.TotalDays).Last(); lblMax.Text = $"Team {maxDays.TeamKey} has the longest experiance together {maxDays.TotalDays} days."; }
static void Main(string[] args) { try { string filePath = "..//..//testData"; //Console.WriteLine("Filepath or file name, if it is in the application folder:"); //do //{ // filePath = Console.ReadLine(); //} while (!File.Exists(filePath)); string[] fileLines = File.ReadAllLines(filePath); if (fileLines.Length > 1) { List <EmployeeExp> records = LoadModel.ParseEmployeeExp(fileLines, ",", null); Console.WriteLine("Records count:" + records.Count); Console.WriteLine(); if (records.Count > 0) { List <TeamWork> teamWorkExp = Statistics.GetTeamWorkPeriods(records); foreach (TeamWork work in teamWorkExp) { Console.WriteLine($"Team {work.TeamKey} has work experiance together {work.TotalDays}"); foreach (Work w in work.WorkTogether) { Console.WriteLine($"\t ProjectId - {w.ProjectId} From: {w.DateFrom.ToShortDateString()} To: {w.DateTo.ToShortDateString()}"); } Console.WriteLine(); } TeamWork maxDays = teamWorkExp.OrderBy(x => x.TotalDays).Last(); Console.WriteLine($"Team {maxDays.TeamKey} has the longest experiance together {maxDays.TotalDays} days."); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.ReadLine(); }
public static List <TeamWork> GetTeamWorkPeriods(List <EmployeeExp> employeeExps) { List <TeamWork> result = new List <TeamWork>(); for (int i = 0; i < employeeExps.Count; i++) { EmployeeExp empExp1 = employeeExps[i]; for (int j = i; j < employeeExps.Count; j++) { EmployeeExp empExp2 = employeeExps[j]; if (empExp1.EmpID == empExp2.EmpID || empExp1.ProjectID != empExp2.ProjectID) { // Continue, if the experiance is for same person or the project is differents continue; } Work work = CalculateTeamWork(empExp1, empExp2); if (work.DateFrom != null) { TeamWork teamWork = new TeamWork(empExp1.EmpID, empExp2.EmpID); if (result.Any(x => x.TeamKey == teamWork.TeamKey)) { result .First(x => x.TeamKey == teamWork.TeamKey) .WorkTogether.Add(work); } else { teamWork.WorkTogether.Add(work); result.Add(teamWork); } } } } return(result); }