public Rental RentCarToCustomer(string loginEmail, int carId, DateTime rentalDate, DateTime dateDueBack) { if (rentalDate > DateTime.Now) { throw new UnableToRentForDateException(string.Format("Cannot rent for date {0} yet.", rentalDate.ToShortDateString())); } IAccountRepository accountRepository = _DataRepositoryFactory.GetDataRepository <IAccountRepository>(); IRentalRepository rentalRepository = _DataRepositoryFactory.GetDataRepository <IRentalRepository>(); bool carIsRented = IsCarCurrentlyRented(carId); if (carIsRented) { throw new CarCurrentlyRentedException(string.Format("Car {0} is already rented.", carId)); } Account account = accountRepository.GetByLogin(loginEmail); if (account == null) { throw new NotFoundException(string.Format("No account found for login '{0}'.", loginEmail)); } Rental rental = new Rental() { AccountId = account.AccountId, CarId = carId, DateRented = rentalDate, DateDue = dateDueBack }; Rental savedEntity = rentalRepository.Add(rental); return(savedEntity); }
public IEnumerable <Rental> GetCarRentalHistory(string loginEmail) { return(HandleFaultHandledOperation(() => { IRentalRepository rentalRepository = _DataRepositoryFactory.GetDataRepository <IRentalRepository>(); IAccountRepository accountRepository = _DataRepositoryFactory.GetDataRepository <IAccountRepository>(); Account account = accountRepository.GetByLogin(loginEmail); if (account == null) { NotFoundException ex = new NotFoundException(string.Format("User with email Id {0} not found ", loginEmail)); throw new FaultException <NotFoundException>(ex, ex.Message); } ValidateAuthorization(account); IEnumerable <Rental> rentalHistory = rentalRepository.GetRentalHistoryByAccountId(account.AccountId); return rentalHistory; })); }
[PrincipalPermission(SecurityAction.Demand, Name = Security.CarRentalUser)] //Y también a los que se acrediten con este usuario de Windows public Car GetCar(int carId) { return(ExecuteFaultHandledOperation(() => { ICarRepository carRepository = _dataRepositoryFactory.GetDataRepository <ICarRepository>(); Car carEntity = carRepository.Get(carId); if (carEntity == null) { NotFoundException ex = new NotFoundException(string.Format("Car with Id {0} is not in the database", carId)); //WCF gestiona las excepciones como mensaje SOAP con FaultException: FaultContract attribute throw new FaultException <NotFoundException>(ex, ex.Message); } return carEntity; })); }
public Car GetCar(int carId) { return(ExecuteFaultHandledOperation(() => { var carRepository = _DataRepositoryFactory.GetDataRepository <ICarRepository>(); var carEntity = carRepository.Get(carId); if (carEntity == null) { var ex = new NotFoundException(string.Format("Car with ID of {0} is not in the database.", carId)); throw new FaultException <NotFoundException>(ex, ex.Message); // wcf compatible } return carEntity; })); }
public Car UpdateCar(Car car) { return(ExecuteFaultHandledOperation(() => { ICarRepository carRepository = _DataRepositoryFactory.GetDataRepository <ICarRepository>(); Car updatedEntity = null; if (car.CarId == 0) { updatedEntity = carRepository.Add(car); } else { updatedEntity = carRepository.Update(car); } return updatedEntity; })); }
public string GetDataConnection() { string connectionString = ""; if (!string.IsNullOrEmpty(DataConnector.CompanyCode)) { IDatabaseRepository databaseRepository = _DataRepositoryFactory.GetDataRepository <IDatabaseRepository>(); var companydb = databaseRepository.Get().Where(c => c.CompanyCode == DataConnector.CompanyCode).FirstOrDefault(); if (companydb == null) { throw new Exception("Unable to load company database."); } connectionString = string.Format("Data Source= {0};Initial Catalog={1};User ={2};Password={3};Integrated Security={4}", companydb.ServerName, companydb.DatabaseName, companydb.UserName, companydb.Password, companydb.IntegratedSecurity); } return(connectionString); }
void use_repository_factory_to_get_non_generic_repositories_and_create_record() { IJarsJobRepository jarsRep = _repFactory.GetDataRepository <IJarsJobRepository>(); Assert.IsNotNull(jarsRep); //Assert.IsNotNull(qlRep); //test create JarsJob jj = jarsRep.CreateUpdate(new JarsJob(), "NONGEN_FACT_TEST"); Assert.IsTrue(jj.Id > 0); //test read jj = jarsRep.GetById((long)1); Assert.IsTrue(jj.Id == 0); }
public void UpdateProduct_update_existing() { Product existingProduct = new Product() { ProductId = 1 }; Product updatedProduct = new Product() { ProductId = 1, Name = "Updated Product" }; IDataRepositoryFactory mockedRepositoryFactory = Substitute.For <IDataRepositoryFactory>(); mockedRepositoryFactory.GetDataRepository <IProductRepository>().Update(existingProduct).Returns(updatedProduct); InventoryManager manager = new InventoryManager(mockedRepositoryFactory); ProductDto results = manager.UpdateProduct(Mapper.Map <ProductDto>(existingProduct)); Assert.IsTrue(results.Name == updatedProduct.Name); }
private void InitRepositories(List <Type> entities) { _errorsRepository = _dataRepositoryFactory.GetDataRepository <Error>(RequestMessage); if (entities.Any(e => e.FullName == typeof(UserEntity).FullName)) { _userRepository = _dataRepositoryFactory.GetDataRepository <UserEntity>(RequestMessage); } if (entities.Any(e => e.FullName == typeof(Location).FullName)) { _locationRepository = _dataRepositoryFactory.GetDataRepository <Location>(RequestMessage); } if (entities.Any(e => e.FullName == typeof(Menu).FullName)) { _memuRepository = _dataRepositoryFactory.GetDataRepository <Menu>(RequestMessage); } if (entities.Any(e => e.FullName == typeof(MenuPrivilege).FullName)) { _memupriRepository = _dataRepositoryFactory.GetDataRepository <MenuPrivilege>(RequestMessage); } if (entities.Any(e => e.FullName == typeof(Privilege).FullName)) { _priRepository = _dataRepositoryFactory.GetDataRepository <Privilege>(RequestMessage); } if (entities.Any(e => e.FullName == typeof(RoleDefine).FullName)) { _roleRepository = _dataRepositoryFactory.GetDataRepository <RoleDefine>(RequestMessage); } if (entities.Any(e => e.FullName == typeof(UserRole).FullName)) { _userroleRepository = _dataRepositoryFactory.GetDataRepository <UserRole>(RequestMessage); } }
public void TestProductAddNew() { Product newProduct = new Product(); Product addedProduct = new Product() { ProductId = 1 }; ProductDto newProductDto = Mapper.Map <ProductDto>(newProduct); ProductDto addedProductDto = Mapper.Map <ProductDto>(addedProduct); IDataRepositoryFactory mockedRepositoryFactory = Substitute.For <IDataRepositoryFactory>(); mockedRepositoryFactory.GetDataRepository <IProductRepository>().Add(newProduct).Returns(addedProduct); InventoryManager manager = new InventoryManager(mockedRepositoryFactory); ProductDto results = manager.AddProduct(newProductDto); //cannot test InventoryManager with Fake Repository, because of Mapper Assert.IsTrue(results == addedProductDto); }
protected override async Task HandleRequirementAsync(AuthorizationHandlerContext context, ClientApplicationAccessRequirement requirement) { var defaultMessage = "No Autorizado"; var authHeader = _HttpContextAccessor.HttpContext.Request.Headers[HeaderNames.Authorization]; if (!string.IsNullOrEmpty(authHeader) && authHeader.ToString().StartsWith("Basic")) { string accessKey = authHeader.ToString().Substring("Basic ".Length).Trim(); _ApplicationProfile.ApplicationId = await _CacheService.GetCachedAsync(accessKey, async() => { var repo = _DataRepositoryFactory.GetDataRepository <ApplicationKey>(); var result = await repo.GetAsync(x => x.Select(r => r.ApplicationId), x => !x.IsDeleted && x.AccessKey == accessKey); return(result); }, TimeSpan.FromMinutes(5)); if (_ApplicationProfile.ApplicationId != null) { context.Succeed(requirement); return; } defaultMessage = "The provided Access Key is invalid."; } var responseModel = new ApiErrorResponseModel() { Message = defaultMessage }; var result = JsonConvert.SerializeObject(responseModel); _HttpContextAccessor.HttpContext.Response.ContentType = MediaTypeNames.Application.Json; _HttpContextAccessor.HttpContext.Response.StatusCode = (int)HttpStatusCode.Unauthorized; await _HttpContextAccessor.HttpContext.Response.WriteAsync(result); }
public IEnumerable <UserList> GetUserListsById(int userId) { return(ExecuteFaultHandledOperation(() => { IUserRepository userRepository = _repositoryFactory.GetDataRepository <IUserRepository>(); IRoleRepository roleRepository = _repositoryFactory.GetDataRepository <IRoleRepository>(); IUserListRepository userListRepository = _repositoryFactory.GetDataRepository <IUserListRepository>(); User userAccount = userRepository.Get(userId); if (userAccount == null) { NotFoundException ex = new NotFoundException(string.Format("{0} kimlik numarasına sahip herhangi bir hesap bulunamadı!", userId)); throw new FaultException <NotFoundException>(ex, ex.Message); } ValidateAuthorization(userAccount); IEnumerable <UserList> userLists = userListRepository.GetByUserId(userAccount.Id); return userLists; })); }
public string GenerateLocSerialsMovedReport(string custCode, string locCode) { var repo = _dataRepositoryFactory .GetDataRepository <ILRyderCiscoSncycCntRepository>(); var items = repo.GetScannedQtyMismatches("H2", custCode, locCode); if (items.Count == 0) { throw new Exception("Location Serials Moved Report has no data"); } var path = string.Format("{0}\\{1}_{2}.csv", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "loc_serials_moved", DateTime.Now.ToString("yyyyMMddhhmm")); using (var fs = File.Create(path)) using (StreamWriter bw = new StreamWriter(fs)) { bw.WriteLine("\"CustomerCode\",\"LocationCode\",\"ItemCode\",\"LocOnHandQty\",\"CycleCountQty\",\"Difference\""); foreach (var item in items) { bw.WriteLine(string.Format("\"{0}\",\"{1}\",\"{2}\",{3},{4},{5}", item.CustomerCode, item.LocationCode, item.ItemCode, item.LocOnHandQty, item.CycleCountQty, item.Difference)); } bw.Close(); } return(Path.GetFileName(path)); }
private void InitRepositories(List <Type> entities) { _errorsRepository = _dataRepositoryFactory.GetDataRepository <Error>(RequestMessage); if (entities.Any(e => e.FullName == typeof(Event).FullName)) { _eventsRepository = _dataRepositoryFactory.GetDataRepository <Event>(RequestMessage); } if (entities.Any(e => e.FullName == typeof(Poster).FullName)) { _postersRepository = _dataRepositoryFactory.GetDataRepository <Poster>(RequestMessage); } if (entities.Any(e => e.FullName == typeof(News).FullName)) { _newsRepository = _dataRepositoryFactory.GetDataRepository <News>(RequestMessage); } if (entities.Any(e => e.FullName == typeof(Report).FullName)) { _reportsRepository = _dataRepositoryFactory.GetDataRepository <Report>(RequestMessage); } if (entities.Any(e => e.FullName == typeof(Book).FullName)) { _booksRepository = _dataRepositoryFactory.GetDataRepository <Book>(RequestMessage); } if (entities.Any(e => e.FullName == typeof(Quote).FullName)) { _quotesRepository = _dataRepositoryFactory.GetDataRepository <Quote>(RequestMessage); } if (entities.Any(e => e.FullName == typeof(Leaflet).FullName)) { _leafletsRepository = _dataRepositoryFactory.GetDataRepository <Leaflet>(RequestMessage); } if (entities.Any(e => e.FullName == typeof(LeafletCategory).FullName)) { _leafletCategoriesRepository = _dataRepositoryFactory.GetDataRepository <LeafletCategory>(RequestMessage); } if (entities.Any(e => e.FullName == typeof(FreeDownload).FullName)) { _freeDownloadRepository = _dataRepositoryFactory.GetDataRepository <FreeDownload>(RequestMessage); } if (entities.Any(e => e.FullName == typeof(Model).FullName)) { _modelsRepository = _dataRepositoryFactory.GetDataRepository <Model>(RequestMessage); } }
bool VerifyWithActiveDirecory(IServiceBase authService, string adUserName, bool isLive) { //for AD we will set up the user by compiling the relevant criteria. //we will only ever use the name part of AD so we need to add the domain and other details to do the AD query //we also need to check if a user with that name does exist in the database IJarsUserAccountRepository userRepo = _DataRepositoryFactory.GetDataRepository <IJarsUserAccountRepository>(); //log that a request was made that failed for the user.. this might help with identifying attacks on the system. IErrorLogRepository errRepo = _DataRepositoryFactory.GetDataRepository <IErrorLogRepository>(); string domain = Environment.UserDomainName; //string userName = $"{domain}\\{adUserName}"; if (isLive) { JarsUserAccount acc = userRepo.GetByUserNameEagerly(adUserName); if (acc != null) { //while in dev we will just say the current user is authorized authService.Request.Items.Add("account", acc); //the user was found, but now we need to make sure that the user exists in AD. if (acc.IsActive.HasValue && !acc.IsActive.Value) { authService.Request.Items.Add("IsActive", acc.IsActive.Value); return(acc.IsActive.Value); } else { //now check if AD can be accessed return(true);//as this computer does not sit on an AD domain try { using (var domainContext = new PrincipalContext(ContextType.Domain, domain)) { using (var foundUser = UserPrincipal.FindByIdentity(domainContext, IdentityType.SamAccountName, adUserName)) { //we could update the user settings here if they were assigned to another group or principal. authService.Request.Items.Add("account", acc); return(foundUser != null); } } } catch (PrincipalServerDownException pex) { errRepo.CreateUpdate(new ErrorLog { EnvironmentUserName = Environment.UserName, ErrorText = pex.Message, ErrorTime = DateTime.Now, ErrorType = "LoginFailed" }, "CustomAuthProvider"); return(false); } catch (Exception ex) { errRepo.CreateUpdate(new ErrorLog { EnvironmentUserName = Environment.UserName, ErrorText = ex.Message, ErrorTime = DateTime.Now, ErrorType = "LoginFailed" }, "CustomAuthProvider"); throw ex; } } } else { JarsUserAccount nacc = new JarsUserAccount { AccountName = adUserName, IsActive = false, UserPermissions = "NONE" }; // userRepo.GetByUserName(adUserName); acc = userRepo.CreateUpdate(nacc, "AUTOREGISTER"); errRepo.CreateUpdate(new ErrorLog { EnvironmentUserName = Environment.UserName, ErrorText = "Failed login attempt.", ErrorTime = DateTime.Now, ErrorType = "LoginFailed" }, "CustomAuthProvider"); //!This needs changing, but for testing purposes this has been made so any new sign in will just create a user and continue nacc.IsActive = true; acc = userRepo.CreateUpdate(nacc, "AUTOREGISTER"); acc = userRepo.GetByUserNameEagerly(adUserName); authService.Request.Items.Add("account", acc); //the user was found, but now we need to make sure that the user exists in AD. if (acc.IsActive.HasValue && !acc.IsActive.Value) { authService.Request.Items.Add("IsActive", acc.IsActive.Value); return(acc.IsActive.Value); } else { return(false);//userName == "Dev" && password == "Pass"; } } } else { if ("TestAccount" == adUserName) { return(true); } else { return(false); } } }
public void Test() { var data = _DataRepositoryFactory.GetDataRepository <UserRepository>(); _UserRepository.Get(); }
protected override Account LoadAuthorizationValidationAccount(string loginName) { IAccountRepository accountRepository = _DataRepositoryFactory.GetDataRepository <IAccountRepository>(); Account authAcct = accountRepository.GetByLogin(loginName); if (authAcct == null) { NotFoundException ex = new NotFoundException(string.Format("Cannot find account for login name {0} to use for security trimming.", loginName)); throw new FaultException <NotFoundException>(ex, ex.Message); } return(authAcct); }
public IEnumerable <DiasLaborables> GetDiasLaborales(int Anio) { IDiasLaborablesRepository diasLaborablesRepository = _DataRepositoryFactory.GetDataRepository <IDiasLaborablesRepository>(); return(diasLaborablesRepository.GetDiasPorPeriodo(Anio)); }
public County Get(int entityId) { var countyRepository = _dataRepositoryFactory.GetDataRepository <ICountyRepository>(); return(countyRepository.Get(entityId)); }
protected override Account LoadAuthorizationValidationAccount(string loginName) { IAccountRepository accountRepository = _dataRepositoryFactory.GetDataRepository <IAccountRepository>(); Account authAccount = accountRepository.GetByLogin(loginName); if (authAccount == null) { NotFoundException ex = new NotFoundException(string.Format("Cannot find account for login name {0} to use for security trimming.", loginName)); //WCF gestiona las excepciones como mensaje SOAP con FaultException: FaultContract attribute throw new FaultException <NotFoundException>(ex, ex.Message); } return(authAccount); }
public IList <ContentType> GetContentTypeList() { IContentTypeRepository contentTypeRepository = _dataFactoryRepository.GetDataRepository <IContentTypeRepository>(); return(contentTypeRepository.Get().ToList()); }
public List <Category> GetCategories() { return(_repoFactory.GetDataRepository <ICategoryRepository>().Get().ToList()); }
public IEnumerable <Rental> GetCarRentalHistory(string loginEmail) { return(ExecuteFaultHandledOperation(() => { IAccountRepository accountRep = _DataRepositoryFactory.GetDataRepository <IAccountRepository>(); IRentalRepository rental = _DataRepositoryFactory.GetDataRepository <IRentalRepository>(); Account account = accountRep.GetByLogin(loginEmail); if (account == null) { NotFoundException ex = new NotFoundException(string.Format($"No account found for login {loginEmail}")); throw new FaultException <NotFoundException>(ex, ex.Message); } ValidateAutorization(account); IEnumerable <Rental> rentalHistory = rental.GetRentalHistoryByAccount(account.AccountId); return rentalHistory; })); }
public override void RegisterModule() { ExecuteFaultHandledOperation(() => { systemCoreData.ISolutionRepository solutionRepository = _DataRepositoryFactory.GetDataRepository <systemCoreData.ISolutionRepository>(); systemCoreData.IModuleRepository moduleRepository = _DataRepositoryFactory.GetDataRepository <systemCoreData.IModuleRepository>(); systemCoreData.IMenuRepository menuRepository = _DataRepositoryFactory.GetDataRepository <systemCoreData.IMenuRepository>(); systemCoreData.IRoleRepository roleRepository = _DataRepositoryFactory.GetDataRepository <systemCoreData.IRoleRepository>(); systemCoreData.IMenuRoleRepository menuRoleRepository = _DataRepositoryFactory.GetDataRepository <systemCoreData.IMenuRoleRepository>(); IGLTypeRepository glTypeRepository = _DataRepositoryFactory.GetDataRepository <IGLTypeRepository>(); using (TransactionScope ts = new TransactionScope()) { //check if module has been installed systemCoreEntities.Module module = moduleRepository.Get().Where(c => c.Name == MODULE_NAME).FirstOrDefault(); if (module == null) { //check if module category exit systemCoreEntities.Solution solution = solutionRepository.Get().Where(c => c.Name == SOLUTION_NAME).FirstOrDefault(); if (solution == null) { //register solution solution = new systemCoreEntities.Solution() { Name = SOLUTION_NAME, Alias = SOLUTION_ALIAS, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }; solution = solutionRepository.Add(solution); } //register module module = new systemCoreEntities.Module() { Name = MODULE_NAME, Alias = MODULE_ALIAS, SolutionId = solution.EntityId, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }; module = moduleRepository.Add(module); //Role var adminRole = new systemCoreEntities.Role() { SolutionId = solution.SolutionId, Name = GROUP_ADMINISTRATOR, Description = "For IFRS solution unlimited users", Type = systemCoreFramework.RoleType.Application, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }; roleRepository.Add(adminRole); var userRole = new systemCoreEntities.Role() { SolutionId = solution.SolutionId, Name = GROUP_USER, Description = "For IFRS solution limited users", Type = systemCoreFramework.RoleType.Application, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }; roleRepository.Add(userRole); int menuIndex = 0; //register menu var root = new systemCoreEntities.Menu() { Name = "IFRS", Alias = "IFRS", Action = "", ActionUrl = "", Image = null, ImageUrl = "ifrs_image", ModuleId = module.EntityId, ParentId = null, Position = menuIndex += 1, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }; root = menuRepository.Add(root); menuRoleRepository.Add(new systemCoreEntities.MenuRole() { MenuId = root.EntityId, RoleId = adminRole.EntityId, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }); menuRoleRepository.Add(new systemCoreEntities.MenuRole() { MenuId = root.EntityId, RoleId = userRole.EntityId, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }); var loan = new systemCoreEntities.Menu() { Name = "IFRS_LOAN", Alias = "Loans", Action = "IFRS_LOAN", ActionUrl = "", Image = null, ImageUrl = "ifrs_loan_image", ModuleId = module.EntityId, ParentId = root.EntityId, Position = menuIndex += 1, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }; menuRepository.Add(loan); menuRoleRepository.Add(new systemCoreEntities.MenuRole() { MenuId = loan.EntityId, RoleId = adminRole.EntityId, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }); menuRoleRepository.Add(new systemCoreEntities.MenuRole() { MenuId = loan.EntityId, RoleId = userRole.EntityId, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }); var finInstrument = new systemCoreEntities.Menu() { Name = "IFRS_FINANCIAL_INSTRUMENT", Alias = "Financial Instrument", Action = "IFRS_FINANCIAL_INSTRUMENT", ActionUrl = "", Image = null, ImageUrl = "ifrs_financialinstrument_image", ModuleId = module.EntityId, ParentId = root.EntityId, Position = menuIndex += 1, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }; menuRepository.Add(finInstrument); menuRoleRepository.Add(new systemCoreEntities.MenuRole() { MenuId = finInstrument.EntityId, RoleId = adminRole.EntityId, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }); menuRoleRepository.Add(new systemCoreEntities.MenuRole() { MenuId = finInstrument.EntityId, RoleId = userRole.EntityId, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }); var dataview = new systemCoreEntities.Menu() { Name = "IFRS_DATA_VIEW", Alias = "IFRS Processed Data", Action = "IFRS_DATA_VIEW", ActionUrl = "", Image = null, ImageUrl = "ifrs_dataview_image", ModuleId = module.EntityId, ParentId = root.EntityId, Position = menuIndex += 1, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }; menuRepository.Add(dataview); menuRoleRepository.Add(new systemCoreEntities.MenuRole() { MenuId = dataview.EntityId, RoleId = adminRole.EntityId, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }); menuRoleRepository.Add(new systemCoreEntities.MenuRole() { MenuId = dataview.EntityId, RoleId = userRole.EntityId, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }); var finstat = new systemCoreEntities.Menu() { Name = "FINSTAT", Alias = "Finstat", Action = "FINSTAT", ActionUrl = "", Image = null, ImageUrl = "finstat_image", ModuleId = module.EntityId, ParentId = root.EntityId, Position = menuIndex += 1, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }; menuRepository.Add(finstat); menuRoleRepository.Add(new systemCoreEntities.MenuRole() { MenuId = finstat.EntityId, RoleId = adminRole.EntityId, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }); menuRoleRepository.Add(new systemCoreEntities.MenuRole() { MenuId = finstat.EntityId, RoleId = userRole.EntityId, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }); var actionMenu = new systemCoreEntities.Menu() { Name = "IFRS_REGISTRY", Alias = "Registries", Action = "IFRS_REGISTRY", ActionUrl = "finstat-registry-list", Image = null, ImageUrl = "action_image", ModuleId = module.EntityId, ParentId = finstat.EntityId, Position = menuIndex += 1, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }; menuRepository.Add(actionMenu); menuRoleRepository.Add(new systemCoreEntities.MenuRole() { MenuId = actionMenu.EntityId, RoleId = adminRole.EntityId, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }); actionMenu = new systemCoreEntities.Menu() { Name = "DERIVED_CAPTIONS", Alias = "Derived Captions", Action = "DERIVED_CAPTIONS", ActionUrl = "finstat-derivedcaption-list", Image = null, ImageUrl = "action_image", ModuleId = module.EntityId, ParentId = finstat.EntityId, Position = menuIndex += 1, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }; menuRepository.Add(actionMenu); menuRoleRepository.Add(new systemCoreEntities.MenuRole() { MenuId = actionMenu.EntityId, RoleId = adminRole.EntityId, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }); } ts.Complete(); } }); }
private void InitRepositories(List <Type> entities) { _errorsRepository = _dataRepositoryFactory.GetDataRepository <Error>(RequestMessage); if (entities.Any(e => e.FullName == typeof(Customer).FullName)) { _customersRepository = _dataRepositoryFactory.GetDataRepository <Customer>(RequestMessage); } if (entities.Any(e => e.FullName == typeof(Supplier).FullName)) { _suppliersRepository = _dataRepositoryFactory.GetDataRepository <Supplier>(RequestMessage); } if (entities.Any(e => e.FullName == typeof(ThirdPartyInspection).FullName)) { _thirdPartyInspectionsRepository = _dataRepositoryFactory.GetDataRepository <ThirdPartyInspection>(RequestMessage); } if (entities.Any(e => e.FullName == typeof(Specifications).FullName)) { _specificationsRepository = _dataRepositoryFactory.GetDataRepository <Specifications>(RequestMessage); } if (entities.Any(e => e.FullName == typeof(Dimension).FullName)) { _dimensionRepository = _dataRepositoryFactory.GetDataRepository <Dimension>(RequestMessage); } if (entities.Any(e => e.FullName == typeof(RawMaterialForm).FullName)) { _rawMaterialFormsRepository = _dataRepositoryFactory.GetDataRepository <RawMaterialForm>(RequestMessage); } if (entities.Any(e => e.FullName == typeof(Test).FullName)) { _testsRepository = _dataRepositoryFactory.GetDataRepository <Test>(RequestMessage); } if (entities.Any(e => e.FullName == typeof(Error).FullName)) { _errorsRepository = _dataRepositoryFactory.GetDataRepository <Error>(RequestMessage); } if (entities.Any(e => e.FullName == typeof(MaterialRegisterHeader).FullName)) { _materialRegisterHeadersRepository = _dataRepositoryFactory.GetDataRepository <MaterialRegisterHeader>(RequestMessage); } if (entities.Any(e => e.FullName == typeof(MaterialRegisterSubSeries).FullName)) { _materialRegisterSubseriessRepository = _dataRepositoryFactory.GetDataRepository <MaterialRegisterSubSeries>(RequestMessage); } if (entities.Any(e => e.FullName == typeof(HeatChartHeader).FullName)) { _heatChartHeadersRepository = _dataRepositoryFactory.GetDataRepository <HeatChartHeader>(RequestMessage); } if (entities.Any(e => e.FullName == typeof(HeatChartDetails).FullName)) { _heatChartDetailsRepository = _dataRepositoryFactory.GetDataRepository <HeatChartDetails>(RequestMessage); } if (entities.Any(e => e.FullName == typeof(LabReport).FullName)) { _labReportssRepository = _dataRepositoryFactory.GetDataRepository <LabReport>(RequestMessage); } if (entities.Any(e => e.FullName == typeof(MillDetail).FullName)) { _millDetailsRepository = _dataRepositoryFactory.GetDataRepository <MillDetail>(RequestMessage); } if (entities.Any(e => e.FullName == typeof(MaterialRegisterSubseriesTestRelationship).FullName)) { _materialRegisterSubseriesTestRelationshipRepository = _dataRepositoryFactory.GetDataRepository <MaterialRegisterSubseriesTestRelationship>(RequestMessage); } if (entities.Any(e => e.FullName == typeof(MaterialRegisterFileDetail).FullName)) { _materialRegisterFileDetailsRepository = _dataRepositoryFactory.GetDataRepository <MaterialRegisterFileDetail>(RequestMessage); } if (entities.Any(e => e.FullName == typeof(HeatChartMaterialHeaderRelationship).FullName)) { _heatChartMaterialHeaderRelationshipRepository = _dataRepositoryFactory.GetDataRepository <HeatChartMaterialHeaderRelationship>(RequestMessage); } }
public IEnumerable <AporteEmpleador> GetAportesEmpleador() { IAporteEmpleadorRepository aporteEmpleadorRepository = _DataRepositoryFactory.GetDataRepository <IAporteEmpleadorRepository>(); return(aporteEmpleadorRepository.Get()); }
public override void RegisterModule() { ExecuteFaultHandledOperation(() => { ISolutionRepository solutionRepository = _DataRepositoryFactory.GetDataRepository <ISolutionRepository>(); systemCoreData.IModuleRepository moduleRepository = _DataRepositoryFactory.GetDataRepository <systemCoreData.IModuleRepository>(); IMenuRepository menuRepository = _DataRepositoryFactory.GetDataRepository <IMenuRepository>(); IRoleRepository roleRepository = _DataRepositoryFactory.GetDataRepository <IRoleRepository>(); IMenuRoleRepository menuRoleRepository = _DataRepositoryFactory.GetDataRepository <IMenuRoleRepository>(); using (TransactionScope ts = new TransactionScope()) { //check if module has been installed systemCoreEntities.Module module = moduleRepository.Get().Where(c => c.Name == OpexModuleDefinition.MODULE_NAME).FirstOrDefault(); var register = false; if (module == null) { register = true; } else { register = module.CanUpdate; } if (register) { //check if module category exit Solution solution = solutionRepository.Get().Where(c => c.Name == OpexModuleDefinition.SOLUTION_NAME).FirstOrDefault(); if (solution == null) { //register solution solution = new Solution() { Name = OpexModuleDefinition.SOLUTION_NAME, Alias = OpexModuleDefinition.SOLUTION_ALIAS, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }; solution = solutionRepository.Add(solution); } //register module if (module == null) { module = new systemCoreEntities.Module() { Name = OpexModuleDefinition.MODULE_NAME, Alias = OpexModuleDefinition.MODULE_ALIAS, SolutionId = solution.EntityId, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }; module = moduleRepository.Add(module); } //Roles var existingRoles = roleRepository.Get().Where(c => c.SolutionId == solution.SolutionId && c.Type == RoleType.Application).ToList(); //var updatedRoles = new List<Role>(); //foreach (var role in OpexModuleDefinition.GetRoles()) //{ // var localRole = existingRoles.Where(c => c.Name == role.Name).FirstOrDefault(); // if (localRole == null) // { // localRole = new Role() { Name = role.Name, Description = role.Description, SolutionId = solution.SolutionId, Type = RoleType.Application, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }; // localRole = roleRepository.Add(localRole); // } // else // { // localRole.Description = role.Description; // localRole.UpdatedOn = DateTime.Now; // localRole = roleRepository.Update(localRole); // } // updatedRoles.Add(localRole); //} //Menus var existingMenus = menuRepository.Get().Where(c => c.ModuleId == module.ModuleId).ToList(); var updatedMenus = new List <Menu>(); var menuIndex = 0; foreach (var menu in OpexModuleDefinition.GetMenus()) { menuIndex += 1; Menu parentMenu = null; int?parentId = null; if (!string.IsNullOrEmpty(menu.Parent)) { if (string.IsNullOrEmpty(menu.ParentModule)) { parentMenu = existingMenus.Where(c => c.Name == menu.Parent).FirstOrDefault(); if (parentMenu == null) { parentMenu = menuRepository.Get().Where(c => c.ModuleId == module.ModuleId && c.Name == menu.Parent).FirstOrDefault(); } } else { var parentModule = moduleRepository.Get().Where(c => c.Name == menu.ParentModule).FirstOrDefault(); if (parentModule != null) { parentMenu = menuRepository.Get().Where(c => c.ModuleId == parentModule.ModuleId && c.Name == menu.Parent).FirstOrDefault(); } } if (parentMenu != null) { parentId = parentMenu.MenuId; } } var localMenu = existingMenus.Where(c => c.Name == menu.Name).FirstOrDefault(); if (localMenu == null) { localMenu = new Menu() { Name = menu.Name, Alias = menu.Alias, Action = menu.Action, ActionUrl = menu.ActionUrl, ImageUrl = menu.ImageUrl, ModuleId = module.ModuleId, Position = menuIndex, ParentId = parentId, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }; localMenu = menuRepository.Add(localMenu); } else { localMenu.Alias = menu.Alias; localMenu.Action = menu.Action; localMenu.ActionUrl = menu.ActionUrl; localMenu.ImageUrl = menu.ImageUrl; localMenu.ModuleId = module.ModuleId; localMenu.Position = menuIndex; localMenu.ParentId = parentId; localMenu.UpdatedOn = DateTime.Now; localMenu = menuRepository.Update(localMenu); } updatedMenus.Add(localMenu); } //MenuRoles var menuIds = updatedMenus.Select(c => c.MenuId).Distinct().ToArray(); var existingMenuRoles = menuRoleRepository.Get().Where(c => menuIds.Contains(c.MenuId)).ToList(); foreach (var menuRole in OpexModuleDefinition.GetMenuRoles()) { var myMenu = updatedMenus.Where(c => c.Name == menuRole.MenuName).FirstOrDefault(); var myRole = existingRoles.Where(c => c.Name == menuRole.RoleName).FirstOrDefault(); var localMenuRole = existingMenuRoles.Where(c => c.MenuId == myMenu.MenuId && c.RoleId == myRole.RoleId).FirstOrDefault(); if (localMenuRole == null) { localMenuRole = new MenuRole() { MenuId = myMenu.MenuId, RoleId = myRole.RoleId, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }; menuRoleRepository.Add(localMenuRole); } else { localMenuRole.MenuId = myMenu.MenuId; localMenuRole.RoleId = myRole.RoleId; localMenuRole.UpdatedOn = DateTime.Now; menuRoleRepository.Update(localMenuRole); } } } ts.Complete(); } }); }
public override void RegisterModule() { ExecuteFaultHandledOperation(() => { systemCoreData.ISolutionRepository solutionRepository = _DataRepositoryFactory.GetDataRepository <systemCoreData.ISolutionRepository>(); systemCoreData.IModuleRepository moduleRepository = _DataRepositoryFactory.GetDataRepository <systemCoreData.IModuleRepository>(); systemCoreData.IMenuRepository menuRepository = _DataRepositoryFactory.GetDataRepository <systemCoreData.IMenuRepository>(); systemCoreData.IRoleRepository roleRepository = _DataRepositoryFactory.GetDataRepository <systemCoreData.IRoleRepository>(); systemCoreData.IMenuRoleRepository menuRoleRepository = _DataRepositoryFactory.GetDataRepository <systemCoreData.IMenuRoleRepository>(); using (TransactionScope ts = new TransactionScope()) { //check if module has been installed systemCoreEntities.Module module = moduleRepository.Get().Where(c => c.Name == MODULE_NAME).FirstOrDefault(); if (module == null) { //check if module category exit systemCoreEntities.Solution solution = solutionRepository.Get().Where(c => c.Name == SOLUTION_NAME).FirstOrDefault(); if (solution == null) { //register solution solution = new systemCoreEntities.Solution() { Name = SOLUTION_NAME, Alias = SOLUTION_ALIAS, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }; solution = solutionRepository.Add(solution); } //register module module = new systemCoreEntities.Module() { Name = MODULE_NAME, Alias = MODULE_ALIAS, SolutionId = solution.EntityId, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }; module = moduleRepository.Add(module); int menuIndex = 0; var root = menuRepository.Get().Where(c => c.Alias == "IFRS Processed Data").FirstOrDefault(); //Role var adminRole = roleRepository.Get().Where(c => c.Name == GROUP_ADMINISTRATOR && c.SolutionId == solution.SolutionId).FirstOrDefault(); var userRole = roleRepository.Get().Where(c => c.Name == GROUP_USER && c.SolutionId == solution.SolutionId).FirstOrDefault(); //register menu var actionMenu = new systemCoreEntities.Menu() { Name = "IFRS_BOND_PERIODIC_SCHEDULE", Alias = "Bond Periodic Data", Action = "IFRS_BOND_PERIODIC_SCHEDULE", ActionUrl = "ifrs-bondperiodicschedule-list", Image = null, ImageUrl = "action_image", ModuleId = module.EntityId, ParentId = root.EntityId, Position = menuIndex += 1, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }; menuRepository.Add(actionMenu); menuRoleRepository.Add(new systemCoreEntities.MenuRole() { MenuId = actionMenu.EntityId, RoleId = adminRole.EntityId, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }); actionMenu = new systemCoreEntities.Menu() { Name = "DAILY_BOND_AMORTIZATION", Alias = "Daily Bond Amortization", Action = "DAILY_BOND_AMORTIZATION", ActionUrl = "ifrs-bondamortization-list", Image = null, ImageUrl = "action_image", ModuleId = module.EntityId, ParentId = root.EntityId, Position = menuIndex += 1, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }; menuRepository.Add(actionMenu); menuRoleRepository.Add(new systemCoreEntities.MenuRole() { MenuId = actionMenu.EntityId, RoleId = adminRole.EntityId, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }); actionMenu = new systemCoreEntities.Menu() { Name = "ZERO_COUPON_BOND", Alias = "Zero Coupon Bond", Action = "ZERO_COUPON_BOND", ActionUrl = "ifrs-zerocouponbond-list", Image = null, ImageUrl = "action_image", ModuleId = module.EntityId, ParentId = root.EntityId, Position = menuIndex += 1, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }; menuRepository.Add(actionMenu); menuRoleRepository.Add(new systemCoreEntities.MenuRole() { MenuId = actionMenu.EntityId, RoleId = adminRole.EntityId, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }); actionMenu = new systemCoreEntities.Menu() { Name = "LOAN_PERIODIC_SCHEDULE", Alias = "Loan Periodic Schedule", Action = "LOAN_PERIODIC_SCHEDULE", ActionUrl = "ifrs-loanperiodicschedule-list", Image = null, ImageUrl = "action_image", ModuleId = module.EntityId, ParentId = root.EntityId, Position = menuIndex += 1, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }; menuRepository.Add(actionMenu); menuRoleRepository.Add(new systemCoreEntities.MenuRole() { MenuId = actionMenu.EntityId, RoleId = adminRole.EntityId, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }); actionMenu = new systemCoreEntities.Menu() { Name = "LOAN_DAILY_SCHEDULE", Alias = "Loan Daily Schedule", Action = "LOAN_DAILY_SCHEDULE", ActionUrl = "ifrs-loandailyschedule-list", Image = null, ImageUrl = "action_image", ModuleId = module.EntityId, ParentId = root.EntityId, Position = menuIndex += 1, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }; menuRepository.Add(actionMenu); menuRoleRepository.Add(new systemCoreEntities.MenuRole() { MenuId = actionMenu.EntityId, RoleId = adminRole.EntityId, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }); actionMenu = new systemCoreEntities.Menu() { Name = "LOAN_IMAPIRMENT_RESULT", Alias = "Loan Impairment Result", Action = "LOAN_IMAPIRMENT_RESULT", ActionUrl = "ifrs-loanimpairmentresult-list", Image = null, ImageUrl = "action_image", ModuleId = module.EntityId, ParentId = root.EntityId, Position = menuIndex += 1, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }; menuRepository.Add(actionMenu); menuRoleRepository.Add(new systemCoreEntities.MenuRole() { MenuId = actionMenu.EntityId, RoleId = adminRole.EntityId, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }); actionMenu = new systemCoreEntities.Menu() { Name = "TREASURY_BILL_COMPUTATION", Alias = "Treasury Bills", Action = "TREASURY_BILL_COMPUTATION", ActionUrl = "ifrs-treasurybillscomputation-list", Image = null, ImageUrl = "action_image", ModuleId = module.EntityId, ParentId = root.EntityId, Position = menuIndex += 1, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }; menuRepository.Add(actionMenu); menuRoleRepository.Add(new systemCoreEntities.MenuRole() { MenuId = actionMenu.EntityId, RoleId = adminRole.EntityId, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }); actionMenu = new systemCoreEntities.Menu() { Name = "EQUITY_STOCK_COMPUTATION", Alias = "Equity Stock", Action = "EQUITY_STOCK_COMPUTATION", ActionUrl = "ifrs-equitystock-list", Image = null, ImageUrl = "action_image", ModuleId = module.EntityId, ParentId = root.EntityId, Position = menuIndex += 1, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }; menuRepository.Add(actionMenu); menuRoleRepository.Add(new systemCoreEntities.MenuRole() { MenuId = actionMenu.EntityId, RoleId = adminRole.EntityId, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now }); } ts.Complete(); } }); }
// BaseService class'ındaki metodu override ediyoruz. protected override User LoadAuthorizationValidationAccount(string loginName) { IUserRepository userRepository = _dataRepositoryFactory.GetDataRepository <IUserRepository>(); User authAccount = userRepository.GetByEmail(loginName); if (authAccount == null) { NotFoundException ex = new NotFoundException(string.Format("{0} isminde kullanıcı bulunamadı!", loginName)); throw new FaultException <NotFoundException>(ex, ex.Message); } return(authAccount); }
public User GetOnlyUserForNow() { var userRepo = _repoFactory.GetDataRepository <IUserRepository>(); return(userRepo.Get(GetUserId())); }