Example #1
0
        public IHttpActionResult RetrieveData(int id)
        {
            ApiResData res = new ApiResData();

            try
            {
                TOURIS_TM_DISTRICT district     = repo.Retrieve(id);
                TOURIS_TV_DISTRICT districtView = new TOURIS_TV_DISTRICT();

                if (district != null)
                {
                    districtView.ID                   = district.ID;
                    districtView.COUNTRY_ID           = district.TOURIS_TM_CITY.TOURIS_TM_PROVINCE.TOURIS_TM_COUNTRY.ID;
                    districtView.COUNTRY_NAME         = district.TOURIS_TM_CITY.TOURIS_TM_PROVINCE.TOURIS_TM_COUNTRY.COUNTRY_NAME;
                    districtView.PROVINCE_ID          = district.TOURIS_TM_CITY.TOURIS_TM_PROVINCE.ID;
                    districtView.PROVINCE_NAME        = district.TOURIS_TM_CITY.TOURIS_TM_PROVINCE.PROVINCE_NAME;
                    districtView.CITY_ID              = district.TOURIS_TM_CITY.ID;
                    districtView.CITY_NAME            = district.TOURIS_TM_CITY.CITY_NAME;
                    districtView.DISTRICT_CODE        = district.DISTRICT_CODE;
                    districtView.DISTRICT_NAME        = district.DISTRICT_NAME;
                    districtView.DISTRICT_DESCRIPTION = district.DISTRICT_DESCRIPTION;
                    districtView.CREATED_BY           = district.CREATED_BY;
                    districtView.CREATED_TIME         = district.CREATED_TIME;
                    districtView.LAST_MODIFIED_BY     = district.LAST_MODIFIED_BY;
                    districtView.LAST_MODIFIED_TIME   = district.LAST_MODIFIED_TIME;
                    rs.SetSuccessStatus();
                }
                resObj = JObject.FromObject(res.ResGetDataTable(new object[] { districtView }, 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));
            }
        }