public JsonResult UserRoleChange(int id, string userRole) { try { Dictionary <int, CheckSessionData> dictionary = CheckSessionData.GetSessionValues(); int companyId = Convert.ToInt32(dictionary[1].Id == "" ? 0 : Convert.ToInt32(dictionary[1].Id)); if (companyId != 0) { _userGroupFactory = new UserGroupFactory(); _userFactory = new UserFactory(); int userId = Convert.ToInt32(dictionary[3].Id); SEC_UserInformation user = _userFactory.FindBy(x => x.ID == userId).FirstOrDefault(); SEC_UserGroup userGroup = _userGroupFactory.FindBy(x => x.ID == user.UserGroupID).FirstOrDefault(); if (userGroup != null && userGroup.IsAdmin) { SEC_UserGroup role = _userGroupFactory.FindBy(x => x.Name == userRole).FirstOrDefault(); _userFactory = new UserFactory(); SEC_UserInformation tblUserInformation = _userFactory.FindBy(x => x.ID == id).FirstOrDefault(); if (tblUserInformation != null) { tblUserInformation.UserGroupID = role.ID; _userFactory.Edit(tblUserInformation); } _userFactory.Save(); return(Json(new { success = true, message = "Sucessifuly changed the user role" }, JsonRequestBehavior.AllowGet)); } return(Json(new { success = false, message = "You are not Admin User" }, JsonRequestBehavior.AllowGet)); } return(Json(new { success = false, message = "LogOut" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public JsonResult UpdateUserForm(UserModel user) { try { result = new Result(); Dictionary <int, CheckSessionData> dictionary = CheckSessionData.GetSessionValues(); int userId = Convert.ToInt32(dictionary[3].Id); if (userId != 0) { _userFactory = new UserFactory(); var aUserInformation = _userFactory.FindBy(x => x.UserName == user.UserName.ToLower().Trim()).FirstOrDefault(); if (aUserInformation != null) { aUserInformation.UpdatedDate = DateTime.Now; aUserInformation.UpdatedBy = userId; aUserInformation.UserGroupID = user.UserGroupID; _userFactory.Edit(aUserInformation); result = _userFactory.Save(); } return(Json(new { success = false, message = "Your entared user name does not exist!!!" }, JsonRequestBehavior.AllowGet)); } Session["logInSession"] = null; return(Json(new { success = false, message = "LogOut" }, JsonRequestBehavior.AllowGet)); } catch (Exception exception) { return(Json(new { success = false, message = exception.Message }, JsonRequestBehavior.AllowGet)); } }
public Result SaveEmployee(Employee emp) { Result _result = new Result(); try { _employeeFactory = new EmployeeFactory(); if (emp.EmployeeID < 1) { _employeeFactory.Add(emp); _result = _employeeFactory.Save(); if (_result.isSucess) { _result.message = _result.SaveSuccessfull(tableName); } } else { _employeeFactory.Edit(emp); _result = _employeeFactory.Save(); if (_result.isSucess) { _result.message = _result.UpdateSuccessfull(tableName); } } } catch (Exception ex) { _result.isSucess = false; _result.message = ex.Message; } return(_result); }
public Result SaveAppointment(DAL.db.Appointment appointment) { _unScheduleAppointment = new UnScheduleAppointmentFactory(); try { if (appointment.AppointmentID > 0) { _unScheduleAppointment.Edit(appointment); _result = _unScheduleAppointment.Save(); if (_result.isSucess) { _result.message = _result.UpdateSuccessfull(tableName); } } else { _unScheduleAppointment.Add(appointment); _result = _unScheduleAppointment.Save(); if (_result.isSucess) { _result.message = _result.SaveSuccessfull(tableName); } } } catch (Exception e) { _result.isSucess = false; _result.message = e.Message; } return(_result); }
public Result SaveMeetingRoom(DAL.db.MeetingRoom meetingRoom) { _mrFactory = new MeetingRoomFactory(); try { if (meetingRoom.MeetingRoomID > 0) { _mrFactory.Edit(meetingRoom); _result = _mrFactory.Save(); if (_result.isSucess) { _result.message = _result.UpdateSuccessfull(tableName); } } else { _mrFactory.Add(meetingRoom); _result = _mrFactory.Save(); if (_result.isSucess) { _result.message = _result.SaveSuccessfull(tableName); } } } catch (Exception e) { _result.isSucess = false; _result.message = e.Message; } return(_result); }
public Result SelfPasswordChange(ChangePasswordModel changePassword) { try { result = new Result(); result.isSucess = false; Dictionary <int, CheckSessionData> dictionary = CheckSessionData.GetSessionValues(); int userGroupId = Convert.ToInt32(dictionary[6].Id == "" ? 0 : Convert.ToInt32(dictionary[6].Id)); if (userGroupId != 0) { int userId = Convert.ToInt32(dictionary[3].Id); string userName = dictionary[4].Id; _userFactory = new UserFactory(); bool status = _userFactory.GetAll().Any(x => x.UserName == userName && x.UserGroupID == userGroupId); if (status == true) { SEC_UserInformation tblUserInformation; tblUserInformation = _userFactory.FindBy(x => x.ID == userId).FirstOrDefault(); _passwordFactory = new UserPasswordFactory(); Encription encription = new Encription(); SEC_Password tblPassword = _passwordFactory.GetAll().FirstOrDefault(x => x.ID == tblUserInformation.PasswordID); if (tblPassword != null) { tblPassword.OldPassword = tblPassword.NewPassword; tblPassword.NewPassword = encription.Encrypt(changePassword.NewPassword.Trim()); tblPassword.IsSelfChanged = true; tblPassword.UpdatedDate = DateTime.Now; tblPassword.UpdatedBy = userId; _passwordFactory.Edit(tblPassword); } result = _passwordFactory.Save(); if (result.isSucess) { result.message = "Changed Password Sucessfully"; return(result); } } result.message = "Password not Changed try again"; return(result); } result.message = "LogOut"; } catch (Exception exception) { result.isSucess = false; result.message = exception.Message; } return(result); }
public JsonResult ActiveDeActiveUser(int id, bool status) { try { Dictionary <int, CheckSessionData> dictionary = CheckSessionData.GetSessionValues(); int userGroupId = Convert.ToInt32(dictionary[6].Id == "" ? 0 : Convert.ToInt32(dictionary[6].Id)); if (userGroupId != 0) { ISecurityFactory _securityLogInFactory = new SecurityFactorys(); PagePermissionVM tblUserActionMapping = _securityLogInFactory.GetCrudPermission(userGroupId, "User"); if (tblUserActionMapping.Edit) { _userGroupFactory = new UserGroupFactory(); _userFactory = new UserFactory(); int userId = Convert.ToInt32(dictionary[3].Id); SEC_UserInformation user = _userFactory.FindBy(x => x.ID == userId).FirstOrDefault(); SEC_UserGroup userGroup = _userGroupFactory.FindBy(x => x.ID == user.UserGroupID).FirstOrDefault(); if (userGroup != null && userGroup.IsAdmin) { _userFactory = new UserFactory(); SEC_UserInformation tblUserInformation = _userFactory.FindBy(x => x.ID == id).FirstOrDefault(); if (tblUserInformation != null) { tblUserInformation.IsActive = status; _userFactory.Edit(tblUserInformation); } _userFactory.Save(); if (status) { return(Json(new { success = true, message = "Sucessifuly activeted the User" }, JsonRequestBehavior.AllowGet)); } return(Json(new { success = true, message = "Sucessifuly de-activeted the User" }, JsonRequestBehavior.AllowGet)); } return(Json(new { success = false, message = "You are not Admin User" }, JsonRequestBehavior.AllowGet)); } return(Json(new { success = false, message = "You has no permission for edit" }, JsonRequestBehavior.AllowGet)); } return(Json(new { success = false, message = "LogOut" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public Result SaveCompanyBranch(SET_CompanyBranch companyBranch) { _result = new Result(); _companyBranchFactory = new CompanyBranchFactory(); try { Dictionary <int, CheckSessionData> dictionary = CheckSessionData.GetSessionValues(); int userGroupId = Convert.ToInt32(dictionary[6].Id == "" ? 0 : Convert.ToInt32(dictionary[6].Id)); if (userGroupId != 0) { if (companyBranch.BranchID > 0) { _companyBranchFactory.Edit(companyBranch); _result = _companyBranchFactory.Save(); } else { int branchID = 1; var prvBranchID = _companyBranchFactory.GetLastRecord().OrderByDescending(x => x.BranchID).FirstOrDefault(); if (prvBranchID != null) { branchID = prvBranchID.BranchID + 1; } companyBranch.BranchID = branchID; _companyBranchFactory.Add(companyBranch); _result = _companyBranchFactory.Save(); } } else { _result.isSucess = false; _result.message = "Logout"; } } catch (Exception e) { _result.isSucess = false; _result.message = e.Message; } return(_result); }
public Result UnassignCard(int deviceNo, string cardNO) { _card = new CardFactory(); try { var card = _card.FindBy(x => x.DeviceNO == deviceNo && x.CardNO == cardNO).FirstOrDefault(); if (card != null) { card.CardNO = null; _card.Edit(card); _card.Save(); _result.isSucess = true; } } catch (Exception e) { _result.isSucess = false; } return(_result); }
public Result SaveCard(Card card) { Result _result = new Result(); try { _card = new CardFactory(); if (card.ID > 0) { _card.Edit(card); _result = _card.Save(); if (_result.isSucess) { _result.message = _result.UpdateSuccessfull(tableName); } } } catch (Exception ex) { _result.isSucess = false; _result.message = ex.Message; } return(_result); }
public Result SaveDepartment(Department dept) { Result _result = new Result(); try { _departmentFactory = new DepartmentFactory(); if (dept.DepartmentID < 1) { _departmentFactory.Add(dept); _result = _departmentFactory.Save(); if (_result.isSucess) { _result.isSucess = true; _result.message = _result.SaveSuccessfull(tableName); } } else { _departmentFactory.Edit(dept); _result = _departmentFactory.Save(); if (_result.isSucess) { _result.isSucess = true; _result.message = _result.UpdateSuccessfull(tableName); } } } catch (Exception ex) { _result.isSucess = false; _result.message = ex.Message; } return(_result); }
public ActionResult LogOff() { try { Dictionary <int, CheckSessionData> dictionary = CheckSessionData.GetSessionValues(); if (dictionary[3].Id != null || dictionary[3].Id != "") { int userId = Convert.ToInt32(dictionary[3].Id); _loginStatusFactory = new LoginStatusFactory(); SEC_LoginStatus loginStatus = _loginStatusFactory.FindBy(x => x.UserID == userId).FirstOrDefault(); loginStatus.PresentLogInStatus = false; loginStatus.LogOutTime = DateTime.Now; loginStatus.ForcedLogOutStatus = false; _loginStatusFactory.Edit(loginStatus); _loginStatusFactory.Save(); System.Web.HttpContext.Current.Session["LoginUserID"] = 0; System.Web.HttpContext.Current.Session["LoginUserName"] = 0; System.Web.HttpContext.Current.Session["LoginEmployee"] = 0; System.Web.HttpContext.Current.Session["LoginCompanyID"] = 0; System.Web.HttpContext.Current.Session["LoginBranchID"] = 0; System.Web.HttpContext.Current.Session["LoginUserFullName"] = 0; System.Web.HttpContext.Current.Session["UserGroupID"] = 0; System.Web.HttpContext.Current.Session["IPAddress"] = 0; Session["logInSession"] = null; return(Redirect("/#!/")); } return(Redirect("/#!/")); } catch (Exception) { return(Redirect("/#!/")); } }
public Result SaveDesignation(Designation designation) { Result _result = new Result(); try { _esignationFactory = new DesignationFactory(); if (designation.DesignationID < 1) { _esignationFactory.Add(designation); _result = _esignationFactory.Save(); if (_result.isSucess) { _result.isSucess = true; _result.message = _result.SaveSuccessfull(tableName); } } else { _esignationFactory.Edit(designation); _result = _esignationFactory.Save(); if (_result.isSucess) { _result.isSucess = true; _result.message = _result.UpdateSuccessfull(tableName); } } } catch (Exception ex) { _result.isSucess = false; _result.message = ex.Message; } return(_result); }
public Result EditUserGroupPagePermission(SEC_UserGroup userGroup, List <MenuItemVM> userMappingVm = null) { Result _result = new Result(); using (var dbContextTransaction = context.Database.BeginTransaction()) { try { Dictionary <int, CheckSessionData> dictionary = CheckSessionData.GetSessionValues(); int userId = Convert.ToInt32(dictionary[3].Id); _userGroupFactory = new UserGroupFactory(); if (userGroup != null) { userGroup.UpdatedBy = userId; userGroup.UpdatedDate = DateTime.Now; _userGroupFactory.Edit(userGroup); _result = _userGroupFactory.Save(); } if (_result.isSucess) { if (userMappingVm != null) { _userActionMappingFactory = new UserActionMappingFactory(); int userGroupId = Convert.ToInt32(userGroup.ID); List <SEC_UserActionMapping> userMappingList = _userActionMappingFactory.FindBy(x => x.UserGroupID == userGroupId).ToList(); foreach (var item in userMappingVm) { SEC_UserActionMapping userMapping = userMappingList.FirstOrDefault(x => x.UIPageID == item.PageId); if (userMapping != null) { userMapping.IsSelect = item.Select != null ? (bool)item.Select : userMapping.IsSelect; userMapping.IsCreate = item.Create != null ? (bool)item.Create : userMapping.IsCreate; userMapping.IsEdit = item.Edit != null ? (bool)item.Edit : userMapping.IsEdit; userMapping.IsDelete = item.Delete != null ? (bool)item.Delete : userMapping.IsDelete; userMapping.UpdatedDate = DateTime.Now; userMapping.UpdatedBy = userId; _userActionMappingFactory.Edit(userMapping); } _result = _userActionMappingFactory.Save(); } if (_result.isSucess) { _result.message = _result.UpdateSuccessfull(tableName); dbContextTransaction.Commit(); } else { _result.isSucess = false; dbContextTransaction.Rollback(); } } } return(_result); } catch (Exception ex) { _result.isSucess = false; dbContextTransaction.Rollback(); return(_result); } } }
public Result SaveMeetingReq(MeetingRoomRequisition meetingRoomReq, List <DAL.db.MeetingParticipant> participantList, List <int> deleteStoreReqDtlsID) { _mrReqFactory = new MeetingRoomReqFactory(); _mrPrFactory = new ParticipantFactory(); try { if (meetingRoomReq.RequisitionID > 0) { _mrReqFactory.Edit(meetingRoomReq); _result = _mrReqFactory.Save(); if (_result.isSucess) { if (deleteStoreReqDtlsID != null) { foreach (var detailsID in deleteStoreReqDtlsID) { _mrPrFactory.Delete(x => x.ParticipantID == detailsID); _result = _mrPrFactory.Save(); } } if (participantList != null) { foreach (var list in participantList) { if (list.ParticipantID < 1) { list.RequisitionID = meetingRoomReq.RequisitionID; _mrPrFactory.Add(list); _result = _mrPrFactory.Save(); if (_result.isSucess) { _result.message = _result.UpdateSuccessfull(tableName); } } else { _mrPrFactory.Edit(list); _result = _mrPrFactory.Save(); if (_result.isSucess) { _result.message = _result.UpdateSuccessfull(tableName); } } } } } } else { _mrReqFactory.Add(meetingRoomReq); _result = _mrReqFactory.Save(); if (_result.isSucess) { if (participantList != null && participantList.Count > 0) { foreach (var list in participantList) { if (list.ParticipantID < 1) { list.RequisitionID = meetingRoomReq.RequisitionID; _mrPrFactory.Add(list); _result = _mrPrFactory.Save(); if (_result.isSucess) { _result.message = _result.UpdateSuccessfull(tableName); } } } } } } } catch (Exception e) { _mrReqFactory.Delete(meetingRoomReq); _result = _mrReqFactory.Save(); _result.isSucess = false; _result.message = e.Message; } return(_result); }
public Result UiPageSave(SEC_UIPage page) { Result _result = new Result(); _uiPageFactory = new UiPageFactory(); _userActionMappingFactory = new UserActionMappingFactory(); Dictionary <int, CheckSessionData> dictionary = CheckSessionData.GetSessionValues(); int userId = Convert.ToInt32(dictionary[6].Id == "" ? 0 : Convert.ToInt32(dictionary[6].Id)); int empId = Convert.ToInt32(dictionary[1].Id == "" ? 0 : Convert.ToInt32(dictionary[1].Id)); try { if (page.ID > 0) { _uiPageFactory.Edit(page); _result = _uiPageFactory.Save(); if (_result.isSucess) { SEC_UserActionMapping userActionMapping = new SEC_UserActionMapping(); _userGroupFactory = new UserGroupFactory(); var groupID = _userGroupFactory.GetAll().ToList(); foreach (var details in groupID) { var uiMapping = _userActionMappingFactory.FindBy(x => x.UserGroupID == details.ID && x.UIPageID == page.ID).Count(); if (uiMapping == 0) { userActionMapping.UserGroupID = details.ID; userActionMapping.UIPageID = page.ID; userActionMapping.UIModuleID = Convert.ToInt32(page.ModuleID); userActionMapping.IsCreate = false; userActionMapping.IsDelete = false; userActionMapping.IsEdit = false; userActionMapping.IsSelect = false; userActionMapping.CreatedBy = empId; userActionMapping.CreatedDate = DateTime.Now; _userActionMappingFactory.Add(userActionMapping); _result = _userActionMappingFactory.Save(); } } if (_result.isSucess) { _result.message = _result.UpdateSuccessfull(tablePageName); return(_result); } _result.message = _result.UpdateSuccessfull(tablePageName); } } else { int pageID = 1; var prvPage = _uiPageFactory.GetLastRecord().OrderByDescending(x => x.ID).FirstOrDefault(); if (prvPage != null) { pageID = prvPage.ID + 1; } page.UrlID = 1; page.ID = pageID; _uiPageFactory.Add(page); _result = _uiPageFactory.Save(); if (_result.isSucess) { var uiMapping = _userActionMappingFactory.FindBy(x => x.UserGroupID == userId && x.UIPageID == page.ID).Count(); if (uiMapping == 0) { SEC_UserActionMapping userActionMapping = new SEC_UserActionMapping(); _userGroupFactory = new UserGroupFactory(); var groupID = _userGroupFactory.GetAll().ToList(); foreach (var details in groupID) { userActionMapping.UserGroupID = details.ID; userActionMapping.UIPageID = page.ID; userActionMapping.UIModuleID = Convert.ToInt32(page.ModuleID); userActionMapping.IsCreate = false; userActionMapping.IsDelete = false; userActionMapping.IsEdit = false; userActionMapping.IsSelect = false; userActionMapping.CreatedBy = empId; userActionMapping.CreatedDate = DateTime.Now; _userActionMappingFactory.Add(userActionMapping); _result = _userActionMappingFactory.Save(); } if (_result.isSucess) { _result.message = _result.SaveSuccessfull(tablePageName); _result.lastInsertedID = userActionMapping.ID; return(_result); } } _result.message = _result.SaveSuccessfull(tablePageName); } } } catch (Exception e) { _result.isSucess = false; _result.message = e.Message; } return(_result); }
public Result PasswordChangeByAdminSave(ChangePasswordModel changePassword) { try { result = new Result(); result.isSucess = false; Dictionary <int, CheckSessionData> dictionary = CheckSessionData.GetSessionValues(); int userGroupID = Convert.ToInt32(dictionary[6].Id); int userId = Convert.ToInt32(dictionary[3].Id); string userName = dictionary[4].Id; if (userGroupID != 0) { _userFactory = new UserFactory(); _passwordFactory = new UserPasswordFactory(); _userGroup = new UserGroupFactory(); Encription encription = new Encription(); SEC_Password tblPassword; SEC_UserInformation tblUserInformation = new SEC_UserInformation(); SEC_UserGroup tblUserGroup = new SEC_UserGroup(); if (changePassword.FullName != "" || changePassword.UserName != "") { if (changePassword.UserName != null) { tblUserInformation = _userFactory.FindBy(x => x.UserName == changePassword.UserName).FirstOrDefault(); } tblUserGroup = _userGroup.FindBy(x => x.ID == userGroupID).FirstOrDefault(); if (tblUserGroup != null) { if (tblUserGroup.IsAdmin == false) { result.message = "You are not a Admin"; return(result); } tblPassword = _passwordFactory.GetAll().FirstOrDefault(x => x.ID == tblUserInformation.PasswordID); if (tblPassword != null) { tblPassword.OldPassword = tblPassword.NewPassword; tblPassword.NewPassword = encription.Encrypt(changePassword.NewPassword.Trim()); tblPassword.IsSelfChanged = false; tblPassword.UpdatedDate = DateTime.Now; tblPassword.UpdatedBy = userId; _passwordFactory.Edit(tblPassword); } result = _passwordFactory.Save(); if (result.isSucess) { result.message = "Changed Password Sucessfully"; return(result); } } result.message = "User cant found"; return(result); } result.message = "Password not Changed try again"; return(result); } result.message = "Logout"; } catch (Exception exception) { result.isSucess = false; result.message = exception.Message; return(result); } return(result); }
public Result SaveUserGroupWithPagePermission(SEC_UserGroup userGroup, List <MenuItemVM> menuVm) { Result result = new Result(); using (var dbContextTransaction = context.Database.BeginTransaction()) { try { _userGroupFactory = new UserGroupFactory(); _userGroupFactory.Add(userGroup); bool isDuplicate = _userGroupFactory.FindBy(x => x.Name.ToLower().Trim() == userGroup.Name.ToLower().Trim()).Any(x => x.Name.ToLower() == userGroup.Name.ToLower()); if (!isDuplicate) { _userGroupFactory.Save(); _uiPageFactory = new UiPageFactory(); _userActionMappingFactory = new UserActionMappingFactory(); List <SEC_UIPage> uiPageList = _uiPageFactory.GetAll().ToList(); foreach (var item in uiPageList) { SEC_UserActionMapping userMappings = new SEC_UserActionMapping(); userMappings.UserGroupID = Convert.ToInt32(userGroup.ID); userMappings.UIModuleID = Convert.ToInt32(item.ModuleID); userMappings.UIPageID = item.ID; userMappings.IsSelect = false; userMappings.IsCreate = false; userMappings.IsEdit = false; userMappings.IsDelete = false; userMappings.CreatedDate = DateTime.Now; userMappings.CreatedBy = Convert.ToInt32(userGroup.CreatedBy); _userActionMappingFactory.Add(userMappings); } _userActionMappingFactory.Save(); if (menuVm != null) { int userGroupId = Convert.ToInt32(userGroup.ID); List <SEC_UserActionMapping> userMappingList = _userActionMappingFactory.FindBy(x => x.UserGroupID == userGroupId).ToList(); List <MenuItemVM> userMappingVmList = menuVm.Distinct().ToList(); foreach (var item in userMappingVmList) { SEC_UserActionMapping userMapping = new SEC_UserActionMapping(); userMapping = userMappingList.FirstOrDefault(x => x.UIPageID == item.PageId); if (userMapping != null) { userMapping.IsSelect = item.Select != null ? (bool)item.Select : userMapping.IsSelect; userMapping.IsCreate = item.Create != null ? (bool)item.Create : userMapping.IsCreate; userMapping.IsEdit = item.Edit != null ? (bool)item.Edit : userMapping.IsEdit; userMapping.IsDelete = item.Delete != null ? (bool)item.Delete : userMapping.IsDelete; _userActionMappingFactory.Edit(userMapping); } } _userActionMappingFactory.Save(); } result.message = "Saved Successfuly"; result.isSucess = true; dbContextTransaction.Commit(); return(result); } result.message = "Your entared code is duplicate"; result.isSucess = false; dbContextTransaction.Commit(); return(result); } catch (Exception ex) { result.message = "Error occured"; result.isSucess = false; dbContextTransaction.Rollback(); } } return(result); }