Esempio n. 1
0
        public void CancelOrder(int userId)
        {
            Incomplete incomplete = context.Incomplete
                                    .Include(o => o.IncompletePizza)
                                    .ThenInclude(o => o.IncompleteToppings)
                                    .Where(o => o.Userid == userId).FirstOrDefault();

            if (incomplete != null)
            {
                context.Remove(incomplete);
                context.SaveChanges();
            }
        }
Esempio n. 2
0
        public PlaceTokenResponse Execute(PlaceTokenRequest request)
        {
            Board board = request.Board;

            System.Exception error  = null;
            IBoardStatus     status = new Incomplete();

            try
            {
                ValidateTokenType(request);
                ValidatePositionFree(request);
                ValidateBoardIncomplete(request);

                board = _boardGateway.Write(request.Board, request.Type, request.Column, request.Row);

                _boardGateway.Flush(board);
            }
            catch (IndexOutOfRangeException)
            {
                error = new OffBoardException();
            }
            catch (AlreadyPlacedException)
            {
                error = new AlreadyPlacedException();
            }
            catch (InvalidTokenException)
            {
                error = new InvalidTokenException();
            }
            catch (BoardCompleteException)
            {
                error = new BoardCompleteException();
            }

            return(new PlaceTokenResponse
            {
                Board = board,
                Error = error,
                Status = board.IsComplete() ? (IBoardStatus) new Complete() : new Incomplete(),
            });
        }