public bool Update([FromBody] DistrictMaster _oDistrictMaster) { try { int output; using (var context = new DB001Core()) { var input = context.DistrictMasters .Where(w => w.DistrictID == _oDistrictMaster.DistrictID) .FirstOrDefault(); input.DistrictName = _oDistrictMaster.DistrictName; output = context.SaveChanges(); } return(Convert.ToBoolean(output)); } catch (Exception ex) { throw; } finally { context = null; } }
public ActionResult DeleteConfirmed(int id) { DistrictMaster districtMaster = db.DistrictMasters.Find(id); db.DistrictMasters.Remove(districtMaster); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "DistrictId,DistrictName,DistrictCode,StateCode")] DistrictMaster districtMaster) { if (ModelState.IsValid) { db.Entry(districtMaster).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(districtMaster)); }
public ActionResult Create([Bind(Include = "DistrictId,DistrictName,DistrictCode,StateCode")] DistrictMaster districtMaster) { if (ModelState.IsValid) { db.DistrictMasters.Add(districtMaster); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(districtMaster)); }
public static string[] GetCompletionListDistrict(string prefixText, int count, string contextKey) { DistrictMaster objDistrict = new DistrictMaster(); DataTable dt = new DataView(objDistrict.GetDistrictMaster(HttpContext.Current.Session["CompId"].ToString()), "District like '" + prefixText.ToString() + "%'", "", DataViewRowState.CurrentRows).ToTable(); string[] txt = new string[dt.Rows.Count]; for (int i = 0; i < dt.Rows.Count; i++) { txt[i] = dt.Rows[i]["District"].ToString(); } return(txt); }
// GET: DistrictMasters/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DistrictMaster districtMaster = db.DistrictMasters.Find(id); if (districtMaster == null) { return(HttpNotFound()); } return(View(districtMaster)); }
public DistrictMaster District_Retrieve(int id) { DistrictMaster obj = new DistrictMaster(); using (MySqlDataReader reader = ExecuteDataReader("District_Retrieve", CreateParameter("DistrictId_", MySqlDbType.Int32, id), CreateParameter("StateId_", MySqlDbType.Int32, -1) )) { while (reader.Read()) { obj.StateId = Convert.ToInt32(reader["StateId"]); obj.StateName = reader["StateName"].ToString(); //obj.CountryName = reader["CountryName"].ToString(); obj.DistrictId = Convert.ToInt32(reader["DistrictId"]); obj.DistrictName = reader["DistrictName"].ToString(); obj.IsActive = Convert.ToBoolean(reader["IsActive"]); } } return(obj); }
public bool Add([FromBody] DistrictMaster _oDistrictMaster) { try { int output; using (var context = new DB001Core()) { context.DistrictMasters.Add(_oDistrictMaster); output = context.SaveChanges(); } return(Convert.ToBoolean(output)); } catch (Exception ex) { throw; } finally { context = null; } }
public List <DistrictMaster> District_RetrieveAll(int stateId) { List <DistrictMaster> listDistrict = new List <DistrictMaster>(); using (MySqlDataReader reader = ExecuteDataReader("District_Retrieve", CreateParameter("DistrictId_", MySqlDbType.Int32, -1), CreateParameter("StateId_", MySqlDbType.Int32, stateId))) { while (reader.Read()) { DistrictMaster obj = new DistrictMaster(); obj.StateId = Convert.ToInt32(reader["StateId"]); obj.StateName = reader["StateName"].ToString(); //obj.CountryName = reader["CountryName"].ToString(); obj.DistrictId = Convert.ToInt32(reader["DistrictId"]); obj.DistrictName = reader["DistrictName"].ToString(); obj.IsActive = Convert.ToBoolean(reader["IsActive"]); listDistrict.Add(obj); } } return(listDistrict); }
public HttpResponseMessage GetDistrict(string stateCode) { try { DistrictMaster objListDistrictMaster = new DistrictMaster(); List <District> objListDistrict = new List <District>(); //For getting list of districts from the table. var getDistrict = (from district in dbContext.District_Master where district.StateCode == stateCode select district).ToList(); if (getDistrict != null) { foreach (var i in getDistrict) { District objDistrict = new District() { DistrictCode = i.DistrictCode, DistrictName = i.DistrictName }; objListDistrict.Add(objDistrict); } objListDistrictMaster.District = objListDistrict; return(Request.CreateResponse(HttpStatusCode.OK, objListDistrictMaster)); } else { objResponse.Message = "Failed"; return(Request.CreateResponse(HttpStatusCode.OK, objResponse)); } } catch (Exception ex) { Log.Info(Convert.ToString(ex.InnerException)); Log.Info(ex.Message); objCommonClasses.InsertExceptionDetails(ex, "MasterController", "GetDistrict"); return(Request.CreateErrorResponse(HttpStatusCode.ExpectationFailed, ex.Message)); } }
public List <DistrictMaster> District_Update(DistrictMaster input) { List <DistrictMaster> listDistrict = new List <DistrictMaster>(); using (MySqlDataReader reader = ExecuteDataReader("District_InsertUpdateDelete", CreateParameter("DistrictId_", MySqlDbType.Int32, input.DistrictId), CreateParameter("StateId_", MySqlDbType.Int32, input.StateId), CreateParameter("DistrictName_", MySqlDbType.VarChar, input.DistrictName), CreateParameter("Type_", MySqlDbType.Int32, 2))) { while (reader.Read()) { DistrictMaster obj = new DistrictMaster(); obj.StateId = Convert.ToInt32(reader["StateId"]); obj.StateName = reader["StateName"].ToString(); //obj.CountryName = reader["CountryName"].ToString(); obj.DistrictId = Convert.ToInt32(reader["DistrictId"]); obj.DistrictName = reader["DistrictName"].ToString(); listDistrict.Add(obj); } } return(listDistrict); }