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(); }
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); }