예제 #1
0
        public List <RequestServiceModel> GetFriendRequests(int userId, string status)
        {
            List <RequestServiceModel> list = new List <RequestServiceModel>();

            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                SqlCommand cmd = new SqlCommand("tdb_frr_all", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                conn.Open();

                cmd.Parameters.AddWithValue("@usr_id", userId);
                cmd.Parameters.AddWithValue("@req_status", status);
                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        if (reader.HasRows)
                        {
                            RequestServiceModel friend = new RequestServiceModel
                            {
                                FriendId = int.Parse(reader["user_id"].ToString())
                            };

                            list.Add(friend);
                        }
                    }
                }
                conn.Close();
            }
            return(list);
        }
예제 #2
0
 public void requestedsucess(string result)
 {
     RequestServiceModel = new RequestServiceModel();
     Servicecategoryname = "";
     Servicedescription  = "";
     App.Current.MainPage.DisplayAlert("HMS", result, "OK");
     OnPropertyChanged("RequestServiceModel");
     OnPropertyChanged("Servicecategoryname");
     OnPropertyChanged("Servicedescription");
 }
예제 #3
0
        public async void RequestServiceByStudent(RequestServiceModel requestServiceModel)
        {
            CourseResponse      courseResponse;
            CourseErrorResponse courseErrorResponse;

            try
            {
                UserDialogs.Instance.ShowLoading();
                var client = new HttpClient();
                client.BaseAddress = new Uri(ApplicationURL.BaseURL);
                client.DefaultRequestHeaders.Add("studentId", App.userid);
                string jsn = JsonConvert.SerializeObject(requestServiceModel);

                var content = new StringContent(jsn, Encoding.UTF8, "application/json");

                HttpResponseMessage response = await client.PostAsync(ApplicationURL.ServiceRequestByStudent, content);

                if ((int)response.StatusCode == 200)
                {
                    UserDialogs.Instance.HideLoading();
                    string resultHostel = await response.Content.ReadAsStringAsync();

                    courseResponse = JsonConvert.DeserializeObject <CourseResponse>(resultHostel);
                    iservicecategory.requestedsucess(courseResponse.message);
                }
                else
                {
                    UserDialogs.Instance.HideLoading();
                    string resultHostel = await response.Content.ReadAsStringAsync();

                    courseErrorResponse = JsonConvert.DeserializeObject <CourseErrorResponse>(resultHostel);
                    iservicecategory.failer(courseErrorResponse.errors[0].message);
                }
            }
            catch (Exception ex)
            {
                UserDialogs.Instance.HideLoading();
                await App.Current.MainPage.DisplayAlert("HMS", ex.ToString(), "OK");
            }
        }