Пример #1
0
        public ActionResult Edit([Bind(Include = "Id,RoleId,RoleIdText,MenuInfoId,MenuInfoIdText,CanView,CanCreate,CanEdit,CanDelete,Active")] RoleMenuMapping roleMenuMapping)
        {
            if (ModelState.IsValid)
            {
                // Saving Longing Credential
                LoginInfoModel logingInfoModel = new LoginInfoModel();
                PopulateLoginInfoCredencial populateLoginInfoCredencial = new PopulateLoginInfoCredencial(logingInfoModel);
                logingInfoModel = populateLoginInfoCredencial.getLoginInfoCredencial();
                if (!populateLoginInfoCredencial.ValidateIPv4(logingInfoModel.LoginIp))
                {
                    return(RedirectToAction("Login", "Account"));
                }
                logingInfoModel.UsedModel    = "RoleMenuMapping";
                logingInfoModel.TypeOfAction = TypeOfAction.Update;
                logingInfoModel.Data         = Newtonsoft.Json.JsonConvert.SerializeObject(roleMenuMapping);
                logingInfoModel.SysDate      = DateTime.Now;
                db.LoginInfoModels.Add(logingInfoModel);
                db.SaveChanges();
                // Saving Longing Credential

                db.Entry(roleMenuMapping).State = EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            return(View(roleMenuMapping));
        }
Пример #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            RoleMenuMapping roleMenuMapping = db.RoleMenuMappings.Find(id);

            // Saving Longing Credential
            LoginInfoModel logingInfoModel = new LoginInfoModel();
            PopulateLoginInfoCredencial populateLoginInfoCredencial = new PopulateLoginInfoCredencial(logingInfoModel);

            logingInfoModel = populateLoginInfoCredencial.getLoginInfoCredencial();
            if (!populateLoginInfoCredencial.ValidateIPv4(logingInfoModel.LoginIp))
            {
                return(RedirectToAction("Login", "Account"));
            }
            logingInfoModel.UsedModel    = "RoleMenuMapping";
            logingInfoModel.TypeOfAction = TypeOfAction.Delete;
            logingInfoModel.Data         = Newtonsoft.Json.JsonConvert.SerializeObject(roleMenuMapping);
            logingInfoModel.SysDate      = DateTime.Now;
            db.LoginInfoModels.Add(logingInfoModel);
            db.SaveChanges();
            // Saving Longing Credential


            db.RoleMenuMappings.Remove(roleMenuMapping);
            db.SaveChanges();



            return(RedirectToAction("Index"));
        }
        public JsonResult Add(RoleMenuMappingViewModels model)
        {
            var rmm = new RoleMenuMapping();

            rmm.RoleId   = model.RoleId;
            rmm.MenuId   = model.MenuId;
            rmm.IsActive = true;
            db.RoleMenuMappings.Add(rmm);
            db.SaveChanges();
            return(Json(true, JsonRequestBehavior.AllowGet));
        }
        public RoleMenuMappingViewModels ConvertFromRole(RoleMenuMapping urole)
        {
            RMId   = urole.RMId;
            RoleId = urole.RoleId;
            MenuId = urole.MenuId;
            if (urole.MenuId != "")
            {
                MenuIds = null;
                MenuIds = urole.MenuId.Split(',').Select(Int32.Parse).ToArray();
            }

            return(this);
        }
Пример #5
0
        // GET: RoleMenuMappings/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RoleMenuMapping roleMenuMapping = db.RoleMenuMappings.Find(id);

            if (roleMenuMapping == null)
            {
                return(HttpNotFound());
            }
            return(View(roleMenuMapping));
        }
