public async Task <ActionResult> DeleteCountry(string RowID) { var DecID = int.Parse(EncriptionAndDecription.Decrypt(RowID)); var GetRow = Db.Table_Countries.Find(DecID); if (GetRow != null) { try { Db.Table_Countries.Remove(GetRow); await Db.SaveChangesAsync(); return(Json(new Msg() { Title = Resources.Common.Delete, Subject = Resources.Common.DeleteDoneMsg, MsgType = MsgType.Success }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { var st = new StackTrace(ex, true); var frame = st.GetFrame(0); var line = frame.GetFileLineNumber(); while (ex.InnerException != null) { ex = ex.InnerException; } LogsSystem.AddError((int)PagesCodes.MainData.Main.RegisterCountries, ex.Message, line, (int)ActionsTypes.Delete, ""); return(Json(new Msg() { Title = Resources.Common.Delete, Subject = Resources.Common.DeleteErrorUsing, MsgType = MsgType.Error }, JsonRequestBehavior.AllowGet)); } } return(Content("")); }
public ActionResult EditCountry(string RowID) { var DecID = int.Parse(EncriptionAndDecription.Decrypt(RowID)); var GetRow = Db.Table_Countries.Find(DecID); if (GetRow != null) { ViewBag.RowID = RowID; return(PartialView("_EditCountry", GetRow)); } return(Json(new Msg() { Title = "حدث خطأ", Subject = "", MsgType = MsgType.Error })); }
public async Task <ActionResult> EditCountry(string RowID, Table_Countries model) { try { //var msgs = new List<Msg>(); var DecRowID = int.Parse(EncriptionAndDecription.Decrypt(RowID)); var GetRow = Db.Table_Countries.FirstOrDefault(s => (s.ArabicName == model.ArabicName || s.CountryCode == model.CountryCode) && s.ID != DecRowID); if (GetRow != null && GetRow.ID != DecRowID) { return(Json(new Msg() { Title = Resources.Common.DuplicateName, Subject = Resources.Common.DuplicateMsg, MsgType = MsgType.Warning })); } else { GetRow = Db.Table_Countries.Find(DecRowID); GetRow.ArabicName = model.ArabicName; GetRow.EnglishName = model.EnglishName; GetRow.CountryCode = model.CountryCode; await Db.SaveChangesAsync(); return(Json(new Msg() { Title = Resources.Common.EditCountry, Subject = Resources.Common.EditDoneMsg, MsgType = MsgType.Success })); } } catch (Exception ex) { var st = new StackTrace(ex, true); var frame = st.GetFrame(0); var line = frame.GetFileLineNumber(); while (ex.InnerException != null) { ex = ex.InnerException; } LogsSystem.AddError((int)PagesCodes.MainData.Main.RegisterCountries, ex.Message, line, (int)ActionsTypes.Edit, ""); return(Json(new Msg() { Title = "حدث خطأ", Subject = ex.Message, MsgType = MsgType.Error })); } }