public IHttpActionResult RetrieveData(int id) { ApiResData res = new ApiResData(); try { TOURIS_TM_MENU menu = repo.Retrieve(id); TOURIS_TV_MENU menuView = new TOURIS_TV_MENU(); if (menu != null) { menuView.ID = menu.ID; menuView.MENU_NAME = menu.MENU_NAME; menuView.MENU_DESCRIPTION = menu.MENU_DESCRIPTION; menuView.MENU_PARENT_ID = menu.MENU_PARENT_ID; menuView.CREATED_BY = menu.CREATED_BY; menuView.CREATED_TIME = menu.CREATED_TIME; menuView.LAST_MODIFIED_BY = menu.LAST_MODIFIED_BY; menuView.LAST_MODIFIED_TIME = menu.LAST_MODIFIED_TIME; rs.SetSuccessStatus(); } resObj = JObject.FromObject(res.ResGetDataTable(new object[] { menuView }, 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)); } }
public ResultStatus Add(TOURIS_TM_MENU menu) { try { _ctx.TOURIS_TM_MENU.Add(menu); _ctx.SaveChanges(); rs.SetSuccessStatus(); } catch (Exception ex) { rs.SetErrorStatus(ex.Message); } return(rs); }
public IHttpActionResult Add(TOURIS_TV_MENU menuView) { 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_MENU menu = new TOURIS_TM_MENU(); menu.MENU_NAME = menuView.MENU_NAME; menu.MENU_DESCRIPTION = menuView.MENU_DESCRIPTION; menu.MENU_PARENT_ID = menuView.MENU_PARENT_ID; menu.CREATED_BY = menuView.CREATED_BY; menu.CREATED_TIME = menuView.CREATED_TIME; menu.ROW_STATUS = eStat.fg.IsActive; rs = repo.Add(menu); 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 ResultStatus Delete(int id, string modifiedBy, DateTime modifiedTime) { try { TOURIS_TM_MENU menu = _ctx.TOURIS_TM_MENU.Find(id); menu.LAST_MODIFIED_TIME = modifiedTime; menu.LAST_MODIFIED_BY = modifiedBy; menu.ROW_STATUS = eStat.fg.NotActive; _ctx.Entry(menu).State = EntityState.Modified; _ctx.SaveChanges(); rs.SetSuccessStatus(); } catch (Exception ex) { rs.SetErrorStatus(ex.Message); } return(rs); }
public ResultStatus Edit(TOURIS_TM_MENU menu) { try { TOURIS_TM_MENU menuNew = _ctx.TOURIS_TM_MENU.Find(menu.ID); menuNew.MENU_NAME = menu.MENU_NAME; menuNew.MENU_DESCRIPTION = menu.MENU_DESCRIPTION; menuNew.MENU_PARENT_ID = menu.MENU_PARENT_ID; menuNew.LAST_MODIFIED_TIME = menu.LAST_MODIFIED_TIME; menuNew.LAST_MODIFIED_BY = menu.LAST_MODIFIED_BY; _ctx.Entry(menuNew).State = System.Data.Entity.EntityState.Modified; _ctx.SaveChanges(); rs.SetSuccessStatus(); } catch (Exception ex) { rs.SetErrorStatus(ex.Message); } return(rs); }