예제 #1
0
파일: Education.cs 프로젝트: SaintCat/VkBot
        internal static Education FromJson(VkResponse response)
        {
            if (response["university"] == null || response["university"].ToString() == "0")
                return null;

            var education = new Education();

            education.UniversityId = Utilities.GetNullableLongId(response["university"]);
            education.UniversityName = response["university_name"];
            education.FacultyId = Utilities.GetNullableLongId(response["faculty"]);
            education.FacultyName = response["faculty_name"];
            education.Graduation = (int?) Utilities.GetNullableLongId(response["graduation"]);

            if (education.UniversityId.HasValue && education.UniversityId == 0)
                education.UniversityId = null;

            if (education.FacultyId.HasValue && education.FacultyId == 0)
                education.FacultyId = null;

            if (education.Graduation.HasValue && education.Graduation == 0)
                education.Graduation = null;

            education.EducationForm = response["education_form"]; // установлено экcпериментальным путем
            education.EducationStatus = response["education_status"]; // установлено экcпериментальным путем

            return education;
        }
예제 #2
0
파일: Education.cs 프로젝트: wowbios/vk
        /// <summary>
        /// Разобрать из json.
        /// </summary>
        /// <param name="response">Ответ сервера.</param>
        /// <returns></returns>
        public static Education FromJson(VkResponse response)
        {
            if (response["university"] == null || response["university"].ToString() == "0")
            {
                return(null);
            }

            var education = new Education
            {
                UniversityId   = Utilities.GetNullableLongId(response["university"]),
                UniversityName = response["university_name"],
                FacultyId      = Utilities.GetNullableLongId(response["faculty"]),
                FacultyName    = response["faculty_name"],
                Graduation     = (int?)Utilities.GetNullableLongId(response["graduation"])
            };

            if (education.UniversityId.HasValue && education.UniversityId == 0)
            {
                education.UniversityId = null;
            }

            if (education.FacultyId.HasValue && education.FacultyId == 0)
            {
                education.FacultyId = null;
            }

            if (education.Graduation.HasValue && education.Graduation == 0)
            {
                education.Graduation = null;
            }

            education.EducationForm   = response["education_form"];           // установлено экcпериментальным путем
            education.EducationStatus = response["education_status"];         // установлено экcпериментальным путем

            return(education);
        }