public IEnumerable <AppTeamSite> Update(IEnumerable <AppTeamSite> models) { // Need to deleted items\ var deleteItems = _teamRepository.GetAllTeams().Where(l => !models.Where(_ => _.Id.HasValue).Select(_ => _.Id).Contains(l.Id)); if (deleteItems != null && deleteItems.Count() > 0) { foreach (var team in deleteItems) { _teamRepository.Remove(team); } } // Add or modify foreach (var team in models) { if (team.Id.HasValue) { // update //_teamRepository.Modify(team.ToTeamSite()); } else { team.CreatedDate = DateTime.Now.ToShortDateString(); team.TeamGuid = Guid.NewGuid(); // Set owner list var teamOwnersStr = team.TeamOwners.Split(';'); TeamSite addedTeam = team.ToTeamSite(); addedTeam.TeamOwners = new List <User>(); foreach (var t in teamOwnersStr) { if (t.Trim() != "") { addedTeam.TeamOwners.Add(_userRepository.GetUserByName(t)); } } Domain.MainBoundedContext.Tiles.Aggregates.Tile tile = new Domain.MainBoundedContext.Tiles.Aggregates.Tile(); //INSERT INTO Tiles VALUES('All Reports','1',@TeamSiteID,2,null,4,0,0,1,1,'#6DC2E9','','','','Centered',0) tile.Title = "All Reports"; tile.IsCustomized = true; tile.TileType = 2; tile.LogicStringType = 4; tile.Top = 0; tile.Left = 0; tile.Width = 1; tile.Height = 1; tile.BackgroundColor = "#6DC2E9"; tile.ReportCountStyle = "Centered"; tile.LogicString = "AllReports"; addedTeam.Tiles.Add(tile); _teamRepository.Add(addedTeam); } } //Submit changes _teamRepository.UnitOfWork.Commit(); return(GetAllTeamSites()); }
public static TeamModel ToTeamModel(TeamSite t) { TeamModel tm = new TeamModel() { Id = t.Id, TeamName = t.Name, TeamGuid = Guid.Parse(t.TeamGUID), TeamOwner = t.TeamOwner, TeamDescription = t.Description, CreatedDate = (DateTime)t.CreatedDate, TeamLogo = t.TeamLogo, TeamTypes = t.TeamTypes }; return(tm); }
public static AppTeamSite ToAppTeamSite(this TeamSite team) { return(new AppTeamSite() { Id = team.Id, TeamDescription = team.TeamDescription, CreatedDate = team.CreatedDateTime.ToShortDateString(), TeamGuid = team.TeamGuid, Segment = team.Segment == null? null:team.Segment.ToAppSegement(), TeamLogo = team.TeamLogo, TeamName = team.TeamName, }); }
public List <TeamSite> GetTeamSites([FromQuery] int id, [FromQuery] string startdate, [FromQuery] string enddate) { string query = "SELECT SessionSite FROM SessionEmployeeTable WHERE EmployeeId=@EmployeeId AND SessionDate=@Date;"; Team team = GetByIdStatic(id); List <string> dates = new List <string>(); List <TeamSite> teamsites = new List <TeamSite>(); for (DateTime dt = DateTime.Parse(startdate); dt <= DateTime.Parse(enddate); dt = dt.AddDays(1)) { dates.Add(dt.ToString("yyyy-MM-dd")); } using (SqlConnection conn = new SqlConnection(Connection.ConnString)) { try { conn.Open(); foreach (string date in dates) { TeamSite teamsite = new TeamSite { Date = date, Day = DateTime.Parse(date).DayOfWeek.ToString(), Members = new List <SessionEmployee>() }; foreach (TeamMember member in team.Members) { SessionEmployee employee = new SessionEmployee(); employee.EmployeeName = member.EmployeeName; List <string> sites = new List <string>(); sites = conn.Query <string>(query, new { date, member.EmployeeId }).ToList(); if (sites.Count < 1) { employee.SessionSite = AbsenceController.GetEmployeeStatus(member.EmployeeId, date); } else if (sites.Count > 0) { employee.SessionSite = string.Join(", ", sites); } teamsite.Members.Add(employee); } teamsites.Add(teamsite); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); } } return(teamsites); }