protected override void EnsureValidState()
 {
     var valid = Id != null &&
                 OwnerId != null &&
                 (State switch
     {
         ClassifiedAdState.PendingReview => Title != null &&
         Text != null && Price?.Amount > 0 &&
         FirstPicture.HasCorrectSize(),
         ClassifiedAdState.Active =>
         Title != null &&
         Text != null &&
         Price?.Amount > 0 &&
         FirstPicture.HasCorrectSize() &&
         ApprovedBy != null,
         _ => true
     });
Exemple #2
0
        protected override void EnsureValiedState()
        {
            var valid = Id != null && OwnerId != null;

            switch (State)
            {
            case ClassifiedAdState.PendingReview:
                valid = valid && Title != null && Text != null && Price?.Amount > 0 && FirstPicture.HasCorrectSize();
                break;

            case ClassifiedAdState.Active:
                valid = Title != null && Text != null && Price?.Amount > 0 && FirstPicture.HasCorrectSize() && ApprovedBy != null;
                break;

            default:
                valid = true;
                break;
            }

            if (!valid)
            {
                throw new InvalidEntityStateException(this, $"Post-checks faild in state {State}");
            }
        }
Exemple #3
0
 private void FirstPicture_PreviewMouseDown(object sender, MouseButtonEventArgs e)
 {
     _movePoint1 = e.GetPosition(FirstPicture);
     FirstPicture.CaptureMouse();
 }
Exemple #4
0
 private void FirstPicture_PreviewMouseUp(object sender, MouseButtonEventArgs e)
 {
     _movePoint1 = null;
     FirstPicture.ReleaseMouseCapture();
 }