public ActionResult ActionEdit(TOURIS_TV_COUNTRY countryView) { ResultStatus rs = new ResultStatus(); try { countryView.LAST_MODIFIED_BY = CurrentUser.GetCurrentUserId(); countryView.LAST_MODIFIED_TIME = CurrentUser.GetCurrentDateTime(); rs = JsonConvert.DeserializeObject <ResultStatus>(ParsingObject.JsonData(countryView, "Country", "EditObjCountry")); 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 ActionDelete(TOURIS_TV_COUNTRY countryView) { ResultStatus rs = new ResultStatus(); try { rs = JsonConvert.DeserializeObject <ResultStatus>(ParsingObject.JsonData(countryView, "Country", "DeleteObjCountry")); if (rs.IsSuccess) { rs.SetSuccessStatus("Data has been deleted successfully"); TempData["msgSuccess"] = rs.MessageText; } else { rs.SetErrorStatus("Data failed to deleted"); TempData["msgError"] = rs.MessageText; } } catch (Exception ex) { ModelState.AddModelError("", ex.Message); rs.SetErrorStatus("Data failed to deleted"); TempData["msgError"] = rs.MessageText; } return(RedirectToAction("Index")); }
public ApiGridResponse DeleteDataCountry(TOURIS_TV_COUNTRY countryView) { ApiGridResponse res = new ApiGridResponse(); ResultStatus rs = new ResultStatus(); try { using (TourismpediaEntities tourisdb = new TourismpediaEntities()) { TOURIS_TM_COUNTRY country = tourisdb.TOURIS_TM_COUNTRY.Find(countryView.ID); tourisdb.TOURIS_TM_COUNTRY.Remove(country); tourisdb.SaveChanges(); rs.SetSuccessStatus(); } res = ResGetDataTable(new object[] { rs }, null); } catch (Exception ex) { rs.SetErrorStatus(ex.Message); res = ResGetDataTable(new object[] { rs }, ex); } return(res); }
public ApiGridResponse InsertDataCountry(TOURIS_TV_COUNTRY countryView) { ApiGridResponse res = new ApiGridResponse(); ResultStatus rs = new ResultStatus(); try { TOURIS_TM_COUNTRY country = new TOURIS_TM_COUNTRY(); using (TourismpediaEntities tourisdb = new TourismpediaEntities()) { country.COUNTRY_CODE = countryView.COUNTRY_CODE; country.COUNTRY_NAME = countryView.COUNTRY_NAME; country.COUNTRY_DESCRIPTION = countryView.COUNTRY_DESCRIPTION; country.CREATED_BY = countryView.CREATED_BY; country.CREATED_TIME = countryView.CREATED_TIME; tourisdb.TOURIS_TM_COUNTRY.Add(country); tourisdb.SaveChanges(); rs.SetSuccessStatus(); } res = ResGetDataTable(new object[] { rs }, null); } catch (Exception ex) { rs.SetErrorStatus(ex.Message); res = ResGetDataTable(new object[] { rs }, ex); } return(res); }
public ApiGridResponse EditDataCountry(TOURIS_TV_COUNTRY countryView) { ApiGridResponse res = new ApiGridResponse(); ResultStatus rs = new ResultStatus(); try { using (TourismpediaEntities tourisdb = new TourismpediaEntities()) { TOURIS_TM_COUNTRY country = tourisdb.TOURIS_TM_COUNTRY.Find(countryView.ID); country.COUNTRY_CODE = countryView.COUNTRY_CODE; country.COUNTRY_NAME = countryView.COUNTRY_NAME; country.COUNTRY_DESCRIPTION = countryView.COUNTRY_DESCRIPTION; country.LAST_MODIFIED_BY = countryView.LAST_MODIFIED_BY; country.LAST_MODIFIED_TIME = countryView.LAST_MODIFIED_TIME; tourisdb.Entry(country).State = EntityState.Modified; tourisdb.SaveChanges(); rs.SetSuccessStatus(); } res = ResGetDataTable(new object[] { rs }, null); } catch (Exception ex) { rs.SetErrorStatus(ex.Message); res = ResGetDataTable(new object[] { rs }, ex); } return(res); }
public IHttpActionResult RetrieveData(int id) { ApiResData res = new ApiResData(); try { TOURIS_TM_COUNTRY country = repo.Retrieve(id); TOURIS_TV_COUNTRY countryView = new TOURIS_TV_COUNTRY(); if (country != null) { countryView.ID = country.ID; countryView.COUNTRY_CODE = country.COUNTRY_CODE; countryView.COUNTRY_NAME = country.COUNTRY_NAME; countryView.COUNTRY_DESCRIPTION = country.COUNTRY_DESCRIPTION; countryView.CREATED_BY = country.CREATED_BY; countryView.CREATED_TIME = country.CREATED_TIME; countryView.LAST_MODIFIED_BY = country.LAST_MODIFIED_BY; countryView.LAST_MODIFIED_TIME = country.LAST_MODIFIED_TIME; rs.SetSuccessStatus(); } resObj = JObject.FromObject(res.ResGetDataTable(new object[] { countryView }, 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 ActionCreate(TOURIS_TV_COUNTRY countryView) { try { countryView.CREATED_BY = CurrentUser.GetCurrentUserId(); countryView.CREATED_TIME = CurrentUser.GetCurrentDateTime(); rs = JsonConvert.DeserializeObject <ResultStatus>(ParsingObject.RequestData(countryView, "Country", "Add", EnumList.IHttpMethod.Post.ToString())); if (rs.IsSuccess) { rs.SetSuccessStatus("Data has been created successfully"); TempData["msgSuccess"] = rs.MessageText; } else { rs.SetErrorStatus("Data failed to created"); TempData["msgError"] = rs.MessageText; } } catch (Exception ex) { ModelState.AddModelError("", ex.Message); rs.SetErrorStatus("Data failed to created"); TempData["msgError"] = rs.MessageText; } return(RedirectToAction("Index")); }
public ActionResult Edit(int id) { TOURIS_TV_COUNTRY countryView = new TOURIS_TV_COUNTRY(); TOURIS_TV_COUNTRY countryRes = new TOURIS_TV_COUNTRY(); countryView.ID = id; countryRes = JsonConvert.DeserializeObject <TOURIS_TV_COUNTRY>(ParsingObject.JsonData(countryView, "Country", "RetrieveObjCountry")); return(View(countryRes)); }
public ActionResult Edit(int id) { TOURIS_TV_COUNTRY countryView = new TOURIS_TV_COUNTRY(); TOURIS_TV_COUNTRY countryRes = new TOURIS_TV_COUNTRY(); countryView.ID = id; countryRes = JsonConvert.DeserializeObject <TOURIS_TV_COUNTRY>(ParsingObject.RequestData(id, "Country", "RetrieveData", EnumList.IHttpMethod.Put.ToString())); return(View(countryRes)); }
public static SelectList GetCountryList() { List <TOURIS_TV_COUNTRY> countries = JsonConvert.DeserializeObject <List <TOURIS_TV_COUNTRY> >(ParsingObject.RequestData(null, "Country", "GridBind", EnumList.IHttpMethod.Get.ToString())); TOURIS_TV_COUNTRY country = new TOURIS_TV_COUNTRY { ID = 0, COUNTRY_NAME = "Select Country :" }; countries.Add(country); var countriesList = countries.OrderBy(x => x.ID); SelectList selectList = new SelectList(countriesList, "ID", "COUNTRY_NAME"); return(selectList); }
public ApiGridResponse RetrieveDataCountryList() { ResultStatus rs = new ResultStatus(); ApiGridResponse res = new ApiGridResponse(); try { List <TOURIS_TM_COUNTRY> countries = new List <TOURIS_TM_COUNTRY>(); List <TOURIS_TV_COUNTRY> countryViews = new List <TOURIS_TV_COUNTRY>(); using (TourismpediaEntities tourisdb = new TourismpediaEntities()) { countries = tourisdb.TOURIS_TM_COUNTRY.ToList(); } if (countries.Count > 0) { foreach (var item in countries) { TOURIS_TV_COUNTRY countryView = new TOURIS_TV_COUNTRY(); countryView.ID = item.ID; countryView.COUNTRY_CODE = item.COUNTRY_CODE; countryView.COUNTRY_NAME = item.COUNTRY_NAME; countryView.COUNTRY_DESCRIPTION = item.COUNTRY_DESCRIPTION; countryView.CREATED_BY = item.CREATED_BY; countryView.CREATED_TIME = item.CREATED_TIME; countryView.LAST_MODIFIED_BY = item.LAST_MODIFIED_BY; countryView.LAST_MODIFIED_TIME = item.LAST_MODIFIED_TIME; countryViews.Add(countryView); } rs.SetSuccessStatus(); } res = ResGetDataTable(new object[] { countryViews }, null); } catch (Exception ex) { rs.SetErrorStatus(ex.Message); res = ResGetDataTable(new object[] { rs }, ex); } return(res); }
public IHttpActionResult Add(TOURIS_TV_COUNTRY countryView) { 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_COUNTRY country = new TOURIS_TM_COUNTRY(); country.COUNTRY_CODE = countryView.COUNTRY_CODE; country.COUNTRY_NAME = countryView.COUNTRY_NAME; country.COUNTRY_DESCRIPTION = countryView.COUNTRY_DESCRIPTION; country.CREATED_BY = countryView.CREATED_BY; country.CREATED_TIME = countryView.CREATED_TIME; country.ROW_STATUS = eStat.fg.IsActive; rs = repo.Add(country); 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_COUNTRY> countries = repo.GridBind(); List <TOURIS_TV_COUNTRY> countryViews = new List <TOURIS_TV_COUNTRY>(); if (countries.Count > 0) { foreach (var item in countries) { TOURIS_TV_COUNTRY countryView = new TOURIS_TV_COUNTRY(); countryView.ID = item.ID; countryView.COUNTRY_CODE = item.COUNTRY_CODE; countryView.COUNTRY_NAME = item.COUNTRY_NAME; countryView.COUNTRY_DESCRIPTION = item.COUNTRY_DESCRIPTION; countryView.CREATED_BY = item.CREATED_BY; countryView.CREATED_TIME = item.CREATED_TIME; countryView.LAST_MODIFIED_BY = item.LAST_MODIFIED_BY; countryView.LAST_MODIFIED_TIME = item.LAST_MODIFIED_TIME; countryViews.Add(countryView); } rs.SetSuccessStatus(); } resObj = JObject.FromObject(res.ResGetDataTable(new object[] { countryViews }, 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 JObject DeleteObjCountry(string param) { TOURIS_TV_COUNTRY country = JsonConvert.DeserializeObject <TOURIS_TV_COUNTRY>(param); return(JObject.FromObject(countryF.DeleteDataCountry(country))); }