public ActionResult AddEditState(int id = 0, int pid = 0) { CustomMethods.ValidateRoles("State"); if (!Convert.ToBoolean(Session["IsAdd"]) && !Convert.ToBoolean(Session["IsEdit"])) { return(View("ErrorPage", "Error")); } StateModel StateModel = new StateModel(); int take = 10; int skip = take * pid; StateModel.PageID = pid; StateModel.Current = pid + 1; ViewBag.c = StateModel.PageID; if (id != 0) { var objstate = new StateBLL { }.GetSubStateById(id); if (objstate != null) { StateModel.StateId = objstate.StateId; StateModel.StateName = objstate.StateName; StateModel.CountryId = objstate.CountryId; StateModel.IsActive = Convert.ToBoolean(objstate.IsActive); } } CustomMethods.BindCountryList(StateModel); return(View(StateModel)); }
public int DALStateInsert(StateBLL st) { using (SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"])) { try { SqlParameter[] par = new SqlParameter[3]; par[0] = new SqlParameter("@stateName", st.stateName); par[1] = new SqlParameter("@countryId", st.countryId); par[2] = new SqlParameter("@status", 100); par[2].Direction = ParameterDirection.Output; SqlHelper.ExecuteNonQuery(con, CommandType.StoredProcedure, "spStateInsert", par); status = (int)par[2].Value; } catch (Exception ex) { throw ex; } finally { con.Close(); } } return(status); }
public bool BLLIsExistStateName(StateBLL st) { bool flag = false; flag = stateDALObj.DALIsExistCountryName(st); return(flag); }
public bool DALIsExistCountryName(StateBLL st) { bool flag = false; string row = ""; using (SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"])) { try { SqlParameter[] par = new SqlParameter[2]; par[0] = new SqlParameter("@stateName", st.stateName); par[1] = new SqlParameter("@Status", 11); par[1].Direction = ParameterDirection.Output; row = Convert.ToString(SqlHelper.ExecuteScalar(con, CommandType.StoredProcedure, "spStateIsExistByName", par)); } catch (SqlException ex) { throw ex; } finally { con.Close(); } if (row != "") { flag = true; } return(flag); } }
public ActionResult ViewState(int id = 0, int pid = 0) { CustomMethods.ValidateRoles("State"); if (!Convert.ToBoolean(Session["IsAdd"]) && !Convert.ToBoolean(Session["IsEdit"])) { return(View("ErrorPage", "Error")); } StateModel state = new StateModel(); int take = 10; int skip = take * pid; state.PageID = pid; state.Current = pid + 1; ViewBag.c = state.PageID; if (id != 0) { var objState = new StateBLL { }.GetSubStateById(id); if (objState != null) { state.StateId = objState.StateId; state.StateName = objState.StateName; state.CountryId = objState.CountryId; //== null ? 0 : Convert.ToInt32(objcourse.CountryId); state.CountryName = objState.CountryName; state.IsActive = Convert.ToBoolean(objState.IsActive); } } return(View(state)); }
public JsonResult ChangeStateStatus(int id) { bool Result = false; bool changestatus = new StateBLL { }.ChangeStatus(id); if (changestatus) { Result = true; } return(Json(Result)); }
public ActionResult State(string SearchValue, string sortOrder, int pid = 0, int cid = 0) { int take = 10; int skip = take * pid; StateModel model = new StateModel(); model.PageID = pid; model.Current = pid + 1; IEnumerable <StateModel> Courses = new List <StateModel>(); CustomMethods.ValidateRoles("State"); var Citieslist = new StateBLL { }.GetAllState(skip, take); if (cid != 0) { var sortedlist = new StateBLL { }.GetAllState(skip, take, cid); double count = Convert.ToDouble(sortedlist.Count); var res = count / take; model.Pagecount = (int)Math.Ceiling(res); model.StateList = sortedlist.Select(x => new StateModel { CountryId = x.CountryId, CountryName = x.CountryName, StateId = x.StateId, StateName = x.StateName, IsActive = Convert.ToBoolean(x.IsActive) }).ToList(); } else { if (Citieslist != null) { double count = Convert.ToDouble(new StateBLL { }.GetPageCount()); var res = count / take; model.Pagecount = (int)Math.Ceiling(res); model.StateList = Citieslist.Select(x => new StateModel { CountryId = x.CountryId, CountryName = x.CountryName, StateId = x.StateId, StateName = x.StateName, IsActive = Convert.ToBoolean(x.IsActive) }).ToList(); } } return(View(model)); }
public void LoadState() { StateBLL state = new StateBLL(); DataTable dtstates = new DataTable(); dtstates = state.LoadState(); ddlState.DataSource = dtstates; ddlState.DataTextField = "Name"; ddlState.DataValueField = "ID_State"; ddlState.DataBind(); ddlState.Items.Insert(0, new ListItem("-----Select State-----", "0")); }
public bool BLLIsExistState(StateBLL st) { bool flag = false; int i; flag = stateDALObj.DALIsExistState(st); if (flag == false) { i = stateDALObj.DALStateUpdate(st); if (i == 0) { flag = true; } } return(flag); }
public static void BindStateList <T>(T model) { try { var cities = new StateBLL { }.GetAllState(); if (cities != null) { model.GetType().GetProperty("StateList").SetValue(model, cities.Select(x => new SelectListItem { Value = x.StateId.ToString(), Text = x.StateName })); } } catch (Exception) { throw; } }
public IHttpActionResult Post(ClaimViewModel claimViewModel) { try { var identityClaims = (ClaimsIdentity)HttpContext.Current.User.Identity; string userObj = identityClaims.FindFirst("userObject").Value; var userLogged = JsonConvert.DeserializeObject <UserBE>(userObj); var uvm = Mapper.Map <UserBE, UserViewModel>(userLogged); claimViewModel.User = uvm; StateBLL stateBLL = new StateBLL(); var states = stateBLL.Get(); claimViewModel.State = states.Where(s => s.Name == "pending").First(); var result = this.claimBLL.Add(claimViewModel); if (result == Guid.Empty) { throw new BusinessException(Messages.ErrorAddClaim); } var response = Request.CreateResponse(System.Net.HttpStatusCode.OK, Messages.SuccessfulUperationCrud); return(this.ResponseMessage(response)); } catch (BusinessException ex) { var response = Request.CreateResponse(System.Net.HttpStatusCode.InternalServerError, ex.Message); return(this.ResponseMessage(response)); } catch (Exception ex) { var response = Request.CreateResponse(System.Net.HttpStatusCode.InternalServerError, Messages.Generic_Error); return(this.ResponseMessage(response)); } }
public DataTable DALStateSelectBySId(StateBLL st) { using (SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"])) { try { SqlParameter[] par = new SqlParameter[1]; par[0] = new SqlParameter("@stateId", st.stateId); ds = SqlHelper.ExecuteDataset(con, CommandType.StoredProcedure, "spStateSelectBySId", par); } catch (SqlException ex) { throw ex; } finally { con.Close(); } } return(ds.Tables[0]); }
public ActionResult AddEditState(StateModel model) { int result = 0; StateBLL StateBLL = new StateBLL(); try { if (model.StateId == 0) { if (!Convert.ToBoolean(Session["IsAdd"])) { return(View("ErrorPage")); } } else { if (!Convert.ToBoolean(Session["IsEdit"])) { return(View("ErrorPage")); } } if (ModelState.IsValid) { if (model.StateId == 0) { var checkDuplicate = objdb.States.Where(x => x.StateName == model.StateName).FirstOrDefault(); if (checkDuplicate == null) { int res = new StateBLL { }.AddEditState(new StateModel { StateName = model.StateName, CountryId = model.CountryId, IsActive = model.IsActive, CreatedBy = Convert.ToInt32(Session["UserId"]), }); if (res != 0) { Session["Success"] = "Successfully Added The Record"; return(RedirectToAction("State")); } } Session["Error"] = "Record Already Exists"; return(RedirectToAction("AddEditState")); } else { model.UpdatedBy = Convert.ToInt32(Session["UserId"]); result = StateBLL.AddEditState(model); if (result != 0) { Session["Success"] = "Successfully Updated The Record"; return(RedirectToAction("State")); } } } CustomMethods.BindCountryList(model); return(View(model)); } catch (Exception) { Session["Error"] = "An Error has occured"; CustomMethods.BindCountryList(model); return(View(model)); throw; } }
public DataTable BLLGetSelectedState(StateBLL st, int i) { DataTable dtStateSelectByCId = stateDALObj.DALStateSelectByCId(st, i); return(dtStateSelectByCId); }
public int BLLStateInsert(StateBLL st) { status = stateDALObj.DALStateInsert(st); return(status); }
public int BLLStateUpdate(StateBLL st) { status = stateDALObj.DALStateUpdate(st); return(status); }
public StateController() { this.stateBLL = new StateBLL(); }