Esempio n. 1
0
        public bool Insert(SecurityRoleApplication pSecurityRoleApplication)
        {
            try
            {
                rep.Add(pSecurityRoleApplication);
                rep.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
 public bool Edit(SecurityRoleApplication pSecurityRoleApplication)
 {
     try
     {
         if (pSecurityRoleApplication.ID > 0)
         {
             SecurityRoleApplication vSecurityRoleApplication = rep.Find(pSecurityRoleApplication.ID);
             if (vSecurityRoleApplication != null)
             {
                 rep.Edit(vSecurityRoleApplication);
                 rep.SaveChanges();
                 return(true);
             }
         }
         return(false);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 3
0
        public List <SecurityRoleApplication> GetByRole(SecurityRole pRole)
        {
            List <SecurityRoleApplication>    vList = new List <SecurityRoleApplication>();
            IRepository <SecurityApplication> repSA = new Repository <SecurityApplication>(ctx);

            try
            {
                var query = from app in ctx.SecurityApplications
                            join roleApp in ctx.SecurityRoleApplications.Where(o => o.RoleCode == pRole.RoleCode) on
                            app.ApplicationCode equals roleApp.ApplicationCode into Details
                            from rapp in Details.DefaultIfEmpty()
                            select new { app, rapp };

                foreach (var eachItem in query)
                {
                    if (eachItem.rapp == null)
                    {
                        SecurityRoleApplication oNew = new SecurityRoleApplication();
                        oNew.ApplicationCode = eachItem.app.ApplicationCode;
                        oNew.RoleCode        = pRole.RoleCode;
                        oNew.AllowFlag       = "N";
                        oNew.ApplicationName = eachItem.app.ApplicationName;
                        vList.Add(oNew);
                    }
                    else
                    {
                        eachItem.rapp.ApplicationName = eachItem.app.ApplicationName;
                        vList.Add(eachItem.rapp);
                    }
                }
                return(vList);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }