public ActionResult Update(CountriesModel CountriesObj) { //------------------------------------------ //Check ModelState //------------------------------------------ if (!ModelState.IsValid) { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, "Invalid data")); } //------------------------------------------ try { bool result = CountriesFactor.Update(CountriesObj); if (result == true) { return(List(1, 25, null, null, null, null)); } else { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, "Saving operation faild")); } } catch (Exception ex) { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.Message)); } }
public ActionResult GetObject(int id) { try { CountriesModel CountriesObj = CountriesFactor.GetObject(id); if (CountriesObj == null) { CountriesObj = new CountriesModel(); } return(Json(CountriesObj, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.Message)); } }
//*********************************************************************************************** #endregion #region -----------------Delete----------------- //*********************************************************************************************** public ActionResult Delete(int[] ids) { //------------------------------------------ //Check ModelState //------------------------------------------ if (!ModelState.IsValid) { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, "Invalid data")); } //------------------------------------------ try { CountriesFactor.DeleteGroupofObjects(ids); return(List(1, 25, null, null, null, null)); } catch (Exception ex) { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.Message)); } }
//*********************************************************************************************** #endregion #region -----------------List----------------- //*********************************************************************************************** public ActionResult List(int page, int rp, string sortname, string sortorder, string qtype, string query) { try { int pageSize = rp; int totalRecords = 0; List <CountriesModel> CountriesList = CountriesFactor.GetPageByPage(page, pageSize, sortname, sortorder, qtype, query, out totalRecords); if (CountriesList.Count > 0) { return(CreateFlexiJson(CountriesList, page, totalRecords)); } else { return(null); } } catch (Exception ex) { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.Message)); } }
//*********************************************************************************************** // // GET: /Sites/ public ActionResult Index() { FlexigridViewModel flexigrid = new FlexigridViewModel("SitesList", "SitesForm", "SitesPost", "/Sites/List", "json", "Name", "asc", true, "Sites Listing", true, pageSize, true, 950, 2000); flexigrid.Columns = new List <FlexigridColumn>() { new FlexigridColumn("Name", "Name", 105, true, "left", false, false), new FlexigridColumn("Url", "Url", 105, true, "left", false, false), new FlexigridColumn("PhotoFile", "PhotoFile", 105, true, "left", false, false), new FlexigridColumn("LogoFile", "LogoFile", 105, true, "left", false, false), new FlexigridColumn("Brief", "Brief", 105, true, "left", false, false), new FlexigridColumn("Address", "Address", 105, true, "left", false, false), new FlexigridColumn("AgencyTypeID", "AgencyTypeID", 105, true, "left", false, false), new FlexigridColumn("BusinessSectionID", "BusinessSectionID", 105, true, "left", false, false), new FlexigridColumn("CountryID", "CountryID", 105, true, "left", false, false) }; flexigrid.Buttons = new List <FlexigridButton>() { new FlexigridButton("Add", "fgButton", "Add"), new FlexigridButton("Edit", "fgButton", "Edit"), new FlexigridButton("Delete", "fgButton", "Delete") }; flexigrid.DialogBoxId = "SitesDialog"; flexigrid.DialogBoxWidth = 700; flexigrid.DialogBoxHeight = 800; ViewData["flexigrid"] = flexigrid; ViewData["AgencyTypeID"] = AgencyTypesFactor.Get().Select(x => new SelectListItem { Text = x.Title, Value = x.AgencyTypeID.ToString() }).ToList(); ViewData["BusinessSectionID"] = BusinessSectionsFactor.Get().Select(x => new SelectListItem { Text = x.Title, Value = x.BusinessSectionID.ToString() }).ToList(); ViewData["CountryID"] = CountriesFactor.Get().Select(x => new SelectListItem { Text = x.Code, Value = x.CountryID.ToString() }).ToList(); //ViewData["Categories"] = CategoriesFactor.Get().Select(x => new SelectListItem { Text = x.Title, Value = x.CategoryID.ToString() }).ToList(); return(View(new SitesModel())); }