Пример #6
0
        public void AddUpdateRoleMenu(RoleMenuMappingListModel model, int LoggedInUserId, int LoggedInOrganizationId)
        {
            base.RepositoryContext.SP_DeleteRoleMenuMapping(model.RoleId);
            if (model != null && model.RoleMenuMappingViewModel != null && model.RoleMenuMappingViewModel.Any())
            {
                foreach (RoleMenuMappingViewModel viewModel in model.RoleMenuMappingViewModel)
                {
                    RoleMenuMapping menu = Mapper.Map <RoleMenuMappingViewModel, RoleMenuMapping>(viewModel);
                    Add(menu, LoggedInUserId, LoggedInOrganizationId);
                }
            }

            this._unitOfWork.Save();
        }
        public RoleMenuMappingViewModels(RoleMenuMapping urole)
        {
            if (urole.MenuId != "")
            {
                var numbers           = urole.MenuId.Split(',').Select(Int32.Parse).ToList();
                MVCProjectEntities db = new MVCProjectEntities();
                var    selected       = db.MenuMasters.Where(x => numbers.Contains(x.MenuId)).Select(x => new { x.MenuName }).ToList();
                string mstr           = "";
                foreach (var u in selected)
                {
                    mstr = mstr + "," + u.MenuName;
                }
                MenuId = mstr.Trim(',');
            }

            //var menulist = db.MenuMasters.Where(x=>x.MenuId in(urole.MenuId)).
            RMId   = urole.RMId;
            RoleId = urole.RoleId;
            //MenuId = urole.MenuId;
            RoleName = urole.UserRole.RoleName;
        }
        protected void InsertMenuMapping(object sender, EventArgs e)
        {
            List <RoleMenuMapping> lstRoleMenuMapping = new List <RoleMenuMapping>();

            foreach (RepeaterItem item in rptMenus.Items)
            {
                CheckBox chkAccountMgr = (CheckBox)item.FindControl("chkAccMgr");
                CheckBox chkAdmin      = (CheckBox)item.FindControl("ChkAdmin");
                CheckBox ChkGovern     = (CheckBox)item.FindControl("ChkGovernance");
                CheckBox ChkHeadBA     = (CheckBox)item.FindControl("ChkHeadBA");
                CheckBox ChkHeadDlvry  = (CheckBox)item.FindControl("ChkHeadDelivery");
                CheckBox ChkHR         = (CheckBox)item.FindControl("ChkHR");
                CheckBox ChkPMO        = (CheckBox)item.FindControl("ChkPMO");
                CheckBox ChkPM         = (CheckBox)item.FindControl("ChkPM");
                CheckBox ChkRequestor  = (CheckBox)item.FindControl("ChkRequestor");
                CheckBox ChkSolHead    = (CheckBox)item.FindControl("ChkSolHead");

                if (chkAccountMgr.Checked)
                {
                    RoleMenuMapping details = new RoleMenuMapping();
                    details.MenuID = Convert.ToInt32(chkAccountMgr.Attributes["MenuID"]);
                    details.RoleID = Convert.ToInt32(chkAccountMgr.Attributes["RoleID"]);
                    lstRoleMenuMapping.Add(details);
                }
                if (chkAdmin.Checked)
                {
                    RoleMenuMapping details = new RoleMenuMapping();
                    details.MenuID = Convert.ToInt32(chkAdmin.Attributes["MenuID"]);
                    details.RoleID = Convert.ToInt32(chkAdmin.Attributes["RoleID"]);
                    lstRoleMenuMapping.Add(details);
                }
                if (ChkGovern.Checked)
                {
                    RoleMenuMapping details = new RoleMenuMapping();
                    details.MenuID = Convert.ToInt32(ChkGovern.Attributes["MenuID"]);
                    details.RoleID = Convert.ToInt32(ChkGovern.Attributes["RoleID"]);
                    lstRoleMenuMapping.Add(details);
                }
                if (ChkHeadBA.Checked)
                {
                    RoleMenuMapping details = new RoleMenuMapping();
                    details.MenuID = Convert.ToInt32(ChkHeadBA.Attributes["MenuID"]);
                    details.RoleID = Convert.ToInt32(ChkHeadBA.Attributes["RoleID"]);
                    lstRoleMenuMapping.Add(details);
                }
                if (ChkHeadDlvry.Checked)
                {
                    RoleMenuMapping details = new RoleMenuMapping();
                    details.MenuID = Convert.ToInt32(ChkHeadDlvry.Attributes["MenuID"]);
                    details.RoleID = Convert.ToInt32(ChkHeadDlvry.Attributes["RoleID"]);
                    lstRoleMenuMapping.Add(details);
                }
                if (ChkHR.Checked)
                {
                    RoleMenuMapping details = new RoleMenuMapping();
                    details.MenuID = Convert.ToInt32(ChkHR.Attributes["MenuID"]);
                    details.RoleID = Convert.ToInt32(ChkHR.Attributes["RoleID"]);
                    lstRoleMenuMapping.Add(details);
                }
                if (ChkPMO.Checked)
                {
                    RoleMenuMapping details = new RoleMenuMapping();
                    details.MenuID = Convert.ToInt32(ChkPMO.Attributes["MenuID"]);
                    details.RoleID = Convert.ToInt32(ChkPMO.Attributes["RoleID"]);
                    lstRoleMenuMapping.Add(details);
                }
                if (ChkPM.Checked)
                {
                    RoleMenuMapping details = new RoleMenuMapping();
                    details.MenuID = Convert.ToInt32(ChkPM.Attributes["MenuID"]);
                    details.RoleID = Convert.ToInt32(ChkPM.Attributes["RoleID"]);
                    lstRoleMenuMapping.Add(details);
                }
                if (ChkRequestor.Checked)
                {
                    RoleMenuMapping details = new RoleMenuMapping();
                    details.MenuID = Convert.ToInt32(ChkRequestor.Attributes["MenuID"]);
                    details.RoleID = Convert.ToInt32(ChkRequestor.Attributes["RoleID"]);
                    lstRoleMenuMapping.Add(details);
                }
                if (ChkSolHead.Checked)
                {
                    RoleMenuMapping details = new RoleMenuMapping();
                    details.MenuID = Convert.ToInt32(ChkSolHead.Attributes["MenuID"]);
                    details.RoleID = Convert.ToInt32(ChkSolHead.Attributes["RoleID"]);
                    lstRoleMenuMapping.Add(details);
                }
            }

            if (lstRoleMenuMapping.Count() > 0)
            {
                ManageMenusBL.InsertRoleMapping(lstRoleMenuMapping);
            }
        }
