Ejemplo n.º 1
0
        private bool IsValid(AddWriterCommand command)
        {
            bool isValid = true;

            if (string.IsNullOrEmpty(command.Name))
            {
                AddError("نام را وارد کنید");
                isValid = false;
            }
            else if (_writerQueryRepository.IsExist(command.Name))
            {
                AddError("این نام وجود دارد");
                isValid = false;
            }
            if (command.Photo != null)
            {
                if (!string.IsNullOrEmpty(command.Photo.FileUrl) && string.IsNullOrEmpty(command.Photo.FileType))
                {
                    AddError("فایل آپلود نشده است");
                    isValid = false;
                }
                if (string.IsNullOrEmpty(command.Photo.FileUrl) && !string.IsNullOrEmpty(command.Photo.FileType))
                {
                    AddError("نوع فایل مشکل دارد");
                    isValid = false;
                }
            }
            return(isValid);
        }
        private bool IsValid(UpdateWriterCommand command)
        {
            bool isValid = true;

            if (!_writerQueryRepository.IsExist(command.WriterId))
            {
                AddError("این نویسنده وجود ندارد");
                isValid = false;
            }
            else if (string.IsNullOrEmpty(command.Name) && command.Photo == null)
            {
                AddError("یک فیلد را تغییر دهید");
                isValid = false;
            }
            return(isValid);
        }