Exemplo n.º 1
0
        public IHttpActionResult GetClubsByCuntryIDAndCityID(int i_CountryID, int i_CityID)
        {
            LogControllerEntring("getclubs");
            IHttpActionResult result = Ok();
            List <ClubModel>  clubs;

            try
            {
                using (MyDiveEntities MyDiveDB = new MyDiveEntities())
                {
                    ObjectResult <stp_GetAllClubsByCountryANDCityId_Result> clubsResult =
                        MyDiveDB.stp_GetAllClubsByCountryANDCityId(i_CountryID, i_CityID);
                    clubs = new List <ClubModel>();

                    foreach (stp_GetAllClubsByCountryANDCityId_Result club in clubsResult)
                    {
                        clubs.Add(new ClubModel
                        {
                            ClubID      = club.ClubID,
                            Name        = club.Name,
                            Phone       = club.Phone,
                            Email       = club.Email,
                            Address     = club.Address,
                            Rating      = club.Rating,
                            SiteURL     = club.SiteURL,
                            Coordinates = new LocationModel {
                                Lat = club.Lat, Long = club.Long
                            }
                        });
                    }

                    LogData("Fetch all clubs", i_CityID.ToString() + i_CountryID.ToString());
                    result = Ok(clubs.Count > 0 ? clubs : null);
                }
            }
            catch (Exception ex)
            {
                clubs  = null;
                result = LogException(ex, null);
            }

            return(result);
        }