Пример #1
0
        public IHttpActionResult GridBind()
        {
            ApiResData res = new ApiResData();

            try
            {
                List <TOURIS_TM_CITY> cities    = repo.GridBind();
                List <TOURIS_TV_CITY> cityViews = new List <TOURIS_TV_CITY>();

                if (cities.Count > 0)
                {
                    foreach (var item in cities)
                    {
                        TOURIS_TV_CITY cityView = new TOURIS_TV_CITY();
                        cityView.ID                 = item.ID;
                        cityView.PROVINCE_ID        = item.PROVINCE_ID;
                        cityView.PROVINCE_NAME      = item.TOURIS_TM_PROVINCE.PROVINCE_NAME;
                        cityView.COUNTRY_NAME       = item.TOURIS_TM_PROVINCE.TOURIS_TM_COUNTRY.COUNTRY_NAME;
                        cityView.CITY_CODE          = item.CITY_CODE;
                        cityView.CITY_NAME          = item.CITY_NAME;
                        cityView.CITY_DESCRIPTION   = item.CITY_DESCRIPTION;
                        cityView.CREATED_BY         = item.CREATED_BY;
                        cityView.CREATED_TIME       = item.CREATED_TIME;
                        cityView.LAST_MODIFIED_BY   = item.LAST_MODIFIED_BY;
                        cityView.LAST_MODIFIED_TIME = item.LAST_MODIFIED_TIME;

                        cityViews.Add(cityView);
                    }
                    rs.SetSuccessStatus();
                }
                resObj = JObject.FromObject(res.ResGetDataTable(new object[] { cityViews }, null));
                return(Content(HttpStatusCode.OK, resObj));
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
                resObj = JObject.FromObject(res.ResGetDataTable(new object[] { rs }, new Exception(eFunc.fg.DataNf)));
                return(Content(HttpStatusCode.BadRequest, resObj));
            }
        }