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 ActionResult ActionEdit(TOURIS_TV_MENU menuView) { try { menuView.LAST_MODIFIED_BY = CurrentUser.GetCurrentUserId(); menuView.LAST_MODIFIED_TIME = CurrentUser.GetCurrentDateTime(); rs = JsonConvert.DeserializeObject <ResultStatus>(ParsingObject.RequestData(menuView, "Menu", "Edit", EnumList.IHttpMethod.Post.ToString())); if (rs.IsSuccess) { rs.SetSuccessStatus("Data has been edited successfully"); TempData["msgSuccess"] = rs.MessageText; } else { rs.SetErrorStatus("Data failed to edited"); TempData["msgError"] = rs.MessageText; } } catch (Exception ex) { ModelState.AddModelError("", ex.Message); rs.SetErrorStatus("Data failed to edited"); TempData["msgError"] = rs.MessageText; } return(RedirectToAction("Index")); }
public ActionResult Edit(int id) { TOURIS_TV_MENU menuView = new TOURIS_TV_MENU(); TOURIS_TV_MENU menuRes = new TOURIS_TV_MENU(); menuView.ID = id; menuRes = JsonConvert.DeserializeObject <TOURIS_TV_MENU>(ParsingObject.RequestData(id, "Menu", "RetrieveData", EnumList.IHttpMethod.Put.ToString())); return(View(menuRes)); }
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 IHttpActionResult GridBind() { ApiResData res = new ApiResData(); try { List <TOURIS_TM_MENU> menus = repo.GridBind(); List <TOURIS_TV_MENU> menuViews = new List <TOURIS_TV_MENU>(); if (menus.Count > 0) { foreach (var item in menus) { TOURIS_TV_MENU menuView = new TOURIS_TV_MENU(); menuView.ID = item.ID; menuView.MENU_NAME = item.MENU_NAME; menuView.MENU_DESCRIPTION = item.MENU_DESCRIPTION; menuView.MENU_PARENT_ID = item.MENU_PARENT_ID; menuView.CREATED_BY = item.CREATED_BY; menuView.CREATED_TIME = item.CREATED_TIME; menuView.LAST_MODIFIED_BY = item.LAST_MODIFIED_BY; menuView.LAST_MODIFIED_TIME = item.LAST_MODIFIED_TIME; menuViews.Add(menuView); } rs.SetSuccessStatus(); } resObj = JObject.FromObject(res.ResGetDataTable(new object[] { menuViews }, 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)); } }