public ResultStatus Add(TOURIS_TM_DISTRICT district) { try { _ctx.TOURIS_TM_DISTRICT.Add(district); _ctx.SaveChanges(); rs.SetSuccessStatus(); } catch (Exception ex) { rs.SetErrorStatus(ex.Message); } return(rs); }
public IHttpActionResult Add(TOURIS_TV_DISTRICT districtView) { ApiResData res = new ApiResData(); try { if (!ModelState.IsValid) { rs.SetErrorStatus(eFunc.fg.SFailed); resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Save, new Exception(eFunc.fg.DataIsntValid))); return(Content(HttpStatusCode.NotFound, resObj)); } TOURIS_TM_DISTRICT district = new TOURIS_TM_DISTRICT(); district.CITY_ID = districtView.CITY_ID; district.DISTRICT_CODE = districtView.DISTRICT_CODE; district.DISTRICT_NAME = districtView.DISTRICT_NAME; district.DISTRICT_DESCRIPTION = districtView.DISTRICT_DESCRIPTION; district.CREATED_BY = districtView.CREATED_BY; district.CREATED_TIME = districtView.CREATED_TIME; district.ROW_STATUS = eStat.fg.IsActive; rs = repo.Add(district); if (rs.IsSuccess) { rs.SetSuccessStatus(); } else { rs.SetErrorStatus(eFunc.fg.SFailed); } resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Save, null)); return(Content(HttpStatusCode.OK, resObj)); } catch (Exception ex) { rs.SetErrorStatus(ex.Message); resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Save, new Exception(eFunc.fg.SFailed))); return(Content(HttpStatusCode.BadRequest, resObj)); } }
public IHttpActionResult Edit(TOURIS_TV_DISTRICT ProvinceView) { ApiResData res = new ApiResData(); try { if (!ModelState.IsValid) { rs.SetErrorStatus(eFunc.fg.SFailed); resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Edit, new Exception(eFunc.fg.DataIsntValid))); return(Content(HttpStatusCode.NotFound, resObj)); } TOURIS_TM_DISTRICT district = new TOURIS_TM_DISTRICT(); district.ID = ProvinceView.ID; district.CITY_ID = ProvinceView.CITY_ID; district.DISTRICT_CODE = ProvinceView.DISTRICT_CODE; district.DISTRICT_NAME = ProvinceView.DISTRICT_NAME; district.DISTRICT_DESCRIPTION = ProvinceView.DISTRICT_DESCRIPTION; district.LAST_MODIFIED_TIME = ProvinceView.LAST_MODIFIED_TIME; district.LAST_MODIFIED_BY = ProvinceView.LAST_MODIFIED_BY; rs = repo.Edit(district); if (rs.IsSuccess) { rs.SetSuccessStatus(); } else { rs.SetErrorStatus(eFunc.fg.SFailed); } resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Edit, null)); return(Content(HttpStatusCode.OK, resObj)); } catch (Exception ex) { rs.SetErrorStatus(ex.Message); resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Edit, new Exception(eFunc.fg.EFailed))); return(Content(HttpStatusCode.BadRequest, resObj)); } }
public ResultStatus Delete(int id, string modifiedBy, DateTime modifiedTime) { try { TOURIS_TM_DISTRICT province = _ctx.TOURIS_TM_DISTRICT.Find(id); province.LAST_MODIFIED_TIME = modifiedTime; province.LAST_MODIFIED_BY = modifiedBy; province.ROW_STATUS = eStat.fg.NotActive; _ctx.Entry(province).State = EntityState.Modified; _ctx.SaveChanges(); rs.SetSuccessStatus(); } catch (Exception ex) { rs.SetErrorStatus(ex.Message); } return(rs); }
public ResultStatus Edit(TOURIS_TM_DISTRICT district) { try { TOURIS_TM_DISTRICT districtNew = _ctx.TOURIS_TM_DISTRICT.Find(district.ID); districtNew.CITY_ID = district.CITY_ID; districtNew.DISTRICT_CODE = district.DISTRICT_CODE; districtNew.DISTRICT_NAME = district.DISTRICT_NAME; districtNew.DISTRICT_DESCRIPTION = district.DISTRICT_DESCRIPTION; districtNew.LAST_MODIFIED_TIME = district.LAST_MODIFIED_TIME; districtNew.LAST_MODIFIED_BY = district.LAST_MODIFIED_BY; _ctx.Entry(districtNew).State = System.Data.Entity.EntityState.Modified; _ctx.SaveChanges(); rs.SetSuccessStatus(); } catch (Exception ex) { rs.SetErrorStatus(ex.Message); } return(rs); }
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)); } }