internal void Update(tblCountry model) { tblCountry newobj = GetCountrys().Where(p => p.CountryId == model.CountryId).FirstOrDefault(); newobj.CountryName = model.CountryName; objData.SaveChanges(); }
private bool SaveData() { objClsCommon = new clsCommon(); objCountry = new tblCountry(); if (objClsCommon.IsRecordExists("tblCountry", tblCountry.ColumnNames.AppCountry, tblCountry.ColumnNames.AppCountryID, txtCountry.Text, hdnPKID.Value)) { DInfo.ShowMessage(" Country already exits.", Enums.MessageType.Error); return(false); } if (!string.IsNullOrEmpty(hdnPKID.Value) && hdnPKID.Value != "") { objCountry.LoadByPrimaryKey(Convert.ToInt32(hdnPKID.Value)); } else { objCountry.AddNew(); } objCountry.AppCountry = txtCountry.Text; //objCountry.AppIsActive = chkIsActive.Checked; objCountry.Save(); iCountryID = objCountry.AppCountryID; objCountry = null; objClsCommon = null; return(true); }
public int Save(tblCountry tbl) { tbl.IsDelete = false; objData.tblCounties.Add(tbl); objData.SaveChanges(); return(tbl.CountryId.Value); }
private bool Delete(int intPKID) { bool retval = false; objCountry = new tblCountry(); tblState ObjState = new tblState(); var _with1 = objCountry; if (_with1.LoadByPrimaryKey(intPKID)) { ObjState.Where.AppStateID.Value = intPKID; ObjState.Query.Load(); if (ObjState.RowCount > 0) { retval = false; } else { _with1.MarkAsDeleted(); _with1.Save(); retval = true; } } ObjState = null; objCountry = null; return(retval); }
public ActionResult Update(tblCountry model) { var countries = objReligion.GetCountrys(); var test = countries.Where(p => p.CountryName.ToUpper() == model.CountryName.ToUpper()).FirstOrDefault(); CountryDetails obj = new CountryDetails(); if (test != null) { obj.Status = false; obj.ErrorMessage = SettingsManager.Instance.Branding == "SINDHI" ? Resources.SPMOResources.AlreadyExist : "हि माहिती आधीपासून उपलब्ध आहे."; } else { obj.Status = true; obj.ErrorMessage = SettingsManager.Instance.Branding == "SINDHI" ? Resources.SPMOResources.UpdateSuccess : "माहितीमध्ये बदल करण्यात आला आहे."; objReligion.Update(model); } int pageindex = 0; var filter = countries.OrderBy(p => p.CountryId).Skip(pageindex * PageSize).Take(PageSize); Session["users"] = countries; Session["pageindex"] = 0; obj.CountryList = filter; return(Json(obj, JsonRequestBehavior.AllowGet)); }
public IActionResult PutCountry(int id, [FromBody] tblCountry CountryDetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != CountryDetail.CountryID) { return(BadRequest()); } CountryDetail.UpdatedBy = 0; CountryDetail.UpdatedOnDate = DateTime.Now; var isUpdated = _service.Update(CountryDetail); if (isUpdated != null && isUpdated > 0) { return(Ok(CountryDetail)); } else { return(BadRequest("Kindly try again")); } }
public IHttpActionResult PuttblCountry(int id, tblCountry tblCountry) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tblCountry.Id) { return(BadRequest()); } db.Entry(tblCountry).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!tblCountryExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public string SaveCountry(tblCountry country) { using (LoanPriceEntities context = new LoanPriceEntities()) { if (country.ID <= 0) { if (context.tblCountry.Where(s => s.Name == country.Name).Count() == 0) { context.AddTotblCountry(country); context.SaveChanges(); return("Country is added successfully"); } else { return("Entry of the same Name is already exists."); } } else { context.tblCountry.Attach(country); context.ObjectStateManager.ChangeObjectState(country, System.Data.EntityState.Modified); context.SaveChanges(); return("Country is Updates successfully"); } } }
public async Task <IActionResult> Edit(int id, [Bind("country_Id,country_Name")] tblCountry tblCountry) { if (id != tblCountry.country_Id) { return(NotFound()); } if (ModelState.IsValid) { try { db.Update(tblCountry); await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!tblCountryExists(tblCountry.country_Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(tblCountry)); }
private void Initialize() { ReadUserPrefFromCookie(); cmbCountry.Items.Clear(); cmbCountry.Items.Add(new RadComboBoxItem("[Select Country]", "-1")); cmbCountry.AppendDataBoundItems = true; cmbCountry.DataSource = GoProGo.Business.Lookup.Geo.GetEnabledCountries(); cmbCountry.DataTextField = "Country"; cmbCountry.DataValueField = "ID"; cmbCountry.DataBind(); cmbRegion.Items.Clear(); tblCountry country = GoProGo.Business.Lookup.Geo.GetEnabledCountries().Where(a => a.Country.ToLower().Equals(UserBrowsingInfo.Country.ToLower())).SingleOrDefault <tblCountry>(); if (country != null) { cmbCountry.SelectedValue = country.ID.ToString(); } else { cmbCountry.SelectedIndex = 0; } cmbCountry_SelectedIndexChanged(null, null); }
public int DeleteCountryDetails(string countryId) { tblCountry Country = db.tblCountries.Find(int.Parse(countryId)); db.tblCountries.Remove(Country); return(db.SaveChanges()); }
public string ChangeStatus(long id) { tblCountry user = _dbRepository.SelectById(id); user.IsActive = !user.IsActive; return(_dbRepository.Update(user)); }
// GET: /Users/ public ActionResult Index(int isdelete = 0, int restoreid = 0) { var list = (dynamic)null; TempData["restore"] = ""; if (isdelete == 0) { if (restoreid > 0) { if (db.tblCountry.Any(a => a.CountryID == restoreid && a.IsDelete == true)) { tblCountry tblCountry = db.tblCountry.Find(restoreid); tblCountry.IsDelete = false; db.Entry(tblCountry).State = EntityState.Modified; db.SaveChanges(); TempData["msg"] = "Record Restore Successfully"; // return View("Index","Country"); } } list = db.tblCountry.Where(a => a.IsDelete != true).OrderByDescending(a => a.CountryID).ToList(); } else { TempData["restore"] = "restore"; list = db.tblCountry.Where(a => a.IsDelete == true).OrderByDescending(a => a.CountryID).ToList(); } return(View(list)); }
public int UpdateCountryDetails(string countryId, string countryName, string IsActive) { tblCountry country = db.tblCountries.Find(int.Parse(countryId)); country.CountryName = countryName; country.IsActive = Convert.ToBoolean(IsActive); return(db.SaveChanges()); }
public ActionResult DeleteConfirmed(int id) { tblCountry tblCountry = db.tblCountry.Find(id); db.tblCountry.Remove(tblCountry); db.SaveChanges(); return(RedirectToAction("Index")); }
public static bool IsCountryKM(tblCountry country) { if (country.ISO2.ToLower().Equals("us") || country.ISO2.ToLower().Equals("gb")) { return(false); } return(true); }
public ActionResult addCountry(tblCountry model) { if (User.Identity.IsAuthenticated) { string name = User.Identity.Name; int u = (from user in _Context.tblUsers where user.EmailID == name select user.ID).Single(); bool isvalid = _Context.tblCountries.Any(m => m.CountryCode == model.CountryCode); if (!isvalid) { tblCountry obj = new tblCountry(); obj.CountryCode = model.CountryCode; obj.Name = model.Name; obj.CreatedDate = DateTime.Now; obj.CreatedBy = u; obj.IsActive = true; if (ModelState.IsValid) { _Context.tblCountries.Add(obj); try { // Your code... // Could also be before try if you know the exception occurs in SaveChanges _Context.SaveChanges(); ModelState.Clear(); return(View()); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } } } } else { ViewBag.Message = "Country already exists in list"; } } return(View()); }
/// <summary> /// Create a new tblCountry object. /// </summary> /// <param name="id">Initial value of ID.</param> /// <param name="name">Initial value of Name.</param> /// <param name="code">Initial value of Code.</param> public static tblCountry CreatetblCountry(int id, string name, string code) { tblCountry tblCountry = new tblCountry(); tblCountry.ID = id; tblCountry.Name = name; tblCountry.Code = code; return(tblCountry); }
public ActionResult Edit([Bind(Include = "CountryID,CountryName")] tblCountry tblCountry) { if (ModelState.IsValid) { db.Entry(tblCountry).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tblCountry)); }
public ActionResult Create([Bind(Include = "CountryID,CountryName,Password,CreatedBy,UpdatedBy,CreateDate,UpdateDate,IsLogin,IsDelete,IsActive,RoleID,SchoolID,DeleteBy,DeleteDate")] tblCountry tblCountry) { if (ModelState.IsValid) { db.tblCountry.Add(tblCountry); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tblCountry)); }
public ActionResult Details(int?id) { if (Session["AdminUser"] == null) { return(RedirectToAction("Login", "Home")); } tblCountry model = db.tblCountries.Find(id); return(View(model)); }
public ActionResult Edit(tblCountry model) { if (Session["AdminUser"] == null) { return(RedirectToAction("Login", "Home")); } db.Entry(model).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public SavingResult SaveNewRecord(tblCountry SaveModel) { SavingResult res = new SavingResult(); //-- Perform Validation //res.ExecutionResult = eExecutionResult.ValidationError; //res.ValidationError = "Validation error message"; //return res; //-- using (dbVisionEntities db = new dbVisionEntities()) { //tblCountry SaveModel; if (SaveModel.CountryName == "") { res.ValidationError = "Can not accept blank value. Please enter Country Name."; res.ExecutionResult = eExecutionResult.ValidationError; return(res); } else if (IsDuplicateRecord(SaveModel.CountryName, SaveModel.CountryID, db)) { res.ValidationError = "Can not accept duplicate value. The Country Name is already exists."; res.ExecutionResult = eExecutionResult.ValidationError; return(res); } if (SaveModel.CountryID == 0) // New Entry { //SaveModel = new tblCountry(); SaveModel.rcuid = Model.CommonProperties.LoginInfo.LoggedinUser.UserID; SaveModel.rcdt = DateTime.Now; db.tblCountries.Add(SaveModel); } else { SaveModel.reuid = Model.CommonProperties.LoginInfo.LoggedinUser.UserID; SaveModel.redt = DateTime.Now; db.tblCountries.Attach(SaveModel); db.Entry(SaveModel).State = System.Data.Entity.EntityState.Modified; } //-- try { db.SaveChanges(); res.PrimeKeyValue = SaveModel.CountryID; res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { CommonFunctions.GetFinalError(res, ex); } } return(res); }
public ActionResult Create([Bind(Include = "Id,Name")] tblCountry tblCountry) { if (ModelState.IsValid) { db.tblCountries.Add(tblCountry); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tblCountry)); }
public async Task <IActionResult> Create([Bind("country_Id,country_Name")] tblCountry tblCountry) { if (ModelState.IsValid) { db.Add(tblCountry); await db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tblCountry)); }
public ActionResult Edit([Bind(Include = "CountryID,CountryName,Password,CreatedBy,UpdatedBy,CreateDate,UpdateDate,IsLogin,IsDelete,IsActive,RoleID,SchoolID,DeleteBy,DeleteDate")] tblCountry tblCountry) { if (ModelState.IsValid) { db.Entry(tblCountry).State = EntityState.Modified; db.SaveChanges(); TempData["msg"] = "Record Update Successfully"; return(RedirectToAction("Index")); } return(View(tblCountry)); }
public IHttpActionResult GettblCountry(int id) { tblCountry tblCountry = db.tblCountries.Find(id); if (tblCountry == null) { return(NotFound()); } return(Ok(tblCountry)); }
public ActionResult Create(tblCountry model) { if (Session["AdminUser"] == null) { return(RedirectToAction("Login", "Home")); } db.tblCountries.Add(model); db.SaveChanges(); return(RedirectToAction("Index")); }
public int InsertCountryDetails(string countryName, string isActive) { tblCountry country = new tblCountry() { CountryName = countryName, IsActive = Convert.ToBoolean(isActive) }; db.tblCountries.Add(country); return(db.SaveChanges()); }
public IHttpActionResult PosttblCountry(tblCountry tblCountry) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.tblCountries.Add(tblCountry); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = tblCountry.Id }, tblCountry)); }
/// <summary> /// Create a new tblCountry object. /// </summary> /// <param name="countryID">Initial value of CountryID.</param> public static tblCountry CreatetblCountry(byte countryID) { tblCountry tblCountry = new tblCountry(); tblCountry.CountryID = countryID; return tblCountry; }
/// <summary> /// Create a new tblCountry object. /// </summary> /// <param name="id">Initial value of ID.</param> /// <param name="name">Initial value of Name.</param> /// <param name="code">Initial value of Code.</param> public static tblCountry CreatetblCountry(int id, string name, string code) { tblCountry tblCountry = new tblCountry(); tblCountry.ID = id; tblCountry.Name = name; tblCountry.Code = code; return tblCountry; }
/// <summary> /// There are no comments for tblCountries in the schema. /// </summary> public void AddTotblCountries(tblCountry tblCountry) { base.AddObject("tblCountries", tblCountry); }