Skip to content

Commit

Permalink
Исправлена ошибка с отсутствующим ManagerRole, поправлен парсинг bdat…
Browse files Browse the repository at this point in the history
…e_visibility

Если запросить пользователей из группы (менеджеров) и не указать дату рождения как фильтр то возвращало результат до того, как заполняло роль пользователя

Поправлено выставление свойства "bdate_visibility"
  • Loading branch information
CaCTuCaTu4ECKuu committed May 12, 2021
1 parent af8e49c commit c3106f5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
10 changes: 5 additions & 5 deletions VkNet/Enums/BirthdayVisibility.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using VkNet.Utils;
using VkNet.Utils;

namespace VkNet.Enums
{
Expand All @@ -11,14 +11,14 @@ public enum BirthdayVisibility
/// Не показывать дату рождения.
/// </summary>
[DefaultValue]
Invisible = 0
Invisible = 0,

, /// <summary>
/// <summary>
/// Показывать дату рождения.
/// </summary>
Full = 1
Full = 1,

, /// <summary>
/// <summary>
/// Показывать только месяц и день.
/// </summary>
OnlyDayAndMonth = 2
Expand Down
26 changes: 15 additions & 11 deletions VkNet/Model/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,18 +145,8 @@ public static User FromJson(VkResponse response)
}
}

if (user.BirthDate == null || response["bdate_visibility"] != null)
switch (response["role"]?.ToString())
{
return user;
}

var birthdayParts = user.BirthDate.Split('.');

user.BirthdayVisibility = birthdayParts.Length > 2
? Enums.BirthdayVisibility.Full
: Enums.BirthdayVisibility.OnlyDayAndMonth;

switch (response["role"]?.ToString()) {
case "creator":
user.Role = ManagerRole.Creator;
break;
Expand All @@ -174,6 +164,20 @@ public static User FromJson(VkResponse response)
break;
}

if (response["bdate_visibility"] == null)
{
if (!string.IsNullOrEmpty(user.BirthDate))
{
var birthdayParts = user.BirthDate.Split('.');

user.BirthdayVisibility = birthdayParts.Length > 2
? Enums.BirthdayVisibility.Full
: Enums.BirthdayVisibility.OnlyDayAndMonth;
}
}
else
user.BirthdayVisibility = response["bdate_visibility"];

return user;
}

Expand Down

0 comments on commit c3106f5

Please sign in to comment.