public async Task <IActionResult> Delete([FromBody] CountryEntry pModel) { // Validation if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (ValidatemCountry(pModel, pModel.AuditColumns, true) == false) { return(BadRequest(ModelState)); } else { // Execution of concrete process SQLResult result = new SQLResult(); result = await _repo.Delete(pModel); if (result.ErrorNo > 0) { return(BadRequest(result)); } else { return(Ok(result)); } } }
public ActionResult Serch(CountryEntry country) { ViewBag.countrys = db.CountryEntries.Where(c => c.CountyName.Trim() == country.CountyName.Trim()).ToList(); TempData["countyName"] = country.CountyName; ViewBag.countryName = TempData["countyName"]; return(View("Index")); }
public ActionResult DeleteConfirmed(int id) { CountryEntry countryEntry = db.CountryEntries.Find(id); db.CountryEntries.Remove(countryEntry); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <SQLResult> Edit(CountryEntry pModel) { SQLResult result = new SQLResult(); _Context.Database.BeginTransaction(); try { string csql = @" EXEC spmCountryUpdate @pi_mCountryId , @pi_CountryCode , @pi_Country , @pi_ISOAlpha2Code , @pi_ISOAlpha3Code , @pi_ISONumericCode , @pi_Active , @pi_UserId , @pi_HostName , @pi_IPAddress , @pi_DeviceType , @pi_MACAddress"; List <SqlParameter> sqlparam = new List <SqlParameter>() { new SqlParameter("@pi_mCountryId", pModel.CountryId), new SqlParameter("@pi_CountryCode", pModel.CountryCode), new SqlParameter("@pi_Country", pModel.Country), new SqlParameter("@pi_ISOAlpha2Code", pModel.ISOAlpha2Code), new SqlParameter("@pi_ISOAlpha3Code", pModel.ISOAlpha3Code), new SqlParameter("@pi_ISONumericCode", pModel.ISONumericCode), new SqlParameter("@pi_Active", pModel.Active), new SqlParameter("@pi_UserId", pModel.AuditColumns.UserId), new SqlParameter("@pi_HostName", pModel.AuditColumns.HostName), new SqlParameter("@pi_IPAddress", pModel.AuditColumns.IPAddress), new SqlParameter("@pi_DeviceType", pModel.AuditColumns.DeviceType), new SqlParameter("@pi_MACAddress", pModel.AuditColumns.MACAddress), }; result = await _Context.DBResult.FromSql(csql, sqlparam.ToArray()).SingleOrDefaultAsync(); if (result.ErrorNo != 0) { _Context.Database.RollbackTransaction(); } else { _Context.Database.CommitTransaction(); } } catch (Exception ex) { _Context.Database.RollbackTransaction(); result.ErrorNo = 9999999999; result.ErrorMessage = ex.Message.ToString(); result.SQLErrorNumber = ex.HResult; result.SQLErrorMessage = ex.Source.ToString(); } return(result); }
public ActionResult Edit([Bind(Include = "Id,CountyName,About")] CountryEntry countryEntry) { if (ModelState.IsValid) { db.Entry(countryEntry).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(countryEntry)); }
// GET: CountryEntries/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CountryEntry countryEntry = db.CountryEntries.Find(id); if (countryEntry == null) { return(HttpNotFound()); } return(View(countryEntry)); }
public ActionResult Create(CountryEntry countryEntry) { if (ModelState.IsValid) { db.CountryEntries.Add(countryEntry); int a = db.SaveChanges(); if (a > 0) { TempData["Massage"] = string.Format("( {0} ) Saved", countryEntry.CountyName); TempData["MassageType"] = "success"; } return(RedirectToAction("Create")); } return(View(countryEntry)); }
private bool ValidatemCountry(CountryEntry pModel, AuditColumns pAuditColumns, Boolean isUpdateValidation) { if (isUpdateValidation == true) { if (pModel.CountryId <= 0) { ModelState.AddModelError("", Messages.Blank("Country entry")); return(false); } } if (pModel.CountryCode.Trim().Length == 0) { ModelState.AddModelError("", Messages.Blank("Country code")); return(false); } if (pModel.Country.Trim().Length == 0) { ModelState.AddModelError("", Messages.Blank("Country")); return(false); } if (pModel.ISOAlpha2Code.Trim().Length == 0) { ModelState.AddModelError("", Messages.Blank("ISO Alpha 2 Code")); return(false); } if (pModel.ISOAlpha3Code.Trim().Length == 0) { ModelState.AddModelError("", Messages.Blank("ISO Alpha 3 Code")); return(false); } if (pModel.ISONumericCode.Trim().Length == 0) { ModelState.AddModelError("", Messages.Blank("ISO Numeric Code")); return(false); } if (pAuditColumns.UserId <= 0) { ModelState.AddModelError("", Messages.Blank("User")); return(false); } if (pAuditColumns.MACAddress.Trim().Length == 0) { ModelState.AddModelError("", Messages.Blank("MAC Address")); return(false); } if (pAuditColumns.HostName.Trim().Length == 0) { ModelState.AddModelError("", Messages.Blank("Host Name")); return(false); } if (pAuditColumns.IPAddress.Trim().Length == 0) { ModelState.AddModelError("", Messages.Blank("IP Address")); return(false); } if (pAuditColumns.DeviceType.Trim().Length == 0) { ModelState.AddModelError("", Messages.Blank("Device Type")); return(false); } return(true); }
public JsonResult IsCountryExist(CountryEntry country) { return(Json(!db.CountryEntries.Any(m => m.CountyName.Trim() == country.CountyName.Trim()), JsonRequestBehavior.AllowGet)); }