コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        public void TeamController_PostTeam_ShouldReturnOk()
        {
            var team   = new TeamCreate {
            };
            var result = _controller.Post(team);

            Assert.AreEqual(1, _mockService.CallCount);
            Assert.IsInstanceOfType(result, typeof(OkResult));
        }
コード例 #4
0
 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();
 }
コード例 #5
0
        //create a team
        public bool CreateTeam(TeamCreate model)
        {
            Team entity = new Team
            {
                TeamName = model.TeamName
            };

            _context.Teams.Add(entity);
            return(_context.SaveChanges() == 1);
        }
コード例 #6
0
        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);
            }
        }
コード例 #7
0
        public ActionResult Create(TeamCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateTeamService();

            service.CreateTeam(model);

            return(RedirectToAction("Index"));
        }
コード例 #8
0
        //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"));
        }
コード例 #9
0
        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);
            }
        }
コード例 #10
0
        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);
            }
        }
コード例 #11
0
        public IHttpActionResult Post(TeamCreate team)
        {
            PopulateTeamService();

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (!_teamService.CreateTeam(team))
            {
                return(InternalServerError());
            }
            return(Ok());
        }
コード例 #12
0
        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);
            }
        }
コード例 #13
0
ファイル: TeamService.cs プロジェクト: Anthony-Mauk/LeagueApp
        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);
            }
        }
コード例 #14
0
        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);
            }
        }
コード例 #15
0
        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);
            }
        }
コード例 #16
0
        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());
        }
コード例 #17
0
        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);
            }
        }
コード例 #18
0
ファイル: TeamService.cs プロジェクト: brawebdev/Komodo
        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);
            }
        }
コード例 #19
0
        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);
            }
        }
コード例 #20
0
        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));
        }
コード例 #21
0
        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));
        }
コード例 #22
0
        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);
            }
        }
コード例 #23
0
        // 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);
        }
コード例 #24
0
        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));
        }
コード例 #25
0
        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"));
        }
コード例 #26
0
        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());
        }
コード例 #27
0
        /// <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));
        }
コード例 #28
0
        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));
        }
コード例 #29
0
 public bool CreateTeam(TeamCreate model)
 {
     CallCount++;
     return(ReturnValue);
 }