示例#1
0
        public TeamListDTO GetById(int id)
        {
            var teams = _teamRepository.GetById(id);

            var team = new TeamListDTO()
            {
                Name       = teams.Name,
                Modality   = teams.Modality,
                QtdPlayers = teams.QtdPlayers
            };

            return(team);
        }
        public TeamListDTO GetById(string id)
        {
            var team = _teams.GetById(id);

            if (team != null)
            {
                var result = new TeamListDTO
                {
                    TeamID            = team.TeamID,
                    TeamLeadID        = team.TeamLeadID,
                    TeamName          = team.TeamName,
                    AmountOfEmployees = team.Employees.Count
                };

                return(result);
            }

            return(new TeamListDTO());
        }
        public List <TeamListDTO> GetTeamsList()
        {
            List <TeamListDTO> retVal = new List <TeamListDTO>();
            string             tName  = "";

            byte[]        tLogo   = new byte[0];
            string[]      dNames  = new string[2];
            List <byte[]> dImages = new List <byte[]>();

            byte[] carImage = new byte[0];
            int    i        = 0;

            using (SqlConnection dbConn = new SqlConnection())
            {
                dbConn.ConnectionString = CONNECTION_STRING;
                dbConn.Open();
                string        sql    = "SELECT t.TeamName, t.TeamLogo, d.Name, d.Image, t.CarImage FROM Team t, Driver d WHERE d.TeamID = t.ID ORDER BY t.TeamName";
                SqlCommand    cmd    = new SqlCommand(sql, dbConn);
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    if (i % 2 == 0)
                    {
                        tName     = reader.GetString(0);
                        tLogo     = reader["TeamLogo"] as byte[];
                        dNames    = new string[2];
                        dNames[0] = reader.GetString(2);
                        dImages   = new List <byte[]>();
                        dImages.Add(reader["Image"] as byte[]);
                        carImage = reader["CarImage"] as byte[];
                    }
                    else
                    {
                        dNames[1] = reader.GetString(2);
                        dImages.Add(reader["Image"] as byte[]);
                        TeamListDTO team = new TeamListDTO(tName, tLogo, dNames, dImages, carImage);
                        retVal.Add(team);
                    }
                    i++;
                }
            }
            return(retVal);
        }
        public IHttpActionResult GetAllTeams()
        {
            team[] _teams = null;
            using (var context = new escorcenterdbEntities())
            {
                _teams = (from t in context.teams where t.Enabled select t).OrderBy(x => x.Name).ToArray <team>();
            }

            if (_teams == null)
            {
                return(Ok());
            }
            TeamDTO[]   _teamsDTO = AutoMapper.Mapper.Map <team[], TeamDTO[]>(_teams);
            TeamListDTO teamList  = new TeamListDTO()
            {
                PageNumber = 1, PageTotal = 1
            };

            teamList.items.AddRange(_teamsDTO);

            return(Ok(teamList));
        }
        public IHttpActionResult CreateNotification([FromBody] NotificationDTO _notification, TeamListDTO _teamList, LeagueDTO _league)
        {
            String         teamsId = "";
            List <TeamDTO> teams   = _teamList.items;

            foreach (TeamDTO t in teams)
            {
                teamsId = teamsId + "<" + t.Id + ">";
            }
            notification n = new notification {
                Content = _notification.Content, Date = DateTime.Parse(_notification.Date), Enabled = true, Title = _notification.Title, TeamsId = teamsId, LeagueId = (int)_league.Id
            };

            using (var context = new escorcenterdbEntities())
            {
                context.notifications.Add(n);
                context.SaveChanges();
            }
            return(Ok());
        }