public string Get(int vkId, string type)
        {
            string result = ResultHelper.Error(ExceptionEnum.WrongRequest);

            List <DAL.Donation> donations = DonationRepository.GetDonationByVkId(vkId);

            if (donations == null)
            {
                return(ResultHelper.Error(ExceptionEnum.DBException));
            }
            switch (type)
            {
            //получить все успешные донации
            case "successful":
                List <DAL.Donation> successDonations = donations.Where(d => d.donation_success == true).ToList();
                result = JsonConvert.SerializeObject(successDonations);
                break;

            //текущий timeline, в котором пользователь находится
            case "timeline":
                //если есть таймлайн в процессе (не finished) - выдаём его
                DAL.Donation timelineDonation = donations.Where(d => d.finished == false).ToList().LastOrDefault();
                //если в процессе таймлайна нет - создаём его
                if (timelineDonation == null)
                {
                    //вычислить дату после которой донор может записаться на донацию
                    DateTime appointmentFrom = DateTime.Now;
                    DAL.User user            = UserRepository.GetUserByVkId(vkId);
                    if (user != null && user.donor_pause_to.HasValue && user.donor_pause_to.Value > DateTime.Now)
                    {
                        appointmentFrom = UserRepository.GetUserByVkId(vkId).donor_pause_to.Value;
                    }
                    DAL.Donation newAppointment = new DAL.Donation()
                    {
                        vk_id = vkId, appointment_date_from = appointmentFrom, appointment_date_to = appointmentFrom.AddDays(7)
                    };
                    timelineDonation = newAppointment;
                    DonationRepository.AddDonation(timelineDonation);
                }

                result = JsonConvert.SerializeObject(timelineDonation);

                break;
            }

            return(result);
        }
        public static async Task <string> GetBloodStationsByVkIdTask(int vkId)
        {
            var    apiKey  = ConfigurationManager.AppSetting["AppSettings:DonorSearchApiKey"];
            var    apiPath = ConfigurationManager.AppSetting["AppSettings:DonorSearchApiPath"];
            string stationsJson;

            //var currentUserJson = await DSUser.GetUserByVKId(vkId);
            //var currentUser = JsonConvert.DeserializeObject<DAL.User>(currentUserJson);
            var currentUser = UserRepository.GetUserByVkId(vkId);

            var cityId = currentUser.city_id;

            if (!cityId.HasValue || cityId == 0)
            {
                return("[]");
            }

            using (var graphQlClient = new GraphQLClient(apiPath + apiKey))
            {
                var stationsRequest = new GraphQLRequest
                {
                    Query         = @"query blood_stations($city_id: Int) {
                      blood_stations(city_id: $city_id) {
                        accept_first_timers
                        address
                        blood_type_name
                        can_get_pdr
                        city {
                          id
                          title
                        }
                        created_at
                        email
                        errors {
                          key
                        }
                        fax
                        id
                        lat
                        lng
                        need_requests {
                          blood_type {
                            created_at
                            display_title
                            id
                            title
                            updated_at
                          }
                          end_time
                          id
                          intensity
                          is_disabled
                          start_time
                          when_is_it
                        }
                        no_registration
                        phones
                        site
                        title
                        updated_at
                        without_registration
                        works_on_monday
                        works_on_tuesday
                        works_on_wednesday
                        works_on_thursday
                        works_on_friday
                        works_on_saturday
                        works_on_sunday
                      }
                    }",
                    OperationName = "blood_stations",
                    Variables     = new
                    {
                        city_id = cityId   //TODO  query
                    }
                };

                var graphQlResponse = await graphQlClient.PostAsync(stationsRequest);

                var stations = graphQlResponse.GetDataFieldAs <List <DSBloodStation> >("blood_stations");

                foreach (var station in stations)
                {
                    //station.requrement_of_user_blood = GetRandomNumber(0,2);

                    //check if station accepts first timers

                    station.accept_first_timers = DonationRepository.GetDonationByVkId(currentUser.vk_id)
                                                  .All(c => cityId != currentUser.city_id);

                    var necessity = currentUser.CheckForBloodNeccesity(station.need_requests);
                    //chech for requirement of blood for current user
                    if (necessity >= 50)
                    {
                        station.requrement_of_user_blood = -2;
                    }
                    if (necessity < 50)
                    {
                        station.requrement_of_user_blood = -1;
                    }
                    if (necessity == 0)
                    {
                        station.requrement_of_user_blood = 0;
                    }

                    //check if station accepts users without registration
                    if (currentUser.has_registration.HasValue && !currentUser.has_registration.Value &&
                        station.without_registration.Value)
                    {
                        station.requrement_of_user_blood = 0;
                    }
                }

                stationsJson = JsonConvert.SerializeObject(stations);
            }

            return(stationsJson);
        }