public JsonResult SaveStaticPage(StaticPage oStaticPages) { var cStatus = "error"; var cMsg = Resources.NotifyMsg.ErrorMsg; var page = _db.StaticPages.FirstOrDefault(x => x.Id == oStaticPages.Id); if (page != null && ModelState.IsValid) { _db.StaticPages.Attach(page); page.Title = oStaticPages.Title; if (!string.IsNullOrEmpty(oStaticPages.Description)) { page.Description = oStaticPages.Description; } if (!string.IsNullOrEmpty(oStaticPages.Image)) { page.Image = oStaticPages.Image; } if (!string.IsNullOrEmpty(oStaticPages.Image2)) { page.Image2 = oStaticPages.Image2; } if (!string.IsNullOrEmpty(oStaticPages.image3)) { page.image3 = oStaticPages.image3; } if (!string.IsNullOrEmpty(oStaticPages.Mobile)) { page.Mobile = oStaticPages.Mobile; } if (!string.IsNullOrEmpty(oStaticPages.Phone)) { page.Phone = oStaticPages.Phone; } if (!string.IsNullOrEmpty(oStaticPages.Email1)) { page.Email1 = oStaticPages.Email1; } page.Email2 = oStaticPages.Email2; page.UpdatedBy = User.Id; page.UpdatedDate = DateTime.Now; _db.Entry(page).Property(x => x.Title).IsModified = true; if (!string.IsNullOrEmpty(oStaticPages.Description)) { _db.Entry(page).Property(x => x.Description).IsModified = true; } if (!string.IsNullOrEmpty(oStaticPages.Image)) { _db.Entry(page).Property(x => x.Image).IsModified = true; } if (!string.IsNullOrEmpty(oStaticPages.Image2)) { _db.Entry(page).Property(x => x.Image2).IsModified = true; } if (!string.IsNullOrEmpty(oStaticPages.image3)) { _db.Entry(page).Property(x => x.image3).IsModified = true; } if (!string.IsNullOrEmpty(oStaticPages.Mobile)) { _db.Entry(page).Property(x => x.Mobile).IsModified = true; } if (!string.IsNullOrEmpty(oStaticPages.Phone)) { _db.Entry(page).Property(x => x.Phone).IsModified = true; } if (!string.IsNullOrEmpty(oStaticPages.Email1)) { _db.Entry(page).Property(x => x.Email1).IsModified = true; } _db.Entry(page).Property(x => x.Email2).IsModified = true; _db.Entry(page).Property(x => x.UpdatedBy).IsModified = true; _db.Entry(page).Property(x => x.UpdatedDate).IsModified = true; _db.SaveChanges(); cStatus = "success"; cMsg = Resources.NotifyMsg.UpdateSuccessMsg; } else { return(Json(new { cStatus = "notValid", cMsg = GeneralHelper.GetErrorMessage(ModelState, Resources.NotifyMsg.ErrorInField) }, JsonRequestBehavior.AllowGet)); } return(Json(new { cStatus, cMsg }, JsonRequestBehavior.AllowGet)); }
public JsonResult UpdateConstant(Constant oConstant) { var cStatus = "error"; var cMsg = Resources.NotifyMsg.ErrorMsg; if (ModelState.IsValid) { var constant = _db.Constants.FirstOrDefault(x => x.Id == oConstant.Id); if (constant != null) { _db.Constants.Attach(constant); constant.NameAr = oConstant.NameAr; constant.NameEn = oConstant.NameEn; constant.Icon = oConstant.Icon; constant.ParentId = oConstant.ParentId; constant.Comment = oConstant.Comment; _db.Entry(constant).Property(x => x.NameAr).IsModified = true; _db.Entry(constant).Property(x => x.NameEn).IsModified = true; _db.Entry(constant).Property(x => x.Icon).IsModified = true; _db.Entry(constant).Property(x => x.ParentId).IsModified = true; _db.Entry(constant).Property(x => x.Comment).IsModified = true; _db.SaveChanges(); cStatus = "success"; cMsg = Resources.NotifyMsg.UpdateSuccessMsg; } return(Json(new { cStatus, cMsg }, JsonRequestBehavior.AllowGet)); } else { cStatus = "notValid"; cMsg = Resources.NotifyMsg.NotValidMsg; } return(Json(new { cStatus, cMsg }, JsonRequestBehavior.AllowGet)); }