예제 #1
0
        public Response RegisterSquad(SquadRequest request)
        {
            var errors = Validate(request);

            if (errors.Count() > 0)
            {
                return(Response.CreateResponse(errors));
            }

            var club = clubQuery.GetClub(request.ClubId);

            if (club == null)
            {
                return(Response.CreateResponse(new EntityNotFoundException("The specified club does not exist")));
            }

            try {
                squadRepository.AddSquad(new Squad(club.Guid)
                {
                    Name = request.SquadName, YearBorn = request.YearBorn
                });
            } catch (Exception ex) {
                return(Response.CreateResponse(ex));
            }

            return(Response.CreateSuccessResponse());
        }