Example #1
0
        public bool UpdatePermission(Guid roleId, string resourceIds)
        {
            try
            {
                using (IDbContextBase context = DbContextFactory.GetDbContext())
                {
                    string[]   arrResourceId = resourceIds.Split(',');
                    Permission permission    = null;

                    context.Delete <Permission>(obj => obj.RoleId == roleId, false);

                    for (int i = 0; i < arrResourceId.Length; i++)
                    {
                        permission            = new Permission();
                        permission.Id         = Guid.NewGuid();
                        permission.RoleId     = roleId;
                        permission.ResourceId = arrResourceId[i];

                        context.Insert <Permission>(permission, false);
                    }

                    return(context.SaveChanges());
                }
            }
            catch
            {
                throw;
            }
        }
Example #2
0
 public bool InsertData <T>(T t) where T : class, new()
 {
     using (IDbContextBase context = DbContextFactory.GetDbContext())
     {
         return(context.Insert <T>(t));
     }
 }
Example #3
0
        public bool AddUserRole(string userIds, string roleIds)
        {
            try
            {
                using (IDbContextBase context = DbContextFactory.GetDbContext())
                {
                    string[] arrUserId = userIds.Split(',');
                    string[] arrRoleId = roleIds.Split(',');

                    User_Role userRole = null;
                    for (int i = 0; i < arrUserId.Length; i++)
                    {
                        for (int j = 0; j < arrRoleId.Length; j++)
                        {
                            userRole        = new User_Role();
                            userRole.Id     = Guid.NewGuid();
                            userRole.RoleId = new Guid(arrRoleId[j]);
                            userRole.UserId = new Guid(arrUserId[i]);

                            context.Insert <User_Role>(userRole, false);
                        }
                    }

                    return(context.SaveChanges());
                }
            }
            catch
            {
                throw;
            }
        }
Example #4
0
 public bool InsertCity(City city)
 {
     try
     {
         using (IDbContextBase context = DbContextFactory.GetDbContext())
         {
             city.Id = Guid.NewGuid();
             return(context.Insert <City>(city));
         }
     }
     catch
     {
         throw;
     }
 }
Example #5
0
 public bool InsertRole(Role role)
 {
     try
     {
         using (IDbContextBase context = DbContextFactory.GetDbContext())
         {
             role.Id = Guid.NewGuid();
             return(context.Insert <Role>(role));
         }
     }
     catch
     {
         throw;
     }
 }
Example #6
0
 public bool InsertUser(User user)
 {
     try
     {
         using (IDbContextBase context = DbContextFactory.GetDbContext())
         {
             user.Id = Guid.NewGuid();
             return(context.Insert <User>(user));
         }
     }
     catch
     {
         throw;
     }
 }
Example #7
0
 public bool InsertDistrict(District district)
 {
     try
     {
         using (IDbContextBase context = DbContextFactory.GetDbContext())
         {
             district.Id = Guid.NewGuid();
             return(context.Insert <District>(district));
         }
     }
     catch
     {
         throw;
     }
 }
Example #8
0
 public bool InsertProperty(Property property)
 {
     try
     {
         using (IDbContextBase context = DbContextFactory.GetDbContext())
         {
             property.Id = Guid.NewGuid();
             context.Insert <Property>(property, false);
             return(context.SaveChanges());
         }
     }
     catch
     {
         throw;
     }
 }
Example #9
0
 public void WriteLog(string userName, string moduleName, string tableName, string eventType, object newValues)
 {
     using (IDbContextBase context = DbContextFactory.GetDbContext())
     {
         context.CloseLog();
         AuditLog audiLog = new AuditLog();
         audiLog.Id         = Guid.NewGuid();
         audiLog.UserName   = userName;
         audiLog.ModuleName = moduleName;
         audiLog.TableName  = tableName;
         audiLog.EventType  = eventType;
         audiLog.NewValues  = JsonConvert.SerializeObject(newValues, new JsonSerializerSettings()
         {
             ReferenceLoopHandling = ReferenceLoopHandling.Ignore
         });
         audiLog.Time = DateTime.Now;
         context.Insert(audiLog);
     }
 }