/// <summary> /// Initialize DTO and save values in database /// </summary> /// <param name="pageId">Int32: page id</param> /// <param name="roleId">Int32: role id</param> /// <param name="isActive">Boolean : isactive = true for page is active</param> private void SavePagesInRoles(int pageId, int roleId, bool isActive) { PagesInRoleDTO pagesInRolesDetails = new PagesInRoleDTO(); pagesInRolesDetails.Page_Role_PageId = pageId; pagesInRolesDetails.Page_Role_IsActive = isActive; pagesInRolesDetails.Page_Role_RoleId = roleId; pagesInRolesDetails.Page_Role_CreatedBy = base.GetCurrentUserId(); pagesInRolesDetails.Page_Role_CreatedDate = DateTime.Now; ESalesUnityContainer.Container.Resolve<IMembershipService>().AddPagesToRoles(pagesInRolesDetails); }
/// <summary> /// Get Page Role Details By PageRoleId /// </summary> /// <param name="pageRoleId">Int32:pageRoleId</param> /// <returns></returns> public PagesInRoleDTO GetPageRoleDetailsByPageRoleId(int pageRoleId) { //To select agent by agent id PagesInRoleDTO pageRoleDTO = new PagesInRoleDTO(); AutoMapper.Mapper.Map(ESalesUnityContainer.Container.Resolve<IGenericRepository<pagesinrole>>() .GetSingle(item => item.Page_Role_Id == pageRoleId && item.Page_Role_IsDeleted == false), pageRoleDTO); //return agent details return pageRoleDTO; }
/// <summary> /// Add Dynamic Parent Items by pageId,roleId and isActive /// </summary> /// <param name="pageId">Int32:pageId</param> /// <param name="roleId">Int32:roleId</param> /// <param name="isActive">Bool:isActive</param> private void AddDynamicParentItems(int pageId, int roleId,bool isActive) { PageInfoDTO page = GetPageDetailsByPageId(pageId); if (page.Page_ParentPageLevelId > 0) { PagesInRoleDTO pageRoleDetails = GetPageDetailsByParentPageIdNRoleId(page.Page_ParentPageLevelId, roleId); PagesInRoleDTO parentPagesDetails = new PagesInRoleDTO(); pagesinrole parentPagesEntity = new pagesinrole(); parentPagesDetails.Page_Role_PageId = page.Page_ParentPageLevelId; parentPagesDetails.Page_Role_IsActive = isActive; parentPagesDetails.Page_Role_RoleId = roleId; parentPagesDetails.Page_Role_CreatedDate = DateTime.Now; AutoMapper.Mapper.Map(parentPagesDetails, parentPagesEntity); if (pageRoleDetails.Page_Role_PageId == 0) { ESalesUnityContainer.Container.Resolve<IGenericRepository<pagesinrole>>().Save(parentPagesEntity); } AddDynamicParentItems(page.Page_ParentPageLevelId, roleId,page.Page_IsActive); UpdateDynamicParentItemsStatus(pageId, roleId, isActive); } }
/// <summary> /// verify If Page Exists InRole or not by PageId and RoleId /// </summary> /// <param name="pageId">Int32:pageId</param> /// <param name="roleId">int32:roleId</param> /// <returns></returns> public bool CheckIfPageExistsInRole(int pageId, int roleId) { bool isPageExists = false; PagesInRoleDTO pagesInRoles = new PagesInRoleDTO(); AutoMapper.Mapper.Map(ESalesUnityContainer.Container.Resolve<IGenericRepository<pagesinrole>>() .GetSingle(item => item.Page_Role_PageId == pageId && item.Page_Role_RoleId == roleId && item.Page_Role_IsDeleted == false && item.pageinfo.Page_IsActive == true), pagesInRoles); //return Role Id if (pagesInRoles.Page_Role_Id > 0) { isPageExists = true; } //return the value return isPageExists; }
/// <summary> /// Add Pages To Roles /// </summary> /// <param name="pagesInRolesDetails"></param> public void AddPagesToRoles(PagesInRoleDTO pagesInRolesDetails) { using (TransactionScope transactionScope = new TransactionScope()) { pagesinrole pagesInRoleEntity = new pagesinrole(); AutoMapper.Mapper.Map(pagesInRolesDetails, pagesInRoleEntity); ESalesUnityContainer.Container.Resolve<IGenericRepository<pagesinrole>>().Save(pagesInRoleEntity); AddDynamicParentItems(pagesInRolesDetails.Page_Role_PageId, pagesInRolesDetails.Page_Role_RoleId, pagesInRolesDetails.Page_Role_IsActive); transactionScope.Complete(); } }