Пример #1
0
        public void AddCheckoutToTeam(int serverTeamId, CheckoutEntity checkout)
        {
            TeamEntity team = teamRepository.GetTeamById(serverTeamId);

            if (checkout.ShiftDate.Date != team.ShiftDate.Date)
            {
                throw new InvalidOperationException("You cannot add a checkout to a team with different shift dates.");
            }

            TeamCheckoutEntity addedCheckout = new TeamCheckoutEntity
            {
                Team      = team,
                Checkout  = checkout,
                ShiftDate = checkout.ShiftDate
            };

            if (teamRepository.CheckoutHasAlreadyBeenAdded(checkout.Id, checkout.ShiftDate))
            {
                throw new InvalidOperationException("That checkout is currently on another team");
            }

            teamRepository.AddCheckoutToTeam(addedCheckout);

            if (!teamRepository.Save())
            {
                throw new Exception("An unexpected error occured while trying to add the checkout to the team.");
            }
        }
Пример #2
0
 public void AddCheckoutToTeam(TeamCheckoutEntity teamCheckout)
 {
     _context.TeamCheckouts.Add(teamCheckout);
 }
Пример #3
0
        public void RemoveCheckoutFromTeam(int teamId, int checkoutId)
        {
            TeamCheckoutEntity teamCheckoutReference = _context.TeamCheckouts.Where(t => t.CheckoutId == checkoutId && t.TeamId == teamId).FirstOrDefault();

            _context.TeamCheckouts.Remove(teamCheckoutReference);
        }