-
Notifications
You must be signed in to change notification settings - Fork 2
Добавить в WS3 функции прописи чисел и дат на казахском 2 #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
bzaar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
См. замечания.
| } | ||
|
|
||
| public string GetDate(string date, bool useOne) | ||
| public string GetDate(DateTime dateTime, bool useOne) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Уже была выпущена версия с этим методом. Если его изменить, то поломается обратная совместимость. Лучше добавить новый метод (перегрузку) с параметром DateTime, а этот пометить как Obsolete.
| using (var client = _newClient()) | ||
| { | ||
| client.AddParam("date", date); | ||
| client.AddParam("date", dateTime.ToString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Нужно отформатировать дату. Иначе можешь получить что-нибудь вроде "21. Juni 2020" в зависимости от региональных настроек ОС.
bzaar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
См. комментарии.
| } | ||
| catch (BadRequestException e) when (e.ErrorCode == 19) | ||
| { | ||
| throw new OutOfRangeException(nameof(n)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Какое значение нужно передать в метод GetCardinal, чтобы сервис вернул ответ с кодом 19?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OutOfRangeException будем возвращать если n больше int.Max или меньше int.Min.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Зачем? Сервис умеет строить пропись для всех значений типа long.
| class BadRequestException : Exception | ||
| { | ||
| public int Status { get; } | ||
| public int ErrorCode { get; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Все хорошо, только нужно где-то установить значение ErrorCode. Думаю, лучше это сделать в конструкторе BadRequestException.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ок
bzaar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
См. замечания и прошу для каждого нового метода добавить XML comments и указать исключения, которые он может выбрасывать. Вот так.
| } | ||
| catch (BadRequestException e) when (e.ErrorCode == 19) | ||
| { | ||
| throw new OutOfRangeException(nameof(n)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Зачем? Сервис умеет строить пропись для всех значений типа long.
| public int Status { get; } | ||
| public int ErrorCode { get; } | ||
|
|
||
| public BadRequestException(int status, int errorCode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Конструктор не используется, следовательно, свойство ErrorCode всегда будет 0.
| if (exc.Response is HttpWebResponse httpWebResponse) | ||
| { | ||
| int status = (int)httpWebResponse.StatusCode; | ||
| int errorCode = int.Parse(httpWebResponse.Headers.Get("Error-Code")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ErrorCode находится в теле запроса, а не в заголовке.
string to DateTime