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 });
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}"); } }
private void FirstPicture_PreviewMouseDown(object sender, MouseButtonEventArgs e) { _movePoint1 = e.GetPosition(FirstPicture); FirstPicture.CaptureMouse(); }
private void FirstPicture_PreviewMouseUp(object sender, MouseButtonEventArgs e) { _movePoint1 = null; FirstPicture.ReleaseMouseCapture(); }