public static List<DALRoleAssignment> GetUserRoles(int userId)
        {
            var retVal = new List<DALRoleAssignment>();

            using (var context = new ISGAdminEntities())
            {
                var roleAssignments = context.RoleAssignments.Where(f => f.UserId == userId).ToList();

                if (!roleAssignments.Any())
                {
                    return retVal;
                }

                // ReSharper disable once LoopCanBeConvertedToQuery
                foreach (var ra in roleAssignments)
                {
                    retVal.Add(new DALRoleAssignment
                    {
                        InstanceId = ra.InstanceId,
                        RoleId = ra.RoleId,
                        Status = ra.Status
                    });
                }
            }
            return retVal;
        }
        public static List<DALRoleMapping> GetRoleMappings(int functionId)
        {
            var retVal = new List<DALRoleMapping>();

            using (var context = new ISGAdminEntities())
            {
                var user = context.RoleMappings.Where(f => f.FunctionId == functionId).ToList();

                if (!user.Any())
                {
                    return retVal;
                }

                // ReSharper disable once LoopCanBeConvertedToQuery
                foreach (var u in user)
                {
                    retVal.Add(new DALRoleMapping
                    {
                        InstanceId = u.InstanceId,
                        RoleId = u.RoleId,
                        FunctionId = u.FunctionId,
                        Status = u.Status
                    });
                }
            }
            return retVal;
        }
 public static List<DALExcelValidationRecord> GetAllExcelValidationRecords()
 {
     List<DALExcelValidationRecord> rtrn = null;
     using (var context = new ISGAdminEntities())
     {
         var excelValidationRecords = context.ExcelValidationRecords;
         if (excelValidationRecords.Any())
         {
             rtrn = TransformDBtoDALExcelValidationRecords(excelValidationRecords.ToList());
         }
     }
     return rtrn;
 }
 public static List<DALExcelValidationRecord> GetExcelValidationRecordsByFileName(string fileName)
 {
     List<DALExcelValidationRecord> rtrn = null;
     using (var context = new ISGAdminEntities())
     {
         var excelValidationRecords = context.ExcelValidationRecords.Where(x => string.Equals(x.FileName, fileName, StringComparison.CurrentCultureIgnoreCase));
         if (excelValidationRecords.Any())
         {
             rtrn = TransformDBtoDALExcelValidationRecords(excelValidationRecords.ToList());
         }
     }
     return rtrn;
 }
        public static List<DALYearQuarter> GetYearQuarters()
        {
            List<DALYearQuarter> rtrn = null;
            using (var context = new ISGAdminEntities())
            {
                var yearQuarters = context.YearQuaters;

                foreach (var yearQuarter in yearQuarters)
                {
                    rtrn = rtrn ?? new List<DALYearQuarter>();
                    rtrn.Add(
                        new DALYearQuarter
                            {
                                Id = yearQuarter.Id,
                                Quarter = yearQuarter.Quater,
                                LastMonth = yearQuarter.LastMonth,
                                EndDate = yearQuarter.EndDate
                            });
                }
            }
            return rtrn;
        }
 public static void AddExcelValidationRecords(List<DALExcelValidationRecord> records)
 {
     using (var context = new ISGAdminEntities())
     {
         records.ForEach(
             x => context.ExcelValidationRecords.Add(
                 new ExcelValidationRecord
                     {
                         Code = x.Code,
                         ExcelColumn = x.ExcelColumn,
                         ExcelRow = x.ExcelRow,
                         ExcelSheet = x.ExcelSheet,
                         ExcelValidationDataType = context.ExcelValidationDataTypes.FirstOrDefault(y => y.Id == (int)x.ExcelValidationDataType),
                         ExcelValidationResultType = context.ExcelValidationResultTypes.FirstOrDefault(y => y.Id == (int)x.ExcelValidationResultType),
                         MaxStringLength = x.MaxStringLength,
                         CreationDate = DateTime.Now,
                         Message = x.Message,
                         FileName = x.FileName,
                         BadValue = x.BadValue
                     }));
         context.SaveChanges();
     }
 }
예제 #7
0
        public static DALUser GetUser(string userName)
        {
            var retVal = new DALUser();

            using (var context = new ISGAdminEntities())
            {
                var user = context.Users.FirstOrDefault(f => string.Equals(f.Name, userName, StringComparison.CurrentCultureIgnoreCase));

                if (user != null)
                {
                    retVal = new DALUser
                    {
                        InstanceId = user.InstanceId,
                        Name = user.Name,
                        Password = user.Password,
                        StartDate = user.StartDate,
                        EndDate = user.EndDate,
                        Status = user.Status
                    };
                }
            }
            return retVal;
        }