Пример #9
0
        public ActionResult Create(List <MenuInfo> menuList, string RoleName)
        {
            var roleToDel = 0;

            List <RoleMenuMapping> roleMenuMappings = db.RoleMenuMappings.Where(drm => drm.RoleIdText == RoleName).ToList();

            if (roleMenuMappings != null && roleMenuMappings.Count() > 0)
            {
                roleToDel = roleMenuMappings[0].RoleId;
            }

            foreach (var item in roleMenuMappings)
            {
                db.RoleMenuMappings.Remove(item);
                db.SaveChanges();
            }

            RoleMenuMapping roleMenuMapping = new  RoleMenuMapping();
            var             RoleList        = db.RoleMasters.ToList();
            var             AllMenu         = db.MenuInfoes.ToList();

            if (ModelState.IsValid)
            {
                foreach (var item in menuList)
                {
                    var MenoInfoIdText = AllMenu.Where(am => am.Id == item.Id).Select(s => s.MenuParentIDText).FirstOrDefault();
                    if (MenoInfoIdText == null || MenoInfoIdText == "")
                    {
                        MenoInfoIdText = AllMenu.Where(am => am.Id == item.Id).Select(s => s.MenuName).FirstOrDefault();
                    }
                    var RoleId = RoleList.Where(rl => rl.Name == RoleName).Select(r => r.Id).FirstOrDefault();
                    roleMenuMapping.MenuInfoId     = item.Id;
                    roleMenuMapping.MenuInfoIdText = MenoInfoIdText;
                    roleMenuMapping.CanView        = Convert.ToBoolean(item.CanView);
                    roleMenuMapping.CanCreate      = Convert.ToBoolean(item.CanCreate);
                    roleMenuMapping.CanEdit        = Convert.ToBoolean(item.CanEdit);
                    roleMenuMapping.CanDelete      = Convert.ToBoolean(item.CanDelete);
                    roleMenuMapping.CanClose       = Convert.ToBoolean(item.CanClose);
                    roleMenuMapping.Active         = item.Active;
                    roleMenuMapping.RoleId         = RoleId == 0 ? roleToDel : RoleId;
                    roleMenuMapping.RoleIdText     = RoleName;
                    db.RoleMenuMappings.Add(roleMenuMapping);


                    // Saving Longing Credential
                    LoginInfoModel logingInfoModel = new LoginInfoModel();
                    PopulateLoginInfoCredencial populateLoginInfoCredencial = new PopulateLoginInfoCredencial(logingInfoModel);
                    logingInfoModel = populateLoginInfoCredencial.getLoginInfoCredencial();
                    if (!populateLoginInfoCredencial.ValidateIPv4(logingInfoModel.LoginIp))
                    {
                        return(RedirectToAction("Login", "Account"));
                    }
                    logingInfoModel.UsedModel    = "RoleMenuMapping";
                    logingInfoModel.TypeOfAction = TypeOfAction.Insert;
                    logingInfoModel.Data         = Newtonsoft.Json.JsonConvert.SerializeObject(roleMenuMapping);
                    logingInfoModel.SysDate      = DateTime.Now;
                    db.LoginInfoModels.Add(logingInfoModel);
                    db.SaveChanges();
                    // Saving Longing Credential


                    db.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }

            return(View(roleMenuMapping));
        }