Пример #1
0
        public bool DeleteAccessLevelType(int accessLevelTypeID)
        {
            using (var dbTransaction = unitOfWork.dbContext.Database.BeginTransaction())
            {
                try
                {
                    tblAccessLevelType accessLevelType = unitOfWork.TblAccessLevelTypeRepository.GetByID(accessLevelTypeID);
                    unitOfWork.TblAccessLevelTypeRepository.Delete(accessLevelType);
                    unitOfWork.Save();

                    //Complete the Transaction
                    dbTransaction.Commit();
                    return(true);
                }
                catch (Exception ex)
                {
                    //Roll back the Transaction
                    dbTransaction.Rollback();
                    return(false);
                }
            }
        }
Пример #2
0
        public bool SaveAccessLevelType(AccessLevelTypeVM accessLevelTypeVM)
        {
            using (var dbTransaction = unitOfWork.dbContext.Database.BeginTransaction())
            {
                try
                {
                    tblAccessLevelType accessLevelType = new tblAccessLevelType();
                    accessLevelType.AccessLevelTypeName = accessLevelType.AccessLevelTypeName;
                    accessLevelType.Description         = accessLevelType.Description;
                    unitOfWork.TblAccessLevelTypeRepository.Insert(accessLevelType);
                    unitOfWork.Save();

                    //Complete the Transaction
                    dbTransaction.Commit();
                    return(true);
                }
                catch (Exception ex)
                {
                    //Roll back the Transaction
                    dbTransaction.Rollback();
                    return(false);
                }
            }
        }
Пример #3
0
        public RoleVM GetFunctionAccessDetailsByID(int accessLevelTypeID)
        {
            try
            {
                tblAccessLevelType       accessLevelType            = unitOfWork.TblAccessLevelTypeRepository.GetByID(accessLevelTypeID);
                List <tblFunction>       functionList               = unitOfWork.TblFunctionRepository.Get().ToList();
                List <tblFunctionAccess> existingFunctionAccessList = unitOfWork.TblFunctionAccessRepository.Get(x => x.AccessLevelTypeID == accessLevelTypeID).ToList();

                RoleVM roleVM = new RoleVM();
                roleVM.AccessLevelTypeID   = accessLevelType.AccessLevelTypeID;
                roleVM.AccessLevelTypeName = accessLevelType.AccessLevelTypeName;

                //Master Function Details
                List <FunctionVM>  masterFunctionVMList = new List <FunctionVM>();
                List <tblFunction> masterFunctionList   = functionList.Where(x => x.tblFunctionType.FunctionTypeName == "Master").ToList();

                foreach (var masterFunction in masterFunctionList)
                {
                    FunctionVM masterFunctionVM = new FunctionVM();
                    masterFunctionVM.FunctionID     = masterFunction.FunctionID;
                    masterFunctionVM.FunctionNumber = masterFunction.FunctionNumber;
                    masterFunctionVM.FunctionName   = masterFunction.FunctionName;

                    if (existingFunctionAccessList.Any(x => x.FunctionID == masterFunction.FunctionID))
                    {
                        masterFunctionVM.IsChecked = true;
                    }
                    else
                    {
                        masterFunctionVM.IsChecked = false;
                    }

                    masterFunctionVMList.Add(masterFunctionVM);
                }

                roleVM.MasterFunctionDetails = masterFunctionVMList;

                //Transaction Function Details
                List <FunctionVM>  transactionFunctionVMList = new List <FunctionVM>();
                List <tblFunction> transactionFunctionList   = functionList.Where(x => x.tblFunctionType.FunctionTypeName == "Transaction").ToList();

                foreach (var transactionFunction in transactionFunctionList)
                {
                    FunctionVM transactionFunctionVM = new FunctionVM();
                    transactionFunctionVM.FunctionID     = transactionFunction.FunctionID;
                    transactionFunctionVM.FunctionNumber = transactionFunction.FunctionNumber;
                    transactionFunctionVM.FunctionName   = transactionFunction.FunctionName;

                    if (existingFunctionAccessList.Any(x => x.FunctionID == transactionFunction.FunctionID))
                    {
                        transactionFunctionVM.IsChecked = true;
                    }
                    else
                    {
                        transactionFunctionVM.IsChecked = false;
                    }

                    transactionFunctionVMList.Add(transactionFunctionVM);
                }

                roleVM.TransactionFunctionDetails = transactionFunctionVMList;

                //Enquiry Function Details
                List <FunctionVM>  enquiryFunctionVMList = new List <FunctionVM>();
                List <tblFunction> enquiryFunctionList   = functionList.Where(x => x.tblFunctionType.FunctionTypeName == "Enquiries").ToList();

                foreach (var enquiryFunction in enquiryFunctionList)
                {
                    FunctionVM enquiryFunctionVM = new FunctionVM();
                    enquiryFunctionVM.FunctionID     = enquiryFunction.FunctionID;
                    enquiryFunctionVM.FunctionNumber = enquiryFunction.FunctionNumber;
                    enquiryFunctionVM.FunctionName   = enquiryFunction.FunctionName;

                    if (existingFunctionAccessList.Any(x => x.FunctionID == enquiryFunction.FunctionID))
                    {
                        enquiryFunctionVM.IsChecked = true;
                    }
                    else
                    {
                        enquiryFunctionVM.IsChecked = false;
                    }

                    enquiryFunctionVMList.Add(enquiryFunctionVM);
                }

                roleVM.EnquiryFunctionDetails = enquiryFunctionVMList;

                //Report Function Details
                List <FunctionVM>  reportFunctionVMList = new List <FunctionVM>();
                List <tblFunction> reportFunctionList   = functionList.Where(x => x.tblFunctionType.FunctionTypeName == "Reports").ToList();

                foreach (var reportFunction in reportFunctionList)
                {
                    FunctionVM reportFunctionVM = new FunctionVM();
                    reportFunctionVM.FunctionID     = reportFunction.FunctionID;
                    reportFunctionVM.FunctionNumber = reportFunction.FunctionNumber;
                    reportFunctionVM.FunctionName   = reportFunction.FunctionName;

                    if (existingFunctionAccessList.Any(x => x.FunctionID == reportFunction.FunctionID))
                    {
                        reportFunctionVM.IsChecked = true;
                    }
                    else
                    {
                        reportFunctionVM.IsChecked = false;
                    }

                    reportFunctionVMList.Add(reportFunctionVM);
                }

                roleVM.ReportFunctionDetails = reportFunctionVMList;

                //Admin Function Details
                List <FunctionVM>  adminFunctionVMList = new List <FunctionVM>();
                List <tblFunction> adminFunctionList   = functionList.Where(x => x.tblFunctionType.FunctionTypeName == "Administration").ToList();

                foreach (var adminFunction in adminFunctionList)
                {
                    FunctionVM adminFunctionVM = new FunctionVM();
                    adminFunctionVM.FunctionID     = adminFunction.FunctionID;
                    adminFunctionVM.FunctionNumber = adminFunction.FunctionNumber;
                    adminFunctionVM.FunctionName   = adminFunction.FunctionName;

                    if (existingFunctionAccessList.Any(x => x.FunctionID == adminFunction.FunctionID))
                    {
                        adminFunctionVM.IsChecked = true;
                    }
                    else
                    {
                        adminFunctionVM.IsChecked = false;
                    }

                    adminFunctionVMList.Add(adminFunctionVM);
                }

                roleVM.AdminFunctionDetails = adminFunctionVMList;

                return(roleVM);
            }
            catch (Exception ex)
            {
                throw;
            }
        }