private string GetCategoryName(long ID) { var _context = new db_KISDEntities(); var TypeMasterID = Convert.ToInt32(GalleryListingService.TypeMaster.SchoolCategory); return(_context.Schools.Where(x => x.SchoolID == ID && x.TypeMasterID == TypeMasterID).Select(x => x.NameTxt).FirstOrDefault()); }
/// <summary> /// To override the change password functionality of the MembershipProvider and implement of its own. /// From this user can change the password by providing the new and old password along with the username. /// </summary> /// <param name="username">User Name.</param> /// <param name="oldPassword">The current password for the membership user.</param> /// <param name="newPassword">The new password value for the membership user.</param> /// <returns>true if the update was successful; otherwise, false.</returns> public override bool ChangePassword(string username, string oldPassword, string newPassword) { bool ret = false; try { db_KISDEntities objContext = new db_KISDEntities(); var userp = (from u in objContext.Users where u.UserNameTxt == username && u.PasswordTxt == oldPassword select u).SingleOrDefault(); if (userp != null) { userp.PasswordTxt = newPassword; objContext.SaveChanges(); ret = true; } else { ret = false; } } catch { ret = false; } return(ret); }
public static List <SelectListItem> GetUserType(string value) { db_KISDEntities _context = new db_KISDEntities(); List <SelectListItem> items = new List <SelectListItem>(); SelectListItem data = new SelectListItem(); data.Text = "--- Select Type ---"; data.Value = "0"; items.Add(data); var UserTypes = _context.Roles.ToList(); if (UserTypes != null) { foreach (var type in UserTypes) { data = new SelectListItem(); data.Text = type.RoleNameTxt; data.Value = type.RoleID.ToString(); items.Add(data); } if (!string.IsNullOrEmpty(value)) { items.Where(x => x.Value == value).FirstOrDefault().Selected = true; } } return(items); }
/// <summary> /// Get Content Type Name from Content Type ID from database. /// </summary> /// <returns>Content Type Name</returns> public static string GetContentTypeName(int contentTypeId) { using (db_KISDEntities objKISD = new db_KISDEntities()) { return(objKISD.ContentTypes.Where(x => x.ContentTypeID == contentTypeId).Select(x => x.ContentTypeNameTxt).SingleOrDefault()); } }
public ActionResult ManageUserPermission(string UID) { UID = !string.IsNullOrEmpty(Convert.ToString(UID)) ? EncryptDecrypt.Decrypt(UID) : "0"; long UserID = Convert.ToInt32(UID); using (var objContext = new db_KISDEntities()) { var objModel = new UserPermissionsModel(); objModel.PermissionList = GetUserPermissions(); var selectedSections = objContext.UserPermissions.Where(m => m.UserID == UserID).Select(m => m.PageID.Value).ToArray(); if (selectedSections.Count() == 0) { string[] s = { "0" }; objModel.SelectedUserPermissions = s; } else { objModel.SelectedUserPermissions = Array.ConvertAll <long, string>(selectedSections, delegate(long i) { return(i.ToString()); }); } objModel.User = objContext.Users.Where(x => x.UserID == UserID).FirstOrDefault(); objModel.UserRoleID = (short?)objContext.UserRoles.Where(x => x.UserID == UserID).FirstOrDefault().RoleID; objModel.Role = objContext.Roles.Where(x => x.RoleID == objModel.UserRoleID).FirstOrDefault(); ViewBag.Title = ViewBag.PageTitle = "Manage User Permissions "; return(View("ManageUserPermission", objModel)); } }
public static bool GetAccessibleTabAccess(int TabID, int userId) { db_KISDEntities objDB = new db_KISDEntities(); var AccessibleTabs = objDB.UserPermissions.Where(x => x.UserID == userId && (x.PageID == TabID || x.PageID == 1)).Select(x => x.UserPermissionID).Count(); bool IsAccessible = AccessibleTabs > 0 ? true : false; return(IsAccessible); }
private string GetContentType(long ContentTypeID) { string s = string.Empty; using (var objContext = new db_KISDEntities()) { s = objContext.ContentTypes.Where(x => x.ContentTypeID == ContentTypeID).Select(x => x.ContentTypeNameTxt).FirstOrDefault(); } return(s); }
public static List <ImageModel> GetInnerImages() { var objContext = new db_KISDEntities(); var InnerImagesTitle = (from db in objContext.Images where db.ImageTypeID == 2 && db.StatusInd == true && db.IsDeletedInd == false select new ImageModel { TitleTxt = db.TitleTxt, ImageID = db.ImageID }).OrderBy(x => x.TitleTxt).ToList(); return(InnerImagesTitle); }
public ActionResult ManageUserPermission(UserPermissionsModel model, string command, FormCollection fm) { #region Route value directory var rvd = new RouteValueDictionary(); rvd.Add("page", Request.QueryString["page"] ?? "1"); rvd.Add("pagesize", Request.QueryString["pagesize"] ?? "10"); rvd.Add("Column", "UserCreateDate"); rvd.Add("Direction", "Descending"); rvd.Add("UID", model.UserID); #endregion using (var objContext = new db_KISDEntities()) { if (string.IsNullOrEmpty(command)) { if (model.SelectedUserPermissions != null) { #region Save User Permissions long userid = Convert.ToInt64(Membership.GetUser().ProviderUserKey); User objuser = objContext.Users.Where(x => x.UserID == userid).FirstOrDefault(); var objUserPermissions = objContext.UserPermissions.Where(x => x.UserID == model.User.UserID).ToList(); if (objUserPermissions != null && objUserPermissions.Count > 0) { foreach (var up in objUserPermissions) { objContext.UserPermissions.Remove(up); } objContext.SaveChanges(); } foreach (var item in model.SelectedUserPermissions) { if (item != "0") { var obj = new UserPermission(); obj.UserID = model.User.UserID; obj.PageID = Convert.ToInt32(item); obj.CreateDate = DateTime.Now; obj.IsAccessInd = true; obj.CreateByID = userid; obj.LastModifyByID = userid; obj.LastModifyDate = DateTime.Now; obj.UserRoleID = model.UserRoleID; objContext.UserPermissions.Add(obj); objContext.SaveChanges(); } } #endregion } TempData["AlertMessage"] = "Manage User Permissions updated successfully."; } return(RedirectToAction("Index", "UsersManagement", rvd)); } }
/// <summary> /// Get all Emails of defined type /// </summary> /// <param name="EmailType"></param> /// <returns></returns> public static bool IsURLExists(string URL, Int32 ID) { var count = 0; var _objContext = new db_KISDEntities(); //count = _objContext.News.Where(x => x.PageURLTxt == URL && x.NewsID != ID).Count(); count += _objContext.Contents.Where(x => x.PageURLTxt == URL).Count(); //count += _objContext.Categories.Where(x => x.PageUrlTxt == URL).Count(); if (URL.Trim().ToLower() == "error404") { count = count + 1; } return(count > 0); }
public ActionResult Index() { db_KISDEntities objContext = new db_KISDEntities(); string sectionName = string.Empty; using (objContext = new db_KISDEntities()) { long userid = Convert.ToInt64(Membership.GetUser().ProviderUserKey); var UserRoleID = (short)objContext.UserRoles.Where(x => x.UserID == userid).First().RoleID; sectionName = objContext.Roles.Where(x => x.RoleID == UserRoleID).Select(x => x.RoleNameTxt).FirstOrDefault(); } ViewBag.SectionName = !string.IsNullOrEmpty(sectionName) ? sectionName : ""; return(View()); }
/// <summary> /// Updates information about a user in the data source. /// </summary> /// <param name="user">A MembershipUser object that represents the user to update and the updated information for the user.</param> public override void UpdateUser(MembershipUser user) { MembershipUser u = Membership.GetUser(user.ProviderUserKey); if (RequiresUniqueEmail && GetUserNameByEmail(user.Email) != string.Empty) { // status = MembershipCreateStatus.DuplicateEmail; return; } db_KISDEntities objDBEntities = new db_KISDEntities(); var objuser = objDBEntities.Users.Find(user.ProviderUserKey); objuser.EmailTxt = user.Email; objDBEntities.SaveChanges(); }
public JsonResult CheckURL(string url) { var objContext = new db_KISDEntities(); var count = 0; count += objContext.BoardOfMembers.Where(x => x.URLTxt.Contains(url)).Count(); if (count > 0) { if (url != "") { url = url + count; } } return(Json(url)); }
public ActionResult ForgotPassword(AccountModel model, FormCollection fc) { db_KISDEntities _Context = new db_KISDEntities(); #region Send Email if (!string.IsNullOrEmpty(model.Email)) { bool IsMailSent = false; string AppPath = ConfigurationManager.AppSettings["AppPath"].ToString(); string body = string.Empty; var query = _Context.Users.Where(x => x.EmailTxt.Trim().ToLower() == model.Email.Trim().ToLower() && x.IsDeletedInd == false).FirstOrDefault(); if (query != null) { string FullLink = AppPath + "/Reset/ResetPassword?u=" + EncryptDecrypt.Encrypt(query.UserID.ToString()); var myMailUtilityBAL = new MailUtilityBAL(); var FromEmail = ConfigurationManager.AppSettings["FromEmail"].ToString(); #region Email Body body = "<table style=\"font-family:Arial;font-size:12px\" border=\"0\" align=\"left\" cellpadding=\"4\" cellspacing=\"0\" >"; body += "<tr><td colspan='2' > Dear " + query.FirstNameTxt + " " + query.LastNameTxt + @",<br/><br/>Please click on the <a href='" + FullLink + "'>link</a> to reset your Password.</td></tr>"; body = body + "<tr><td colspan='2'><br/>Regards,<br/>Killeen ISD Team.</td></tr></table>"; #endregion #region Email try { if (myMailUtilityBAL.SendEmail(FromEmail, query.EmailTxt, body, ("Killeen ISD - Password Reset Request")).ToLower().Trim() == "ok") { IsMailSent = true; } } catch (Exception ce) { IsMailSent = false; } #endregion } if (IsMailSent) { model.Message = "Reset Password link is sent to the email. Please click on the link and reset the Password."; } } #endregion return(RedirectToAction("ForgotPassword", model)); }
private SelectList GetAllUserType(Int64 currentRoleID) { var objContext = new db_KISDEntities(); var list = objContext.Roles.OrderBy(x => x.RoleID).Where(x => x.RoleID > currentRoleID).Select(x => new RoleModel() { RoleId = x.RoleID, RoleName = x.RoleNameTxt }).ToList(); var objRole = new RoleModel(); objRole.RoleName = "--- Select User Type ---"; objRole.RoleId = 0; list.Insert(0, objRole); var objselectlist = new SelectList(list, "RoleID", "RoleName"); return(objselectlist); }
public JsonResult CheckURL(string url) { var objContext = new db_KISDEntities(); var count = 0; //count = objContext.Events.Where(x => x.URLTxt.Contains(url)).Count(); //count = objContext.News.Where(x => x.URLTxt.Contains(url)).Count(); count += objContext.ExceptionOpportunities.Where(x => x.URLTxt.Contains(url)).Count(); if (count > 0) { if (url != "") { url = url + count; } } return(Json(url)); }
private SelectList GetAllRightSections() { var objContext = new db_KISDEntities(); var list = objContext.RightSections.Where(x => x.StatusInd == true && x.IsDeletedInd == false).OrderBy(x => x.TitleTxt).Select(x => new RightSectionModel() { RightSectionID = x.RightSectionID, TitleTxt = x.TitleTxt }).ToList(); var obj = new RightSectionModel(); obj.TitleTxt = "--- Select Right Section ---"; obj.RightSectionID = 0; list.Insert(0, obj); var objselectlist = new SelectList(list, "RightSectionID", "TitleTxt"); return(objselectlist); }
/// <summary> /// Change display order /// </summary> /// <param name="sourceorder"></param> /// <param name="targetorder"></param> /// <param name="ContentID"></param> /// <returns></returns> public static bool ChangeAnnouncementDisplayOrder(long sourceorder, long targetorder, long ContentID, int TypeMasterID) { var _context = new db_KISDEntities(); try { if (sourceorder < targetorder) { var AnnouncementList = _context.Announcements.Where(x => x.DisplayOrderNbr >= sourceorder && x.DisplayOrderNbr <= targetorder && x.TypeMasterID == TypeMasterID && x.IsDeletedInd == false).ToList(); foreach (var item in AnnouncementList) { if (item.DisplayOrderNbr == sourceorder) { item.DisplayOrderNbr = targetorder; } else { item.DisplayOrderNbr -= 1; } } } else { var AnnouncementList = _context.Announcements.Where(x => x.DisplayOrderNbr >= targetorder && x.DisplayOrderNbr <= sourceorder && x.TypeMasterID == TypeMasterID && x.IsDeletedInd == false).ToList(); foreach (var item in AnnouncementList) { if (item.DisplayOrderNbr == sourceorder) { item.DisplayOrderNbr = targetorder; } else { item.DisplayOrderNbr += 1; } } } _context.SaveChanges(); return(true); } catch { return(false); } }
/// <summary> /// Change display order /// </summary> /// <param name="sourceorder"></param> /// <param name="targetorder"></param> /// <param name="ContentID"></param> /// <returns></returns> public static bool ChangeDisplayOrder(long sourceorder, long targetorder) { var _context = new db_KISDEntities(); try { if (sourceorder < targetorder) { var List = _context.Staffs.Where(x => x.DisplayOrderNbr >= sourceorder && x.DisplayOrderNbr <= targetorder && x.IsDeletedInd == false).ToList(); foreach (var item in List) { if (item.DisplayOrderNbr == sourceorder) { item.DisplayOrderNbr = targetorder; } else { item.DisplayOrderNbr -= 1; } } } else { var List = _context.Staffs.Where(x => x.DisplayOrderNbr >= targetorder && x.DisplayOrderNbr <= sourceorder && x.IsDeletedInd == false).ToList(); foreach (var item in List) { if (item.DisplayOrderNbr == sourceorder) { item.DisplayOrderNbr = targetorder; } else { item.DisplayOrderNbr += 1; } } } _context.SaveChanges(); return(true); } catch { return(false); } }
/// <summary> /// To override the DeleteUser functionality of the MembershipProvider and implement of its own. /// Removes a user from the membership data source. /// </summary> /// <param name="username">The user name for the new user.</param> /// <param name="deleteAllRelatedData">true to delete data related to the user from the database; false to leave data related to the user in the database.</param> /// <returns>true if the user was successfully deleted; otherwise, false.</returns> public override bool DeleteUser(string username, bool deleteAllRelatedData) { db_KISDEntities objContext = new db_KISDEntities(); var userp = (from u in objContext.Users where u.UserNameTxt == username select u).SingleOrDefault(); if (deleteAllRelatedData) { var role = (from u in objContext.UserRoles where u.UserID == userp.UserID select u).FirstOrDefault(); if (role != null) { objContext.UserRoles.Remove(role); objContext.SaveChanges(); } } objContext.Users.Remove(userp); objContext.SaveChanges(); return(true); // throw new NotImplementedException(); }
/// <summary> /// Gets information from the data source for a user. Provides an option to update the last-activity date/time stamp for the user. /// </summary> /// <param name="providerUserKey">The unique identifier from the membership data source for the user.</param> /// <param name="userIsOnline">true to update the last-activity date/time stamp for the user; false to return user information without updating the last-activity date/time stamp for the user.</param> /// <returns>A MembershipUser object populated with the specified user's information from the data source.</returns> public override MembershipUser GetUser(object providerUserKey, bool userIsOnline) { db_KISDEntities objDBEntities = new db_KISDEntities(); var username = (from u in objDBEntities.Users where u.UserID == (long)providerUserKey select u.UserNameTxt).SingleOrDefault(); var usersContext = new UsersContext(); var user = usersContext.GetUser(username); if (user != null) { var memUser = new MembershipUser("CustomMembershipProvider", username, user.UserID, user.EmailTxt, string.Empty, string.Empty, true, false, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, DateTime.Now, DateTime.Now); return(memUser); } // user.UserEmailAddress return(null); }
/// <summary> /// To override the change password functionality of the MembershipProvider and implement of its own. /// From this user can change the password by providing the new and old password along with the username. /// </summary> /// <param name="username">User Name.</param> /// <param name="oldPassword">The current password for the membership user.</param> /// <param name="newPassword">The new password value for the membership user.</param> /// <returns>true if the update was successful; otherwise, false.</returns> public override bool ChangePassword(string username, string oldPassword, string newPassword) { try { db_KISDEntities objDBEntities = new db_KISDEntities(); var userp = (from u in objDBEntities.Users where u.UserNameTxt == username && u.PasswordTxt == oldPassword select u).SingleOrDefault(); if (userp != null) { userp.PasswordTxt = newPassword; objDBEntities.SaveChanges(); return(true); } return(false); } catch { return(false); } }
/// <summary> /// this method is called when admin lohout his/her account /// </summary> /// <returns>redirect to login view</returns> public ActionResult LogOff() { db_KISDEntities _contex = new db_KISDEntities(); SystemAccessLog objSystemAccessLog = new SystemAccessLog(); var usename = Membership.GetUser().UserName; objSystemAccessLog = _contex.SystemAccessLogs.Where(x => x.UserNameTxt == usename).OrderByDescending(x => x.SystemAccessLogID).FirstOrDefault(); objSystemAccessLog.LogoutDateTime = System.DateTime.Now; _contex.Entry(objSystemAccessLog).State = System.Data.Entity.EntityState.Modified; _contex.SaveChanges(); FormsAuthentication.SignOut(); // Clear authentication cookie. HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, ""); cookie.Expires = DateTime.Now.AddYears(-1); Response.Cookies.Add(cookie); Session.Abandon(); return(RedirectToAction("Login", "Account")); }
public ListingParameterService() { _context = new db_KISDEntities(); }
public JsonResult Delete(string it, string iid, FormCollection fm) { //decrypt Announcement type id(it) it = !string.IsNullOrEmpty(Convert.ToString(it)) ? EncryptDecrypt.Decrypt(it) : "0"; //decrypt Announcement id(iid) iid = !string.IsNullOrEmpty(Convert.ToString(iid)) ? EncryptDecrypt.Decrypt(iid) : "0"; //.. Code for get the route value directory RouteValueDictionary rvd = new RouteValueDictionary(); ViewBag.TypeMasterID = it; ViewBag.Title = _service.GetAnnouncementType(Convert.ToInt32(it)); var page = Request.QueryString["page"] != null ? Request.QueryString["page"].ToString() : Models.Common._currentPage.ToString(); var pagesize = Request.QueryString["pagesize"] != null ? Request.QueryString["pagesize"].ToString() : Models.Common._pageSize.ToString(); rvd.Add("pagesize", pagesize); rvd.Add("Column", Request.QueryString["Column"] != null ? Request.QueryString["Column"].ToString() : "AnnouncementCreateDate"); rvd.Add("Direction", Request.QueryString["Direction"] != null ? Request.QueryString["Direction"].ToString() : "Descending"); rvd.Add("it", EncryptDecrypt.Encrypt(it)); TempData["pager"] = pagesize; Session["Edit/Delete"] = "Delete"; try { // TODO: Add delete logic here //.. Check for Announcement in use Announcement objAnnouncement = objContext.Announcements.Find(Convert.ToInt32(iid)); int AnnounceID = Convert.ToInt32(iid); #region System Change Log var oldresult = (from a in objContext.Announcements where a.AnnouncementID == AnnounceID select a).ToList(); DataTable dtOld = KISD.Areas.Admin.Models.Common.LINQResultToDataTable(oldresult); #endregion if (objAnnouncement != null) { // objAnnouncement.IsDeletedInd = true; //****************Display Order ************************ //var objAnnouncements = objContext.Announcements.Where(x => x.TypeMasterID == objAnnouncement.TypeMasterID).FirstOrDefault(); if (objAnnouncement != null) { try { var objAnnouncementService = new AnnouncementService(); objAnnouncementService.ChangeDeletedDisplayOrder(objAnnouncement.DisplayOrderNbr.Value, objAnnouncement.AnnouncementID, objAnnouncement.TypeMasterID.Value); } catch { } } #region Delete Selected Right Section for the Announcement var MasterID = Convert.ToInt64(it); var rightSections = objContext.RightSections.Where(x => x.ListingID == AnnounceID && x.TypeMasterID == MasterID).ToList(); if (rightSections != null && rightSections.Count() > 0) { foreach (var section in rightSections) { section.IsDeletedInd = true; } objContext.SaveChanges(); } #endregion //*************************************************** // objContext.SaveChanges(); #region System Change Log SystemChangeLog objSCL = new SystemChangeLog(); long userid = Convert.ToInt64(Membership.GetUser().ProviderUserKey); User objuser = objContext.Users.Where(x => x.UserID == userid).FirstOrDefault(); objSCL.NameTxt = objuser.FirstNameTxt + " " + objuser.LastNameTxt; objSCL.UsernameTxt = objuser.UserNameTxt; objSCL.UserRoleID = (short)objContext.UserRoles.Where(x => x.UserID == objuser.UserID).First().RoleID; objSCL.ModuleTxt = _service.GetAnnouncementType(objAnnouncement.TypeMasterID.Value); objSCL.LogTypeTxt = "Delete"; objSCL.NotesTxt = (_service.GetAnnouncementType(objAnnouncement.TypeMasterID.Value)) + " Details deleted for " + objAnnouncement.TitleTxt; objSCL.LogDateTime = DateTime.Now; objContext.SystemChangeLogs.Add(objSCL); objContext.SaveChanges(); objSCL = objContext.SystemChangeLogs.OrderByDescending(x => x.ChangeLogID).FirstOrDefault(); var objContextnew = new db_KISDEntities(); var newResult = (from x in objContextnew.Announcements where x.AnnouncementID == AnnounceID select x); DataTable dtNew = KISD.Areas.Admin.Models.Common.LINQResultToDataTable(newResult); foreach (DataColumn col in dtNew.Columns) { SystemChangeLogDetail objSCLD = new SystemChangeLogDetail(); objSCLD.ChangeLogID = objSCL.ChangeLogID; objSCLD.FieldNameTxt = col.ColumnName.ToString(); objSCLD.OldValueTxt = dtOld.Rows[0][col.ColumnName].ToString(); objSCLD.NewValueTxt = col.ColumnName == "IsDeletedInd" ? dtNew.Rows[0][col.ColumnName].ToString() : ""; objContext.SystemChangeLogDetails.Add(objSCLD); objContext.SaveChanges(); } #endregion try { Models.Common.DeleteImage(Server.MapPath(objAnnouncement.ImageURLTxt)); } catch { } TempData["AlertMessage"] = _service.GetAnnouncementType(Convert.ToInt32(it)) + " details deleted successfully."; } //.. Checks for no of records in current page if exists records then return same page number else decrease the page number int?CheckPage = 1; int TypeMasterID = Convert.ToInt32(it); var count = objContext.Announcements.Where(x => x.TypeMasterID == TypeMasterID && x.IsDeletedInd == false).Count(); if (Convert.ToInt32(page) > 1) { CheckPage = count > ((Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize)) ? Convert.ToInt32(page) : (Convert.ToInt32(page)) - 1; } rvd.Add("page", CheckPage); return(Json(Url.Action("Index", "Announcement", rvd))); } catch { rvd.Add("page", page); return(Json(Url.Action("Index", "Announcement", rvd))); } }
/// <summary> /// this method will show the Announcement listing with all Announcement type. /// </summary> /// <param name="Page">this parameter is used to get page number to be shown.</param> /// <param name="PageSize">this parameter is used to get no of recorde to be shown.</param> /// <param name="gridSortOptions">this parameter is used to get grid sorting option.</param> /// <param name="it">this parameter is used to get type id of the Announcement i.e. 1,2 or 3</param> /// <param name="formCollection">this parameter is used to get controls collection on the page.</param> /// <param name="ObjResult"></param> /// <returns>view to enter Announcement details.</returns> public ActionResult Index(int?Page, int?PageSize, GridSortOptions gridSortOptions, string it, FormCollection formCollection, string ObjResult) { var db_obj = new db_KISDEntities(); //Check for valid TypeMasterID if (it == null) { return(RedirectToAction("Index", "Home")); } #region Check Tab is Accessible or Not db_KISDEntities objContext = new db_KISDEntities(); var userId = objContext.Users.Where(x => x.UserNameTxt == User.Identity.Name).Select(x => x.UserID).FirstOrDefault(); var RoleID = objContext.UserRoles.Where(x => x.UserID == userId).Select(x => x.RoleID).FirstOrDefault(); var HasTabAccess = GetAccessibleTabAccess(Convert.ToInt32(ModuleType.Masters), Convert.ToInt32(userId)); if (!(HasTabAccess || RoleID == Convert.ToInt32(UserType.SuperAdmin) || RoleID == Convert.ToInt32(UserType.Admin))) //if tab not accessible then redirect to home { return(RedirectToAction("Index", "Home")); } #endregion //decrypt Announcement type id(it) if (!string.IsNullOrEmpty(Convert.ToString(it))) { it = Convert.ToString(EncryptDecrypt.Decrypt(it)); } TempData["CroppedImage"] = null; var AnnouncementType = it != null?Convert.ToInt32(it) : Convert.ToInt32(AnnouncementTypeAlias.Announcement); ViewBag.TypeMasterID = AnnouncementType; //*******************Fill Values if Display order contains null values*************************** var displayOrderList = objContext.Announcements.Where(x => x.TypeMasterID == AnnouncementType && x.IsDeletedInd == false).ToList(); foreach (var item in displayOrderList) { if (string.IsNullOrEmpty(item.DisplayOrderNbr.ToString())) { var objContentData = objContext.Announcements.Where(x => x.AnnouncementID == item.AnnouncementID).FirstOrDefault(); var NewdisplayOrder = (displayOrderList.Max(x => x.DisplayOrderNbr)) == null ? 1 : displayOrderList.Max(x => x.DisplayOrderNbr).Value + 1; objContentData.DisplayOrderNbr = NewdisplayOrder; objContext.SaveChanges(); } } //*********************************************************** #region Ajax Call if (ObjResult != null) { AjaxRequest objAjaxRequest = JsonConvert.DeserializeObject <AjaxRequest>(ObjResult);//Convert json String to object Model if (objAjaxRequest.ajaxcall != null && !string.IsNullOrEmpty(objAjaxRequest.ajaxcall) && ObjResult != null && !string.IsNullOrEmpty(ObjResult)) { if (objAjaxRequest.ajaxcall == "paging") //Ajax Call type = paging i.e. Next|Previous|Back|Last { Session["pageNo"] = Page; // stores the page no for status } else if (objAjaxRequest.ajaxcall == "sorting") //Ajax Call type = sorting i.e. column sorting Asc or Desc { Page = (Session["pageNo"] != null ? Convert.ToInt32(Session["pageNo"].ToString()) : Page); Session["GridSortOption"] = gridSortOptions; PageSize = (Session["PageSize"] != null ? Convert.ToInt32(Session["PageSize"].ToString()) : PageSize); } else if (objAjaxRequest.ajaxcall == "ddlPaging")//Ajax Call type = drop down paging i.e. drop down value 10, 25, 50, 100, ALL { Session["PageSize"] = (Request.QueryString["pagesize"] != null ? Convert.ToInt32(Request.QueryString["pagesize"].ToString()) : PageSize); Session["GridSortOption"] = gridSortOptions; Session["pageNo"] = Page; } else if (objAjaxRequest.ajaxcall == "status")//Ajax Call type = status i.e. Active/Inactive { Page = (Session["pageNo"] != null ? Convert.ToInt32(Session["pageNo"].ToString()) : Page); gridSortOptions = (Session["GridSortOption"] != null ? Session["GridSortOption"] as GridSortOptions : gridSortOptions); } else if (objAjaxRequest.ajaxcall == "displayorder")//Ajax Call type = Display Order i.e. drop down values { Page = (Session["pageNo"] != null ? Convert.ToInt32(Session["pageNo"].ToString()) : Page); gridSortOptions = (Session["GridSortOption"] != null ? Session["GridSortOption"] as GridSortOptions : gridSortOptions); } objAjaxRequest.ajaxcall = null;; //remove parameter value } //Ajax Call for update status for Announcements if (objAjaxRequest.hfid != null && objAjaxRequest.hfvalue != null && !string.IsNullOrEmpty(objAjaxRequest.hfid) && !string.IsNullOrEmpty(objAjaxRequest.hfvalue) && ObjResult != null && !string.IsNullOrEmpty(ObjResult)) { var Announcementid = System.Convert.ToInt64(objAjaxRequest.hfid); var Announcements = objContext.Announcements.Find(Announcementid); if (Announcements != null) { #region System Change Log var oldresult = (from a in objContext.Announcements where a.AnnouncementID == Announcementid select a).ToList(); DataTable dtOld = KISD.Areas.Admin.Models.Common.LINQResultToDataTable(oldresult); #endregion var isvalid = true; if (AnnouncementType == Convert.ToInt32(AnnouncementTypeAlias.OnscreenAlert)) { var onscreenalerttypeid = Convert.ToInt32(AnnouncementTypeAlias.OnscreenAlert); var alertcnt = objContext.Announcements.Where(x => x.TypeMasterID == onscreenalerttypeid && x.StatusInd == true && x.IsDeletedInd == false).Count(); if (alertcnt == 3 && objAjaxRequest.hfvalue == "1") { TempData["Message"] = "Maximum three onscreen alerts can be set as active to show on website."; isvalid = false; } } if (isvalid) { Announcements.StatusInd = objAjaxRequest.hfvalue == "1"; if (objAjaxRequest.qs_Type == "displayorder") { if (AnnouncementService.ChangeAnnouncementDisplayOrder(Announcements.DisplayOrderNbr.Value, Convert.ToInt64(objAjaxRequest.qs_value), Announcements.AnnouncementID, Convert.ToInt32(Announcements.TypeMasterID))) { TempData["AlertMessage"] = "Display Order has been changed successfully."; } } else { objContext.SaveChanges(); #region System Change Log SystemChangeLog objSCL = new SystemChangeLog(); long userid = Convert.ToInt64(Membership.GetUser().ProviderUserKey); User objuser = objContext.Users.Where(x => x.UserID == userid).FirstOrDefault(); objSCL.NameTxt = objuser.FirstNameTxt + " " + objuser.LastNameTxt; objSCL.UsernameTxt = objuser.UserNameTxt; objSCL.UserRoleID = (short)objContext.UserRoles.Where(x => x.UserID == objuser.UserID).First().RoleID; objSCL.ModuleTxt = _service.GetAnnouncementType(Announcements.TypeMasterID.Value); objSCL.LogTypeTxt = Announcements.AnnouncementID > 0 ? "Update" : "Add"; objSCL.NotesTxt = _service.GetAnnouncementType(Announcements.TypeMasterID.Value) + " Details updated status for " + Announcements.TitleTxt; objSCL.LogDateTime = DateTime.Now; objContext.SystemChangeLogs.Add(objSCL); objContext.SaveChanges(); objSCL = objContext.SystemChangeLogs.OrderByDescending(x => x.ChangeLogID).FirstOrDefault(); var newResult = (from x in objContext.Announcements where x.AnnouncementID == Announcements.AnnouncementID select x); DataTable dtNew = KISD.Areas.Admin.Models.Common.LINQResultToDataTable(newResult); foreach (DataColumn col in dtNew.Columns) { // if(objSCL) if (dtOld.Rows[0][col.ColumnName].ToString() != dtNew.Rows[0][col.ColumnName].ToString()) { SystemChangeLogDetail objSCLD = new SystemChangeLogDetail(); objSCLD.ChangeLogID = objSCL.ChangeLogID; objSCLD.FieldNameTxt = col.ColumnName.ToString(); objSCLD.OldValueTxt = dtOld.Rows[0][col.ColumnName].ToString(); objSCLD.NewValueTxt = dtNew.Rows[0][col.ColumnName].ToString(); objContext.SystemChangeLogDetails.Add(objSCLD); objContext.SaveChanges(); } } #endregion TempData["AlertMessage"] = "Status updated successfully."; } } objAjaxRequest.hfid = null; //remove parameter value objAjaxRequest.hfvalue = null; //remove parameter value objAjaxRequest.qs_Type = null; PageSize = ((Request.QueryString["pagesize"] != null && Request.QueryString["pagesize"].ToString() != "All") ? Convert.ToInt32(Request.QueryString["pagesize"].ToString()) : Models.Common._pageSize); Page = (Session["pageNo"] != null ? Convert.ToInt32(Session["pageNo"].ToString()) : Models.Common._currentPage); gridSortOptions = (Session["GridSortOption"] != null ? Session["GridSortOption"] as GridSortOptions : gridSortOptions); } } else { TempData["Message"] = string.Empty; } ObjResult = string.Empty; } #endregion Ajax Call ViewBag.Title = ViewBag.PageTitle = _service.GetAnnouncementType(AnnouncementType);//+ "s" //This section is used to retain the values of page , pagesize and gridsortoption on complete page post back(Edit, Dlete) if (!Request.IsAjaxRequest() && Session["Edit/Delete"] != null && !string.IsNullOrEmpty(Session["Edit/Delete"].ToString())) { PageSize = (Session["PageSize"] != null ? Convert.ToInt32(Session["PageSize"]) : Models.Common._pageSize); Page = (Session["pageNo"] != null ? Convert.ToInt32(Session["pageNo"]) : Models.Common._currentPage); gridSortOptions = (Session["GridSortOption"] != null ? Session["GridSortOption"] as GridSortOptions : gridSortOptions); Session["Edit/Delete"] = null; } else if (!Request.IsAjaxRequest() && Session["Edit/Delete"] == null) { gridSortOptions.Column = "AnnouncementCreateDate"; Session["PageSize"] = null; Session["pageNo"] = null; Session["GridSortOption"] = null; } if (gridSortOptions.Column == "TitleTxt" || gridSortOptions.Column == "AnnouncementCreateDate" || gridSortOptions.Column == "DisplayOrderNbr") { } else { gridSortOptions.Column = "AnnouncementCreateDate"; } //.. Code for get records as page view model var pagesize = PageSize.HasValue ? PageSize.Value : Models.Common._pageSize; var page = Page.HasValue ? Page.Value : Models.Common._currentPage; TempData["pager"] = pagesize; long announcementType = Convert.ToInt64(it); var pagedViewModel = new PagedViewModel <AnnouncementModel> { ViewData = ViewData, Query = _service.GetAnnouncements(announcementType).AsQueryable(), GridSortOptions = gridSortOptions, DefaultSortColumn = "AnnouncementCreateDate", Page = page, PageSize = pagesize, }.Setup(); if (Request.IsAjaxRequest()) // check if request comes from ajax, then return Partial view { return(View("AnnouncementPartial", pagedViewModel)); // ("partial view name ") } else { return(View(pagedViewModel)); } }
/// <summary> /// /// </summary> /// <param name="it">Announcement type id</param> /// <param name="iid"> Announcement id</param> /// <returns></returns> public ActionResult Create(string it, string iid) { var objAnnouncementModel = new AnnouncementModel(); //Check for valid TypeMasterID ViewBag.TypeMasterID = it; ViewBag.Title = ""; #region Check Tab is Accessible or Not db_KISDEntities objContext = new db_KISDEntities(); var userId = objContext.Users.Where(x => x.UserNameTxt == User.Identity.Name).Select(x => x.UserID).FirstOrDefault(); var RoleID = objContext.UserRoles.Where(x => x.UserID == userId).Select(x => x.RoleID).FirstOrDefault(); var HasTabAccess = GetAccessibleTabAccess(Convert.ToInt32(ModuleType.Masters), Convert.ToInt32(userId)); if (!(HasTabAccess || RoleID == Convert.ToInt32(UserType.SuperAdmin) || RoleID == Convert.ToInt32(UserType.Admin))) //if tab not accessible then redirect to home { return(RedirectToAction("Index", "Home")); } #endregion if ((Request.QueryString["it"] == null) && (Request.QueryString["iid"] == null) ) { return(RedirectToAction("Index", "Home")); } //decrypt Announcement type id(it) it = !string.IsNullOrEmpty(Convert.ToString(it)) ? EncryptDecrypt.Decrypt(it) : "0"; //decrypt Announcement id(iid) iid = !string.IsNullOrEmpty(Convert.ToString(iid)) ? EncryptDecrypt.Decrypt(iid) : "0"; int AnnouncementID = Convert.ToInt32(iid); if (AnnouncementID > 0 && objContext.Announcements.Where(x => x.AnnouncementID == AnnouncementID && x.IsDeletedInd == true).Any()) { return(RedirectToAction("Index", "Home")); } Session["Edit/Delete"] = "Edit"; ViewBag.Title = ViewBag.PageTitle = (iid == "0" ? "Add " : "Edit ") + (_service.GetAnnouncementType(Convert.ToInt32(it))); ViewBag.Submit = (iid == "0" ? "Save" : "Update"); ViewBag.TypeMasterID = it; ViewBag.AnnouncementTypeTitle = _service.GetAnnouncementType(Convert.ToInt32(it)); // +"s" objAnnouncementModel.AnnouncementCreateDate = DateTime.Now; ViewBag.AnnouncementCreateDate = DateTime.Now.ToShortDateString(); ViewBag.StartDateStr = ""; ViewBag.EndDateStr = ""; ViewBag.ScheduleDateStr = DateTime.Now.ToShortDateString(); objAnnouncementModel.TypeMasterID = Convert.ToInt32(it); if (Convert.ToInt32(iid) > 0) { var Announcement = (from u in objContext.Announcements where u.AnnouncementID == AnnouncementID select u).FirstOrDefault(); if (Announcement != null) { objAnnouncementModel.AnnouncementID = Announcement.AnnouncementID; objAnnouncementModel.TitleTxt = Announcement.TitleTxt; objAnnouncementModel.DisplayStartDate = Announcement.DisplayStartDate; objAnnouncementModel.DisplayEndDate = Announcement.DisplayEndDate; objAnnouncementModel.AltImageTxt = Announcement.AltImageTxt; objAnnouncementModel.DescriptionTxt = Announcement.DescriptionTxt; objAnnouncementModel.ScheduleDateTime = Announcement.ScheduleDateTime; objAnnouncementModel.ImageURLTxt = Announcement.ImageURLTxt; objAnnouncementModel.AnnouncementCreateDate = Convert.ToDateTime(Announcement.AnnouncementCreateDate.Value.ToShortDateString()); objAnnouncementModel.TypeMasterID = Announcement.TypeMasterID; objAnnouncementModel.StatusInd = Announcement.StatusInd.Value; objAnnouncementModel.CreateByID = Announcement.CreateByID; objAnnouncementModel.CreateDate = Announcement.CreateDate; objAnnouncementModel.LastModifyByID = Announcement.LastModifyByID; objAnnouncementModel.LastModifyDate = Announcement.LastModifyDate; objAnnouncementModel.ScheduleTimeTxt = Announcement.ScheduleTimeTxt; ViewBag.StatusInd = GetStatusData(objAnnouncementModel.StatusInd ? "1" : "0"); ViewBag.StartDateStr = objAnnouncementModel.DisplayStartDate.HasValue ? objAnnouncementModel.DisplayStartDate.Value.ToString("MM/dd/yyyy hh:mm tt") : null; ViewBag.EndDateStr = objAnnouncementModel.DisplayEndDate.HasValue ? objAnnouncementModel.DisplayEndDate.Value.ToString("MM/dd/yyyy hh:mm tt") : null; ViewBag.ScheduleDateStr = objAnnouncementModel.ScheduleDateTime.HasValue ? objAnnouncementModel.ScheduleDateTime.Value.ToShortDateString() : DateTime.Now.ToShortDateString(); ViewBag.AnnouncementCreateDate = objAnnouncementModel.AnnouncementCreateDate.HasValue ? objAnnouncementModel.AnnouncementCreateDate.Value.ToShortDateString(): DateTime.Now.ToShortDateString(); } } else { if (Convert.ToInt32(it) == Convert.ToInt32(AnnouncementTypeAlias.OnscreenAlert)) { var onscreenalerttypeid = Convert.ToInt32(AnnouncementTypeAlias.OnscreenAlert); var alertcnt = objContext.Announcements.Where(x => x.TypeMasterID == onscreenalerttypeid && x.StatusInd == true && x.IsDeletedInd == false).Count(); if (alertcnt == 3) { ViewBag.StatusInd = GetStatusData("0"); } else { ViewBag.StatusInd = GetStatusData(string.Empty); } } else { ViewBag.StatusInd = GetStatusData(string.Empty); } } return(View(objAnnouncementModel)); }
/// <summary> /// Gallery Listing Service /// </summary> public UsersManagementListingService() { _context = new db_KISDEntities(); }
public JsonResult Delete(string bmid) { bmid = !string.IsNullOrEmpty(Convert.ToString(bmid)) ? EncryptDecrypt.Decrypt(bmid) : "0"; long BOMID = Convert.ToInt32(bmid); var rvd = new RouteValueDictionary(); rvd.Add("pagesize", Request.QueryString["pagesize"] ?? "10"); rvd.Add("Column", Request.QueryString["Column"] ?? "BOMCreateDate"); rvd.Add("Direction", Request.QueryString["Direction"] ?? "Descending"); Session["Edit/Delete"] = "Delete"; if (BOMID > 0) { try { using (var objContext = new db_KISDEntities()) { #region System Change Log var oldresult = (from a in objContext.BoardOfMembers where a.BoardMemberID == BOMID select a).ToList(); DataTable dtOld = Models.Common.LINQResultToDataTable(oldresult); #endregion //****************Display Order ************************ var objData = objContext.BoardOfMembers.Where(x => x.BoardMemberID == BOMID).FirstOrDefault(); if (objData != null) { try { var objModelService = new BoardMembersModelService(); var parentid = Request.QueryString["ParentId"] ?? "0"; objModelService.ChangeDeletedDisplayOrder(objData.DisplayOrderNbr.Value, objData.BoardMemberID); } catch { } } //*************************************************** #region System Change Log SystemChangeLog objSCL = new SystemChangeLog(); long userid = Convert.ToInt64(Membership.GetUser().ProviderUserKey); User objuser = objContext.Users.Where(x => x.UserID == userid).FirstOrDefault(); objSCL.NameTxt = objuser.FirstNameTxt + " " + objuser.LastNameTxt; objSCL.UsernameTxt = objuser.UserNameTxt; objSCL.UserRoleID = (short)objContext.UserRoles.Where(x => x.UserID == objuser.UserID).First().RoleID; objSCL.ModuleTxt = "Board Members"; objSCL.LogTypeTxt = "Delete"; objSCL.NotesTxt = "Board Members Details deleted for " + objData.NameTxt; objSCL.LogDateTime = DateTime.Now; objContext.SystemChangeLogs.Add(objSCL); objContext.SaveChanges(); objSCL = objContext.SystemChangeLogs.OrderByDescending(x => x.ChangeLogID).FirstOrDefault(); var newResult = (from x in objContext.RightSections where x.RightSectionID == BOMID select x); DataTable dtNew = Models.Common.LINQResultToDataTable(newResult); foreach (DataColumn col in dtNew.Columns) { try { SystemChangeLogDetail objSCLD = new SystemChangeLogDetail(); objSCLD.ChangeLogID = objSCL.ChangeLogID; objSCLD.FieldNameTxt = col.ColumnName.ToString(); objSCLD.OldValueTxt = dtOld.Rows[0][col.ColumnName].ToString(); objSCLD.NewValueTxt = col.ColumnName == "IsDeletedInd" ? dtNew.Rows[0][col.ColumnName].ToString() : ""; objContext.SystemChangeLogDetails.Add(objSCLD); objContext.SaveChanges(); } catch { } } #endregion try { Models.Common.DeleteImage(Server.MapPath(objData.ImageURLTxt)); } catch { } TempData["Message"] = " Board Member details deleted successfully."; } } catch (Exception e) { TempData["Message"] = "Some error occured while deleting the Member, Please try again later."; } } int?Page = 1; var count = 1; using (var objContext = new db_KISDEntities()) { count = objContext.Users.Where(x => x.IsDeletedInd == false).Count(); } var page = Request.QueryString["page"] ?? "1"; var pagesize = Request.QueryString["pagesize"] ?? "10"; if (Convert.ToInt32(page) > 1) { Page = count > ((Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize)) ? Convert.ToInt32(page) : (Convert.ToInt32(page)) - 1; } rvd.Add("page", Page); return(Json(Url.Action("Index", "BoardMembers", rvd))); }
public ActionResult Index(int?Page, int?PageSize, GridSortOptions gridSortOptions, FormCollection formCollection, string ObjResult) { var objContext = new db_KISDEntities(); var currentLoggedUserId = Convert.ToInt64(Membership.GetUser().ProviderUserKey); var CurrentUserRoleID = objContext.UserRoles.Where(x => x.UserID == currentLoggedUserId).FirstOrDefault().RoleID; #region Check Tab is Accessible or Not var userId = objContext.Users.Where(x => x.UserNameTxt == User.Identity.Name).Select(x => x.UserID).FirstOrDefault(); var RoleID = objContext.UserRoles.Where(x => x.UserID == userId).Select(x => x.RoleID).FirstOrDefault(); var HasTabAccess = GetAccessibleTabAccess(Convert.ToInt32(ModuleType.SchoolBoard), Convert.ToInt32(userId)); if (!(HasTabAccess || RoleID == Convert.ToInt32(UserType.SuperAdmin) || RoleID == Convert.ToInt32(UserType.Admin))) //if tab not accessible then redirect to home { return(RedirectToAction("Index", "Home")); } #endregion ViewBag.Title = ViewBag.PageTitle = "Board Members Listing"; //*******************Fill Values if Display order contains null values*************************** var displayOrderList = objContext.BoardOfMembers.Where(x => x.IsDeletedInd == false).ToList(); foreach (var item in displayOrderList) { if (string.IsNullOrEmpty(item.DisplayOrderNbr.ToString())) { var objContentData = objContext.BoardOfMembers.Where(x => x.BoardMemberID == item.BoardMemberID && x.IsDeletedInd == false).FirstOrDefault(); var displayOrder1 = (displayOrderList.Max(x => x.DisplayOrderNbr)) == null ? 1 : displayOrderList.Max(x => x.DisplayOrderNbr).Value + 1; objContentData.DisplayOrderNbr = displayOrder1; objContext.SaveChanges(); } } //*********************************************************** #region Ajax Call if (ObjResult != null) { AjaxRequest objAjaxRequest = JsonConvert.DeserializeObject <AjaxRequest>(ObjResult);//Convert json String to object Model if (objAjaxRequest.ajaxcall != null && !string.IsNullOrEmpty(objAjaxRequest.ajaxcall) && ObjResult != null && !string.IsNullOrEmpty(ObjResult)) { if (objAjaxRequest.ajaxcall == "paging") //Ajax Call type = paging i.e. Next|Previous|Back|Last { Session["pageNo"] = Page; // stores the page no for status } else if (objAjaxRequest.ajaxcall == "sorting") //Ajax Call type = sorting i.e. column sorting Asc or Desc { Page = (Session["pageNo"] != null ? Convert.ToInt32(Session["pageNo"].ToString()) : Page); Session["GridSortOption"] = gridSortOptions; PageSize = (Session["PageSize"] != null ? Convert.ToInt32(Session["PageSize"].ToString()) : PageSize); } else if (objAjaxRequest.ajaxcall == "ddlPaging")//Ajax Call type = drop down paging i.e. drop down value 10, 25, 50, 100, ALL { Session["PageSize"] = (Request.QueryString["pagesize"] != null ? Convert.ToInt32(Request.QueryString["pagesize"].ToString()) : PageSize); Session["GridSortOption"] = gridSortOptions; Session["pageNo"] = Page; } else if (objAjaxRequest.ajaxcall == "status")//Ajax Call type = status i.e. Active/Inactive { Page = (Session["pageNo"] != null ? Convert.ToInt32(Session["pageNo"].ToString()) : Page); gridSortOptions = (Session["GridSortOption"] != null ? Session["GridSortOption"] as GridSortOptions : gridSortOptions); } objAjaxRequest.ajaxcall = null;; //remove parameter value } //Ajax Call for update status for images if (objAjaxRequest.hfid != null && objAjaxRequest.hfvalue != null && !string.IsNullOrEmpty(objAjaxRequest.hfid) && !string.IsNullOrEmpty(objAjaxRequest.hfvalue) && ObjResult != null && !string.IsNullOrEmpty(ObjResult)) { var ListingID = Convert.ToInt64(objAjaxRequest.hfid); var Listing = objContext.BoardOfMembers.Find(ListingID); if (Listing != null) { #region System Change Log var oldresult = (from a in objContext.BoardOfMembers where a.BoardMemberID == ListingID select a).ToList(); DataTable dtOld = Models.Common.LINQResultToDataTable(oldresult); #endregion if (objAjaxRequest.qs_Type == "status") { Listing.StatusInd = objAjaxRequest.hfvalue == "1"; TempData["Message"] = "Status updated successfully."; } else if (objAjaxRequest.qs_Type == "displayorder") { try { if (BoardMembersModelService.ChangeDisplayOrder(Convert.ToInt64(Listing.DisplayOrderNbr), Convert.ToInt64(objAjaxRequest.qs_value))) { TempData["Message"] = "Display Order has been changed successfully."; } } catch { TempData["Message"] = "Some Error Occured while changing Display Order, Please try again later."; } } objContext.SaveChanges(); #region System Change Log SystemChangeLog objSCL = new SystemChangeLog(); User objuser = objContext.Users.Where(x => x.UserID == currentLoggedUserId).FirstOrDefault(); objSCL.NameTxt = objuser.FirstNameTxt + " " + objuser.LastNameTxt; objSCL.UsernameTxt = objuser.UserNameTxt; objSCL.UserRoleID = (short)objContext.UserRoles.Where(x => x.UserID == objuser.UserID).First().RoleID; objSCL.ModuleTxt = "Board Member Listing"; objSCL.LogTypeTxt = "Update"; objSCL.NotesTxt = (objAjaxRequest.qs_Type == "status" ? "Status " : "Display order ") + "updated for " + Listing.NameTxt; objSCL.LogDateTime = DateTime.Now; objContext.SystemChangeLogs.Add(objSCL); objContext.SaveChanges(); objSCL = objContext.SystemChangeLogs.OrderByDescending(x => x.ChangeLogID).FirstOrDefault(); var newResult = (from x in objContext.BoardOfMembers where x.BoardMemberID == Listing.BoardMemberID select x); DataTable dtNew = Models.Common.LINQResultToDataTable(newResult); foreach (DataColumn col in dtNew.Columns) { // if(objSCL) if (dtOld.Rows[0][col.ColumnName].ToString() != dtNew.Rows[0][col.ColumnName].ToString()) { SystemChangeLogDetail objSCLD = new SystemChangeLogDetail(); objSCLD.ChangeLogID = objSCL.ChangeLogID; objSCLD.FieldNameTxt = col.ColumnName.ToString(); objSCLD.OldValueTxt = dtOld.Rows[0][col.ColumnName].ToString(); objSCLD.NewValueTxt = dtNew.Rows[0][col.ColumnName].ToString(); objContext.SystemChangeLogDetails.Add(objSCLD); objContext.SaveChanges(); } } #endregion objAjaxRequest.hfid = null; //remove parameter value objAjaxRequest.hfvalue = null; //remove parameter value PageSize = ((Request.QueryString["pagesize"] != null && Request.QueryString["pagesize"].ToString() != "All") ? Convert.ToInt32(Request.QueryString["pagesize"].ToString()) : PageSize); Page = (Session["pageNo"] != null ? Convert.ToInt32(Session["pageNo"].ToString()) : Page); gridSortOptions = (Session["GridSortOption"] != null ? Session["GridSortOption"] as GridSortOptions : gridSortOptions); } } else { TempData["Message"] = string.Empty; } ObjResult = string.Empty; } #endregion Ajax Call //This section is used to retain the values of page , pagesize and gridsortoption on complete page post back(Edit, Dlete) if (!Request.IsAjaxRequest() && Session["Edit/Delete"] != null && !string.IsNullOrEmpty(Session["Edit/Delete"].ToString())) { PageSize = (Session["PageSize"] != null ? Convert.ToInt32(Session["PageSize"]) : Models.Common._pageSize); Page = (Session["pageNo"] != null ? Convert.ToInt32(Session["pageNo"]) : Models.Common._currentPage); gridSortOptions = (Session["GridSortOption"] != null ? Session["GridSortOption"] as GridSortOptions : gridSortOptions); Session["Edit/Delete"] = null; } else if (!Request.IsAjaxRequest() && Session["Edit/Delete"] == null) { gridSortOptions.Column = "BOMCreateDate"; Session["PageSize"] = null; Session["pageNo"] = null; Session["GridSortOption"] = null; } if (gridSortOptions.Column == "NameTxt" || gridSortOptions.Column == "TitleTxt" || gridSortOptions.Column == "DisplayOrderNbr" || gridSortOptions.Column == "TitleTxt" ) { } else { gridSortOptions.Column = "BOMCreateDate"; } //.. Code for get records as page view model var pagesize = PageSize.HasValue ? PageSize.Value : Models.Common._pageSize; var page = Page.HasValue ? Page.Value : Models.Common._currentPage; TempData["pager"] = pagesize; var pagedViewModel = new PagedViewModel <BoardMembersModel> { ViewData = ViewData, Query = _service.GetBoardMembers().AsQueryable(), GridSortOptions = gridSortOptions, DefaultSortColumn = "BOMCreateDate", Page = page, PageSize = pagesize, }.Setup(); if (Request.IsAjaxRequest()) // check if request comes from ajax, then return Partial view { return(View("BoardMembersListingPartial", pagedViewModel)); // ("partial view name ") } else { return(View(pagedViewModel)); } }