Ejemplo n.º 1
0
        public void AcceptBy(User user)
        {
            if (Status != WishListItemStatus.Requested &&
                Status != WishListItemStatus.RequestedToDirector)
            {
                throw new CannotAcceptWishListItemWithCurrentStatusException(Status);
            }

            if (Status == WishListItemStatus.Requested)
            {
                if (!user.IsLeaderOf(_owner))
                {
                    throw new UserDoesNotHavePermissionToAcceptRequestedWishListItemException();
                }

                if (ShouldBeRequestedToDirector())
                {
                    State = WishListItemState.RequestedToDirector;
                }
                else
                {
                    State = WishListItemState.Accepted;
                }

                return;
            }

            if (!user.IsDirectorOf(_owner))
            {
                throw new UserDoesNotHavePermissionToAcceptRequestedWishListItemException();
            }

            State = WishListItemState.Accepted;
        }
Ejemplo n.º 2
0
        public void RejectBy(User user)
        {
            if (Status != WishListItemStatus.Requested &&
                Status != WishListItemStatus.RequestedToDirector)
            {
                throw new CannotRejectWishListItemWithCurrentStatusException(Status);
            }

            if (Status == WishListItemStatus.Requested)
            {
                if (!user.IsLeaderOf(_owner))
                {
                    throw new UserDoesNotHavePermissionToRejectRequestedWishListItemException();
                }

                State = WishListItemState.Rejected;

                return;
            }

            if (!user.IsDirectorOf(_owner))
            {
                throw new UserDoesNotHavePermissionToRejectRequestedWishListItemException();
            }

            State = WishListItemState.Rejected;
        }
Ejemplo n.º 3
0
 public WishListItem(
     WishListItemStatus status,
     User owner,
     decimal itemCost,
     bool areCostsInvoiced = true)
 {
     Owner            = owner;
     ItemCost         = itemCost;
     AreCostsInvoiced = areCostsInvoiced;
     State            = WishListItemState.CreateState(status);
 }
Ejemplo n.º 4
0
        public void StartRealizationBy(User user)
        {
            if (Status != WishListItemStatus.Accepted)
            {
                throw new CannotStartWishListItemRealizationWithCurrentStatusException(Status);
            }

            if (!user.IsSupervisor)
            {
                throw new UserDoesNotHavePermissionToStartWishListItemRealizationException();
            }

            State = WishListItemState.InRealization;
        }
Ejemplo n.º 5
0
        public void FinishRealizationBy(User user)
        {
            if (Status != WishListItemStatus.InRealization)
            {
                throw new CannotFinishWishListItemRealizationWithCurrentStatusException(Status);
            }

            if (!user.IsSupervisor)
            {
                throw new UserDoesNotHavePermissionToFinishWishListItemRealizationException();
            }

            if (!_areCostsInvoiced)
            {
                throw new CannotFinishWishListItemRealizationWithNotInvoicedException();
            }

            State = WishListItemState.Realized;
        }