Exemple #1
0
        public IHttpActionResult GetCity(int id)
        {
            City city = db.Cities.Find(id);

            if (city == null)
            {
                return(NotFound());
            }
            DTO_City dcity = new DTO_City();

            city.ConvertToDTO(dcity);

            return(Ok(dcity));
        }
Exemple #2
0
        // GET: api/Cities
        public List <DTO_City> GetCities()
        {
            var cities = db.Cities;

            List <DTO_City> dcities = new List <DTO_City>();

            foreach (City city in cities)
            {
                DTO_City dcity = new DTO_City();
                city.ConvertToDTO(dcity);
                dcities.Add(dcity);
            }

            return(dcities);
        }
        public List <DTO_City> GetCityByStateId(int id)
        {
            List <DTO_City> dcities = new List <DTO_City>();

            List <City> cities = db.Cities.Where(x => x.State_Id == id).ToList();

            foreach (City city in cities)
            {
                DTO_City dcity = new DTO_City();

                city.ConvertToDTO(dcity);

                dcities.Add(dcity);
            }

            return(dcities);
        }
Exemple #4
0
 public void ConvertToDTO(DTO_City dcity)
 {
     dcity.City_Id   = City_Id;
     dcity.City_Name = City_Name;
     dcity.State_Id  = State_Id;
 }