Exemplo n.º 1
0
 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));
     }
 }
Exemplo n.º 2
0
 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));
     }
 }
Exemplo n.º 3
0
        public JsonResult GetDeptWiseEmployee(int deptID)
        {
            Dictionary <int, CheckSessionData> dictionary = CheckSessionData.GetSessionValues();
            IVMS_DBEntities db = new IVMS_DBEntities();

            try
            {
                if (deptID > 0)
                {
                    var employee = from b in db.Employees
                                   where b.Status == 1 && b.DepartmentID == deptID
                                   select new
                    {
                        b.EmployeeID,
                        b.EmpName
                    };
                    return(Json(employee, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception exception)
            {
                return(Json(new { success = false, message = exception.Message }, JsonRequestBehavior.AllowGet));
            }
            return(Json(null, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 4
0
 public JsonResult DeletePage(int id)
 {
     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, "Page");
             if (tblUserActionMapping.Delete)
             {
                 securityFactory = new SecurityFactorys();
                 result          = securityFactory.DeleteUiPage(id);
                 if (result.isSucess)
                 {
                     return(Json(result, JsonRequestBehavior.AllowGet));
                 }
                 return(Json(new { isSucess = false, message = "You cant delete this another one use this User Group" }, JsonRequestBehavior.AllowGet));
             }
             return(Json(new { isSucess = false, message = "You are not permitted for this action" }, JsonRequestBehavior.AllowGet));
         }
         return(Json(new { isSucess = false, message = "LogOut" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { isSucess = false, message = ex.Message }, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 5
0
 public JsonResult UserGroupSave(SEC_UserGroup userGroup)
 {
     try
     {
         Dictionary <int, CheckSessionData> dictionary = CheckSessionData.GetSessionValues();
         int userId = Convert.ToInt32(dictionary[3].Id);
         int empId  = Convert.ToInt32(dictionary[1].Id);
         if (userId != 0)
         {
             _securityFactory = new SecurityFactorys();
             if (userGroup.ID < 1)
             {
                 userGroup.CreatedBy   = empId;
                 userGroup.CreatedDate = DateTime.Now;
             }
             result = _securityFactory.SaveUserGroupWithPageMapping(userGroup);
             if (result.isSucess)
             {
                 return(Json(result));
             }
             return(Json(result));
         }
         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 JsonResult GetEvents()
        {
            Dictionary <int, CheckSessionData> dictionary = CheckSessionData.GetSessionValues();
            int employeeID  = Convert.ToInt32(dictionary[1].Id == "" ? 0 : Convert.ToInt32(dictionary[1].Id));
            int userGroupID = Convert.ToInt32(dictionary[6].Id == "" ? 0 : Convert.ToInt32(dictionary[6].Id));

            //var events = dc.Appointments.Where(x => x.Status != "O" && x.Status != "C" && x.EmployeeID == employeeID).Select(x => new { x.VisitorName, x.Purpose, x.AppointmentDate, x.AppointmentTime, x.CompanyName }).ToList();

            //(x.EmployeeID == employeeID) &&
            using (IVMS_DBEntities dc = new IVMS_DBEntities())
            {
                //var groupCode = dc.UserGroups.Where(x => x.UserGroupId == userGroupID).Select(x => x.GroupCode).FirstOrDefault();
                var groupCode = dc.SEC_UserGroup.Where(x => x.ID == userGroupID).Select(x => x.GroupCode).FirstOrDefault();
                if (groupCode == "RECEPTION" || groupCode == "ADMIN")
                {
                    var events = dc.Appointments.Where(x => (x.Status == "A" || x.Status == "N" || x.Status == "AP" || x.Status == "P" || x.Status == "I")).Select(x => new { x.AppointmentBy, x.VisitorName, x.Purpose, x.AppointmentDate, x.AppointmentTime, x.CompanyName }).ToList();
                    return(new JsonResult {
                        Data = events, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                    });
                }
                else
                {
                    var events = dc.Appointments.Where(x => (x.EmployeeID == employeeID) && (x.Status == "A" || x.Status == "N" || x.Status == "AP" || x.Status == "P" || x.Status == "I")).Select(x => new { x.AppointmentBy, x.VisitorName, x.Purpose, x.AppointmentDate, x.AppointmentTime, x.CompanyName }).ToList();
                    return(new JsonResult {
                        Data = events, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                    });
                }
            }
        }
Exemplo n.º 7
0
 public ActionResult LoadAllUserGroup()
 {
     try
     {
         Dictionary <int, CheckSessionData> dictionary = CheckSessionData.GetSessionValues();
         int userGroupId = Convert.ToInt32(dictionary[6].Id == "" ? 0 : Convert.ToInt32(dictionary[6].Id));
         if (userGroupId != 0)
         {
             _userGroupFactory = new UserGroupFactory();
             var userGroup = _userGroupFactory.GetAll().Select(x => new
             {
                 x.ID,
                 UserGroup = x.Name,
                 IsAdmin   = x.IsAdmin,
                 x.CreatedBy,
                 x.CreatedDate
             }).ToList();
             return(Json(userGroup.OrderBy(x => x.UserGroup).ToList()));
         }
         return(Json(new { success = false, message = "LogOut" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception exception)
     {
         return(Json(new { success = false, message = exception.Message }, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 8
0
        public PagePermissionVM GetCrudPermission(int userGroupID, string pageName)
        {
            try
            {
                Dictionary <int, CheckSessionData> dictionary = CheckSessionData.GetSessionValues();
                int userId = Convert.ToInt16(dictionary[3].Id);

                bool forcedLogInStatus = context.SEC_LoginStatus.Where(x => x.UserID == userId && x.ForcedLogOutStatus).FirstOrDefault() == null ? false : true;

                PagePermissionVM accountmapping = (from map in context.SEC_UserActionMapping.Where(x => (x.UserGroupID == userGroupID) && (x.IsCreate || x.IsDelete || x.IsEdit || x.IsSelect))
                                                   join uip in context.SEC_UIPage.Where(x => x.UIPageName.Trim().ToLower() == pageName.Trim().ToLower()) on map.UIPageID equals uip.ID
                                                   where map.UserGroupID == userGroupID
                                                   select new PagePermissionVM()
                {
                    ID = 3,
                    UserGroupId = map.UserGroupID,
                    Select = map.IsSelect,
                    Create = map.IsCreate,
                    Edit = map.IsEdit,
                    Delete = map.IsDelete,
                    ForcedLogOut = forcedLogInStatus
                }).FirstOrDefault();
                return(accountmapping);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 9
0
        public JsonResult LoadUserGroupForEdit(int id)
        {
            try
            {
                Dictionary <int, CheckSessionData> dictionary = CheckSessionData.GetSessionValues();
                int companyId = Convert.ToInt32(dictionary[1].Id);
                if (companyId != 0)
                {
                    _userGroupFactory = new UserGroupFactory();
                    var userGroup = _userGroupFactory.GetAll()
                                    .Select(a => new
                    {
                        a.ID,
                        a.Name
                    }).FirstOrDefault();

                    return(Json(new { success = true, data = userGroup }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception exception)
            {
                return(Json(new { success = false, message = exception.Message }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { success = false, message = "Error Ocured" }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 10
0
 public JsonResult Delete(int id)
 {
     try
     {
         Dictionary <int, CheckSessionData> dictionary = CheckSessionData.GetSessionValues();
         int companyId = Convert.ToInt32(dictionary[1].Id == "" ? 0 : Convert.ToInt32(dictionary[1].Id));
         if (companyId != 0)
         {
             int userGroupId = Convert.ToInt32(dictionary[6].Id == "" ? 0 : Convert.ToInt32(dictionary[6].Id));
             ISecurityFactory _securityLogInFactory = new SecurityFactorys();
             PagePermissionVM tblUserActionMapping  = _securityLogInFactory.GetCrudPermission(userGroupId, "User");
             if (tblUserActionMapping.Delete)
             {
                 _userFactory = new UserFactory();
                 _userFactory.Delete(x => x.ID == id);
                 _userFactory.Save();
                 return(Json(new { success = true, message = "Deleted Successfuly" }, JsonRequestBehavior.AllowGet));
             }
             return(Json(new { success = false, message = "You has no delete permission" }, JsonRequestBehavior.AllowGet));
         }
         return(Json(new { success = false, message = "LogOut" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { success = false, message = "Another page use this User data" }, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 11
0
        public JsonResult GetSiteMenu()
        {
            Dictionary <int, CheckSessionData> dictionary = CheckSessionData.GetSessionValues();
            int _userGroupID = Convert.ToInt32(dictionary[6].Id == "" ? 0 : Convert.ToInt32(dictionary[6].Id));
            ISecurityFactory _securityLogInFactory = new SecurityFactorys();
            var _menu = _securityLogInFactory.PagePermissedList(_userGroupID);

            return(Json(new { menu = _menu, userGroupID = _userGroupID }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 12
0
        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);
        }
Exemplo n.º 13
0
 public ActionResult GetPage()
 {
     try
     {
         Dictionary <int, CheckSessionData> dictionary = CheckSessionData.GetSessionValues();
         int companyId = Convert.ToInt32(dictionary[1].Id == "" ? 0 : Convert.ToInt32(dictionary[1].Id));
         _securityFactory = new SecurityFactorys();
         //var menu = _securityFactory.GetPageList(Convert.ToInt32(companyId)); //Page are Common For all the Application
         var menu = _securityFactory.GetPageList();
         return(Json(new { data = menu }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception)
     {
         return(Json(new { success = false, message = "Error occured" }, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 14
0
 public List <SEC_UserInformation> LoadAllUserName()
 {
     try
     {
         Dictionary <int, CheckSessionData> dictionary = CheckSessionData.GetSessionValues();
         int userGroupId = Convert.ToInt32(dictionary[6].Id == "" ? 0 : Convert.ToInt32(dictionary[6].Id));
         _userFactory = new UserFactory();
         var list = new List <SEC_UserInformation>();
         list = _userFactory.FindBy(x => x.IsActive == true && x.UserGroupID == userGroupId).ToList();
         return(list);
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Exemplo n.º 15
0
        public ActionResult CreateCompanyBranch()
        {
            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, "CompanyBranch");
                if (tblUserActionMapping.Create)
                {
                    DefaultLoad();
                    return(View());
                }
            }
            Session["logInSession"] = null;
            return(Redirect("/#!/"));
        }
Exemplo n.º 16
0
 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));
     }
 }
Exemplo n.º 17
0
        public ActionResult PasswordChangeByAdmin()
        {
            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, "ChangePasswordByAdmin");
                if (tblUserActionMapping.Select)
                {
                    ViewBag.CallingForm     = "Security";
                    ViewBag.CallingForm1    = "Reset Password";
                    ViewBag.CallingViewPage = "#";
                    return(View());
                }
            }
            return(Redirect("/Login"));
        }
Exemplo n.º 18
0
 public JsonResult LoadMappingDataForEdit(int id)
 {
     try
     {
         Dictionary <int, CheckSessionData> dictionary = CheckSessionData.GetSessionValues();
         int userId = Convert.ToInt32(dictionary[3].Id);
         if (userId != 0)
         {
             _securityFactory = new SecurityFactorys();
             var userPagemapping = _securityFactory.GetEditPageList(id);
             return(Json(userPagemapping));
         }
         return(Json(new { success = false, message = "LogOut" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception exception)
     {
         return(Json(new { success = false, message = exception.Message }, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 19
0
        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);
        }
Exemplo n.º 20
0
        public JsonResult CreateUserSave(UserModel user)
        {
            JsonResult jsonResult = new JsonResult();

            try
            {
                Dictionary <int, CheckSessionData> dictionary = CheckSessionData.GetSessionValues();
                int userId = Convert.ToInt32(dictionary[3].Id == "" ? 0 : Convert.ToInt32(dictionary[3].Id));
                if (userId != 0)
                {
                    _userFactory     = new UserFactory();
                    _employeeFactory = new EmployeeFactory();

                    SEC_UserInformation isDuplicate = _userFactory.FindBy(x => x.UserName.ToLower().Trim() == user.UserName.ToLower().Trim()).FirstOrDefault();
                    if (isDuplicate == null)
                    {
                        var emp = _employeeFactory.FindBy(x => x.EmpCode == user.UserName).FirstOrDefault();
                        if (emp != null)
                        {
                            user.EmployeeID       = emp.EmployeeID;
                            user.CompanyID        = emp.CompanyID;
                            user.BranchID         = emp.BranchID;
                            user.SecurityQuestion = "0";
                            user.SecurityQueAns   = "BD";
                        }
                        else
                        {
                            return(Json(new { success = false, message = "Your enter employee code is not registered in the employee registration section" }, JsonRequestBehavior.AllowGet));
                        }

                        jsonResult = CreateUser(user, userId);
                        return(Json(jsonResult));
                    }
                    return(Json(new { success = false, message = "Your entered user name are duplicated please chose another name" }, 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));
            }
        }
Exemplo n.º 21
0
        public JsonResult SaveCompanyBranch(SET_CompanyBranch companyBranch)
        {
            result = new Result();
            companyBranchFactory = new CompanyBranchFactorys();
            Dictionary <int, CheckSessionData> dictionary = CheckSessionData.GetSessionValues();
            int empId = Convert.ToInt32(dictionary[1].Id);

            if (companyBranch.BranchID > 0)
            {
                companyBranch.UpdatedBy   = empId;
                companyBranch.UpdatedDate = DateTime.Now;
            }
            else
            {
                companyBranch.CreatedBy   = empId;
                companyBranch.CreatedDate = DateTime.Now;
            }
            result = companyBranchFactory.SaveCompanyBranch(companyBranch);
            return(Json(result));
        }
Exemplo n.º 22
0
        public ActionResult CompanyBranchList()
        {
            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, "CompanyBranch");
                if (tblUserActionMapping.Select)
                {
                    ViewBag.CallingForm     = "VMS";
                    ViewBag.CallingForm1    = "Branch";
                    ViewBag.CallingViewPage = "#";
                    return(View());
                }
            }
            Session["logInSession"] = null;
            return(Redirect("/#!/"));
        }
Exemplo n.º 23
0
 public JsonResult GetModuleData(int?moduleID)
 {
     try
     {
         Dictionary <int, CheckSessionData> dictionary = CheckSessionData.GetSessionValues();
         int userGroupId = Convert.ToInt32(dictionary[6].Id == "" ? 0 : Convert.ToInt32(dictionary[6].Id));
         if (userGroupId > 0)
         {
             securityFactory = new SecurityFactorys();
             List <SEC_UIModule> list = securityFactory.SearchUiModule(moduleID);
             var pageList             = list.Select(x => new { x.ID, x.Name });
             return(Json(pageList, JsonRequestBehavior.AllowGet));
         }
         return(Json(new { success = false, message = "LogOut" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception exception)
     {
         return(Json(new { success = false, message = exception.Message }, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 24
0
        public JsonResult DeptWiseEmployee(int deptID)
        {
            Dictionary <int, CheckSessionData> dictionary = CheckSessionData.GetSessionValues();
            int companyID = Convert.ToInt32(dictionary[9].Id == "" ? 0 : Convert.ToInt32(dictionary[9].Id));
            int branchID  = Convert.ToInt32(dictionary[10].Id == "" ? 0 : Convert.ToInt32(dictionary[10].Id));

            try
            {
                var employee = from b in db.Employees
                               where b.CompanyID == companyID && b.BranchID == branchID && b.Status == 1 && b.DepartmentID == deptID
                               select new
                {
                    b.EmployeeID,
                    b.EmpName
                };
                return(Json(employee, JsonRequestBehavior.AllowGet));
            }
            catch (Exception exception)
            {
                return(Json(new { success = false, message = exception.Message }, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 25
0
 public JsonResult LoadUserGroups()
 {
     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();
             var userGroups = _userGroupFactory.GetAll().Select(x => new
             {
                 id    = x.Name,
                 Group = x.Name
             }).ToList();
             return(Json(new { success = true, data = userGroups.OrderBy(x => x.Group) }, JsonRequestBehavior.AllowGet));
         }
         return(Json(new { success = false, message = "LogOut" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception exception)
     {
         return(Json(new { success = false, message = exception.Message }, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 26
0
 public ActionResult LoadAllUser()
 {
     try
     {
         Dictionary <int, CheckSessionData> dictionary = CheckSessionData.GetSessionValues();
         int userGroupId = Convert.ToInt32(dictionary[6].Id == "" ? 0 : Convert.ToInt32(dictionary[6].Id));
         if (userGroupId != 0)
         {
             _userFactory = new UserFactory();
             var users = _userFactory.GetAll().Select(x => new
             {
                 x.ID,
                 x.UserFullName,
                 x.Address,
                 x.PhoneNo,
                 //Group = x.SEC_UserGroup.FirstOrDefault().Name,
                 Group = x.SEC_UserGroup.Name,
                 User  = x.UserName,
                 x.IsActive,
                 x.UserGroupID,
                 x.Email,
                 x.UserName,
                 x.EmployeeID,
                 x.CompanyID,
                 x.BranchID,
                 x.Employee.EmpName,
                 x.Employee.DepartmentID
             }).ToList();
             return(Json(users.OrderBy(x => x.UserFullName)));
         }
         return(Json(new { success = false, message = "LogOut" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception exception)
     {
         return(Json(new { success = false, message = exception.Message }, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 27
0
 public JsonResult EditUserGroupSave(SEC_UserGroup userGroup, List <MenuItemVM> userMappingVm = null)
 {
     try
     {
         _securityFactory = new SecurityFactorys();
         Dictionary <int, CheckSessionData> dictionary = CheckSessionData.GetSessionValues();
         int userId = Convert.ToInt32(dictionary[3].Id);
         if (userId != 0)
         {
             result = _securityFactory.EditUserGroupPagePermission(userGroup, userMappingVm);
             if (result.isSucess)
             {
                 return(Json(result, JsonRequestBehavior.AllowGet));
             }
             return(Json(result, 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));
     }
 }
Exemplo n.º 28
0
        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("/#!/"));
            }
        }
Exemplo n.º 29
0
 public JsonResult PageSave(SEC_UIPage page)
 {
     try
     {
         Dictionary <int, CheckSessionData> dictionary = CheckSessionData.GetSessionValues();
         int userId = Convert.ToInt32(dictionary[3].Id);
         if (userId != 0)
         {
             securityFactory = new SecurityFactorys();
             result          = securityFactory.UiPageSave(page);
             if (result.isSucess)
             {
                 return(Json(result));
             }
             return(Json(result));
         }
         Session["logInSession"] = null;
         return(Json(result));
     }
     catch (Exception exception)
     {
         return(Json(new { isSucess = false, message = exception.Message }, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 30
0
        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);
        }