public bool CreateTeam(TeamCreate model, int ProfileID) { var entity = new Team() { UserID = model.UserID, TeamName = model.TeamName, Roster = new List <Profile>(), TeamEvents = new List <Event>() }; using (var ctx = new ApplicationDbContext()) { ctx.Team.Add(entity); if (ctx.SaveChanges() == 1) { var query = ctx .Profile .Where(e => e.ProfileID == ProfileID) .Single(); entity.Roster.Add(query); } return(ctx.SaveChanges() == 3); } }
public bool CreateTeam(TeamCreate model) { var entity = new Team() { OwnerID = _userID, Title = model.Title, Description = model.Description }; var teamData = new TeamData() { TeamID = entity.TeamID, UserID = entity.OwnerID, Private = false }; using (var ctx = new ApplicationDbContext()) { ctx.Teams.Add(entity); ctx.TeamsData.Add(teamData); return(ctx.SaveChanges() == 1); } }
public void TeamController_PostTeam_ShouldReturnOk() { var team = new TeamCreate { }; var result = _controller.Post(team); Assert.AreEqual(1, _mockService.CallCount); Assert.IsInstanceOfType(result, typeof(OkResult)); }
public IHttpActionResult Post(TeamCreate teamCreate, int ProfileID) { teamCreate.UserID = Guid.Parse(User.Identity.GetUserId()); if (!ModelState.IsValid) return BadRequest(ModelState); var service = CreateTeamService(); if (!service.CreateTeam(teamCreate, ProfileID)) return InternalServerError(); return Ok(); }
//create a team public bool CreateTeam(TeamCreate model) { Team entity = new Team { TeamName = model.TeamName }; _context.Teams.Add(entity); return(_context.SaveChanges() == 1); }
public bool TeamCreate(TeamCreate model) { var newTeam = new Team() { Name = model.Name }; using (var ctx = new ApplicationDbContext()) { ctx.Teams.Add(newTeam); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(TeamCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateTeamService(); service.CreateTeam(model); return(RedirectToAction("Index")); }
//post a team public IHttpActionResult Post(TeamCreate team) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateTeamService(); if (!service.CreateTeam(team)) { return(InternalServerError()); } return(Ok("Team was added")); }
public bool CheckDependencyAccess(TeamCreate model) { using (var ctx = new ApplicationDbContext()) { var ownedLeague = ctx.Leagues.FirstOrDefault(league => league.LeagueID == model.LeagueID && (league.OwnerID == _userID || league.OwnerID == _publicGuid)); if (ownedLeague == null) { return(false); } return(true); } }
public bool CreateTeam(TeamCreate model) { var entity = new Team() { TeamName = model.TeamName, }; using (var ctx = new ApplicationDbContext()) { ctx.TeamDb.Add(entity); return(ctx.SaveChanges() == 1); } }
public IHttpActionResult Post(TeamCreate team) { PopulateTeamService(); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (!_teamService.CreateTeam(team)) { return(InternalServerError()); } return(Ok()); }
public bool CreateTeam(TeamCreate model) //creates instance of Team { var entity = new Team() { TeamName = model.TeamName, VenueID = model.VenueID, }; using (var ctx = new ApplicationDbContext()) { ctx.Teams.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool CreateTeam(TeamCreate model) { var entity = new Team() { OwnerId = _userId, Name = model.Name }; using (var ctx = new ApplicationDbContext()) { ctx.Teams.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool CreateTeam(TeamCreate model) { Team team = new Team() { TeamName = model.TeamName, UserId = _userId, TotalPoints = 0 }; using (var ctx = new ApplicationDbContext()) { ctx.Teams.Add(team); return(ctx.SaveChanges() == 1); } }
public bool CreateTeam(TeamCreate model) { var entity = new Team() { SquadId = model.SquadId, Squad = model.Squad, Name = model.Name, Familiar = model.Familiar }; using (var ctx = new ApplicationDbContext()) { ctx.TeamDbSet.Add(entity); return(ctx.SaveChanges() == 1); } }
public IHttpActionResult Post(TeamCreate team) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = new TeamService(Guid.Parse(User.Identity.GetUserId())); if (!service.CreateTeam(team)) { return(InternalServerError()); } return(Ok()); }
public bool CreateTeam(TeamCreate model) { var team = new Team() { CoachID = _userID, TeamName = model.TeamName, TeamDivision = model.TeamDivision }; using (var db = new ApplicationDbContext()) { db.Teams.Add(team); return(db.SaveChanges() == 1); } }
public bool CreateTeam(TeamCreate model) { var entity = new Team() { TeamManagerId = _userId, TeamName = model.TeamName, IsActive = true }; using (var ctx = new ApplicationDbContext()) { ctx.Teams.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool CreateTeam(TeamCreate model) { var entity = new TeamEntity { TeamName = model.TeamName, LeagueID = model.LeagueID, ImageData = model.ImageData, OwnerID = _userID }; using (var ctx = new ApplicationDbContext()) { ctx.Teams.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(TeamCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateTeamService(); if (service.CreateTeam(model)) { TempData["Save Result"] = "Record created."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Unable to create record."); return(View(model)); }
public ActionResult Create(TeamCreate team) { if (!ModelState.IsValid) { return(View(team)); } var service = CreateTeamService(); if (service.CreateTeam(team)) { TempData["SaveResult"] = "Team was added."; return(RedirectToAction("Index")); } return(View(team)); }
public bool CreateTeam(TeamCreate model) { var entity = new Team() { UserId = _userId, TeamName = model.TeamName, CreatedUtc = DateTimeOffset.Now, ModifiedUtc = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.Teams.Add(entity); return(ctx.SaveChanges() == 1); } }
// Teams public static List <TeamCreate> TeamDummyData() { List <TeamCreate> teams = new List <TeamCreate>(); var name = new string[] { "Captain", "CrewMates", "A couple of Guitar Players", "A couple of pianists", "A drummer and singer", "FrontEnd", "BackEnd" }; for (int i = 0; i < name.Length; i++) { var team = new TeamCreate() { Name = name[i], }; teams.Add(team); } return(teams); }
public ActionResult Create(TeamCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateTeamService(); if (service.CreateTeam(model)) { TempData["SaveResult"] = "New team added."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Team could not be created."); return(View(model)); }
public IHttpActionResult PostTeam([FromBody] TeamCreate team) { if (team is null) { return(BadRequest("Cannot use null values.")); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateTeamService(); var isSuccessful = service.CreateTeam(team); if (!isSuccessful) { return(InternalServerError()); } return(Ok("Team Created")); }
public IHttpActionResult Post(TeamCreate model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } TeamService service = CreateTeamService(); if (!service.CheckDependencyAccess(model)) { return(BadRequest("Inaccessible dependency")); } if (service.CreateTeam(model)) { return(Ok()); } return(InternalServerError()); }
/// <summary> /// Create a project team. /// </summary> public IHttpActionResult Post(TeamCreate Team) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateTeamService(); if (!service.TeamCreate(Team)) { return(InternalServerError()); } string newLog = "Team Created"; var logService = CreateLogService(); logService.LogCreate(newLog); return(Ok(newLog)); }
public async Task <IActionResult> CreateTeam(int userId, [FromBody] TeamCreate teamcr) { if (userId != int.Parse(User.FindFirst(ClaimTypes.Name)?.Value)) { return(Unauthorized()); } if (teamcr == null) { return(BadRequest(ModelState)); } var repoTeam = _mapper.Map <Team>(teamcr); repoTeam.UserId = userId; if (!await _tRepo.CreateTeam(userId, repoTeam)) { return(StatusCode(500, ModelState)); } return(Ok(repoTeam)); }
public bool CreateTeam(TeamCreate model) { CallCount++; return(ReturnValue); }