public LogicResponse Delete(int courseId, int id) { LogicResponse response = new LogicResponse(); Module module = _moduleRepository.Get(courseId, id); if (module == null) { response.Success = false; response.Message = "No se encontró el módulo"; return(response); } try { _moduleRepository.Delete(module); response.Success = true; response.Message = "Se borró el módulo"; return(response); } catch (Exception ex) { response.Success = false; response.Message = "No se pudo borrar el módulo"; return(response); } }
public IEnumerable <DocumentNonOfficiel> GetDocumentByModule(int ModuleId) { if (ModuleId < 1 || _moduleRepository.Get(ModuleId) == null) { return(null); } return(_documentNonOfficielRepository.GetDocumentByModule(ModuleId)); }
/// <summary> /// This method gets current page "View" actions of all modules /// </summary> /// <param name="actionContext"></param> /// <returns></returns> public async Task <Dictionary <string, List <ContentResult> > > GetPageModuleResults(ActionContext actionContext) { Dictionary <string, List <ContentResult> > actionResults = new Dictionary <string, List <ContentResult> >(); Page currentPage = _scopeService.PageContext.CurrentPage; if (currentPage.PageModule != null && currentPage.PageModule.Count > 0) { currentPage.PageModule = currentPage.PageModule.Where(pm => !pm.IsDeleted).ToList(); foreach (var pageModule in currentPage.PageModule) { Module module = _moduleRepository.Get(pageModule.ModuleId); ModuleAction moduleAction = module.ModuleAction.FirstOrDefault(ma => ma.Id == pageModule.ModuleActionId); ModuleContext moduleContext = new ModuleContext(); moduleContext.ModuleInfo = module; moduleContext.PageModuleId = pageModule.Id; if (module != null && moduleAction != null) { List <ContentResult> contentResults; string containerId = pageModule.ContainerId.ToString(); //Prepare the result object if (actionResults.ContainsKey(containerId)) { contentResults = actionResults[containerId]; } else { contentResults = new List <ContentResult>(); actionResults.Add(containerId, contentResults); } try { IHtmlContent actionResult = await ExecuteModuleController(actionContext, moduleContext, moduleAction); IHtmlContent moduleResult = GetModuleResult(actionResult, moduleContext); contentResults.Add(new ContentResult { HtmlResult = moduleResult, SortOrder = pageModule.SortOrder }); } catch (Exception ex) { var actionResult = "Module load exception has been occured"; contentResults.Add(new ContentResult { //Result = actionResult, HtmlResult = new HtmlString(actionResult), SortOrder = pageModule.SortOrder }); _logger.LogError("Module load exception has been occured", ex); } } } } return(actionResults); }
public IEnumerable <DocumentOfficiel> GetDocumentsByModule(int ModuleId, int pageIndex, int pageSize) { if (ModuleId < 1 || _moduleRepository.Get(ModuleId) == null || pageIndex < 0 || pageSize < 0) { return(null); } if (pageIndex == 0 && pageSize == 0) { return(_documentOfficielRepository.GetAll().Where(o => o.ModuleId == ModuleId)); } return(_documentOfficielRepository.GetDocumentByModule(ModuleId, pageIndex, pageSize)); }
public IHttpActionResult GetModule(int id) { Module Module = ModuleRepo.Get(id); if (Module == null) { return(NotFound()); } ModuleDTO ModuleDTO = Mapper.Map <ModuleDTO>(Module); return(Ok(ModuleDTO)); }
public void Handle(BuildState state) { var module = _moduleRepository.Get(state.NetlistSource, state.CurrentModuleName); module.SupplyDeclarations.Add(state.CurrentStatementTrimmed); _moduleRepository.Update(module); }
public ModuleDTO EditModule(DataObjects.ModuleDTO moduledto) { Module parentmodule = null; var module = Mapper.Map <ModuleDTO, Module>(moduledto); var mod = moduleRepository.Get(Specification <Module> .Eval(m => m.ID.Equals(module.ID))); if (moduledto.ParentID.HasValue) { parentmodule = moduleRepository.Find(Specification <Module> .Eval(m => m.ID.Equals(moduledto.ParentID.Value))); } mod.ParentModule = parentmodule; mod.ActionName = module.ActionName; mod.ControllerName = module.ControllerName; mod.Creator = module.Creator; mod.Description = module.Description; mod.EditDate = module.EditDate; mod.ICON = module.ICON; mod.Index = module.Index; mod.IsMenus = module.IsMenus; mod.IsPost = module.IsPost; mod.Name = module.Name; mod.Target = module.Target; mod.Url = module.Url; moduleRepository.Update(mod); Context.Commit(); return(Mapper.Map <Module, ModuleDTO>(module).ToViewModel()); }
protected void ReceiveRequestAppFile(PacketHeader header, Connection connection, long moduleId) { // ######################################################################## // This method requires authentication. // If user is not authorized then send UnAuthorized and end method. if (!accountManager.Authorized(connection)) { TCPConnection.GetConnection(connection.ConnectionInfo).SendObject( PacketName.ReUnauthorized.ToString(), 1); return; } // ######################################################################## Module module = moduleRepository.Get(moduleId); string filePath = module.path; byte[] fileData = File.ReadAllBytes(filePath); AppFileData appData = new AppFileData(module.id, filePath, fileData); TCPConnection.GetConnection(connection.ConnectionInfo).SendObject( PacketName.ReAppFile.ToString(), appData); }
public Dictionary <Module, Professeur> GetProfesseursBySpecialiteAndNiveau(int SpecialiteId, int Niveau) { if (SpecialiteId < 1 || Niveau < 1 || Niveau > 3) { return(null); } Dictionary <Module, Professeur> profs = new Dictionary <Module, Professeur>(); List <SpecialiteModule> sm = _specialiteModuleRepository.GetSpecialiteModulesByNiveau(SpecialiteId, Niveau).ToList(); List <ProfesseurSpecialite> ps = _professeurSpecialiteRepository.GetProfesseursBySpecialite(SpecialiteId).ToList(); List <ProfesseurModule> pm = _professeurModuleRepository.GetAll().ToList(); foreach (ProfesseurModule p in pm) { foreach (ProfesseurSpecialite s in ps) { if (p.ProfesseurId == s.ProfesseurId) { foreach (SpecialiteModule m in sm) { if (s.SpecialiteId == m.SpecialiteId && p.ModuleId == m.ModuleId && m.Niveau == Niveau) { profs.Add(_moduleRepository.Get(m.ModuleId), _professeurRepository.Get(s.ProfesseurId)); } } } } } return(profs); }
public IEnumerable <ProfesseurModule> GetProfesseursByModule(int ModuleId) { if (ModuleId < 1 || _moduleRepository.Get(ModuleId) == null) { return(null); } return(_professeurModuleRepository.GetProfesseursByModule(ModuleId)); }
public IActionResult Get() { try { var result = _moduleRepository.Get(); if (result != null) { return(Ok(result)); } return(NotFound()); } catch (Exception ex) { _logger.LogError(string.Format("Error occured while getting all modules"), ex); return(new StatusCodeResult(StatusCodes.Status500InternalServerError)); } }
public IHttpActionResult GetModules(int id) { Module module = repository.Get(id); if (module == null) { return(NotFound()); } return(Ok(module)); }
public void Handle(BuildState state) { var portType = _parser.GetPortType(state.CurrentStatementTrimmed); var portNames = _parser.GetPorts(state.CurrentStatementTrimmed).Select(p => p.PortName).ToList(); var module = _moduleRepository.Get(state.NetlistSource, state.CurrentModuleName); _moduleMutator.UpdatePortsType(module, portNames, portType); _moduleRepository.Update(module); }
public void Update(ModuleDTO moduleDTO) { //get persisted item var module = _Repository.Get(moduleDTO.Id); if (module == null) { throw new DataNotFoundException(UserSystemMessagesResources.Module_NotExists); } var oldDTO = module.ToDto(); var current = moduleDTO.ToModel(); module.Name = current.Name; module.SortOrder = current.SortOrder; if (module.Name.IsNullOrBlank()) { throw new DefinedException(UserSystemMessagesResources.Name_Empty); } if (_Repository.Exists(module)) { throw new DataExistsException(string.Format(UserSystemMessagesResources.Module_Exists_WithValue, module.Name)); } #region 操作日志 var moduleDto = module.ToDto(); OperateRecorder.RecordOperation(oldDTO.Id.ToString(), UserSystemMessagesResources.Update_Module, moduleDto.GetOperationLog(oldDTO)); #endregion //commit unit of work _Repository.UnitOfWork.Commit(); }
public LogicResponse Create(LessonDto lessonDto) { LogicResponse response = new LogicResponse(); Course course = _courseRepository.GetById(lessonDto.CourseId); Module module = _moduleRepository.Get(lessonDto.CourseId, lessonDto.ModuleId); if (course == null) { response.Success = false; response.Message = "No se encontró el curso"; return(response); } if (module == null) { response.Success = false; response.Message = "No se encontró el módulo"; return(response); } Lesson lesson = _mapper.Map <LessonDto, Lesson>(lessonDto); lesson.Module = module; try { int id = _lessonRepository.Create(lesson); response.Success = true; response.Message = id.ToString(); return(response); } catch (Exception ex) { response.Success = false; response.Message = "Error al almacenar la clase"; return(response); } }
/// <summary> /// Enable service. /// </summary> /// <param name="serviceId">The service identifier.</param> public void EnableService(long serviceId) { if (services.ContainsKey(serviceId)) { ModuleInstance service = services[serviceId]; Module module = moduleRepository.Get(serviceId); if (module.type == (int)ModuleType.Service && module.enabled == 0) { try { if (service.Load()) { moduleRepository.EnableService(serviceId); } } catch (Exception err) { logManager.Add(module.id, err.ToString()); } } } }
public IActionResult Delete(Guid id) { try { var moduleActions = _moduleRepository.Get(id); if (moduleActions != null) { moduleActions.IsActive = false; //is it correct? var result = _moduleRepository.Update(moduleActions); if (result != null) { return(Ok(result)); } } return(BadRequest()); } catch (Exception ex) { _logger.LogError(string.Format("Error occured while deleting module"), ex); return(new StatusCodeResult(StatusCodes.Status500InternalServerError)); } }
public async Task <string> GetUserPermission(UserInfo userInfo) { List <int> moduleList = new List <int>(); if (userInfo.Roles != null && userInfo.Roles?.ToList().Count > 0) { foreach (var v in userInfo.Roles) { var roleInfo = await _roleRepository.Get(x => x.Id == v.RoleId, x => x.Modules); if (roleInfo.Modules != null && roleInfo.Modules.Count > 0) { foreach (var vv in roleInfo.Modules) { var moduleInfo = await _moduleRepository.Get(vv.Id); if (moduleInfo != null) { moduleList.Add(moduleInfo.ModuleNO); } } } } } if (userInfo.Modules != null && userInfo.Modules.Count > 0) { foreach (var v in userInfo.Modules) { if (!moduleList.Contains(v.Module.ModuleNO)) { moduleList.Add(v.Module.ModuleNO); } } } return(string.Join(",", moduleList)); }
// --------------------------------------------------------------------------------------------- public ModuleDTO GetDTOWithResults(int moduleId, int userId) { var user = _userService.GetUserEntity(userId); var userQuestions = user.user_question; var passedQuests = userQuestions .Where(uq => uq.last_result == true) .Select(uq => uq.test_question) .ToList(); var userCodes = user.user_code; var passedCodes = userCodes .Where(uc => uc.last_result == true) .Select(uc => uc.test_code) .ToList(); var mod = _moduleRepository.Get(moduleId); return(GetDTOWitResults( userQuestions, passedQuests, userCodes, passedCodes, mod)); }
/// <summary> /// 取出模块功能信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public Module FindById(string id) { var model = moduleRepository.Get(id); return(model.ProjectedAs <Module>()); }
public bool CheckIsExist(Module module) { return(moduleRepository.Get(chk => chk.Name == module.Name) == null ? false : true); }
public override void RegisterModule() { ExecuteFaultHandledOperation(() => { ISolutionRepository solutionRepository = _DataRepositoryFactory.GetDataRepository <ISolutionRepository>(); IModuleRepository moduleRepository = _DataRepositoryFactory.GetDataRepository <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 Module module = moduleRepository.Get().Where(c => c.Name == IFRSCoreModuleDefinition.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 == IFRSCoreModuleDefinition.SOLUTION_NAME).FirstOrDefault(); if (solution == null) { //register solution solution = new Solution() { Name = IFRSCoreModuleDefinition.SOLUTION_NAME, Alias = IFRSCoreModuleDefinition.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 Module() { Name = IFRSCoreModuleDefinition.MODULE_NAME, Alias = IFRSCoreModuleDefinition.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 IFRSCoreModuleDefinition.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 IFRSCoreModuleDefinition.GetMenus()) { menuIndex += 1; int?parentId = null; if (!string.IsNullOrEmpty(menu.Parent)) { var 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(); } 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 IFRSCoreModuleDefinition.GetMenuRoles()) { var myMenu = updatedMenus.Where(c => c.Name == menuRole.MenuName).FirstOrDefault(); var myRole = updatedRoles.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 ModuleDTO GetEntity(string keyValue) { return(_moduleRepository.Get(keyValue).MapTo <ModuleDTO>()); }
public ModuleEntity GetForm(string keyValue) { return(service.Get(m => m.F_Id == keyValue)); }
// --------------------------------------------------------------------------------------------- public ModuleAndDistractorDTO NextModule(int userId, int currentModuleId, List <Pad> lastEmoStates) { edumodule newModule; distractor newDistractor = null; user user = _userService.GetUserEntity(userId); // pobranie listy modułów dotychczas wysłanych do tego użytkownika List <edumodule> prevModules = user.edumodule.ToList(); ModuleService.SortGroupPosition(ref prevModules); // jeśli kolejny moduł będzie wysłany po raz pierwszy - zostanie // dopisany do modułów tego użytkownika var addToUserModules = true; // To jest PIERWSZY moduł pobierany przez tego użytkownika if (prevModules.Count() == 0) { newModule = _moduleRepository.Get(1); } // To już nie pierwszy lecz KOLEJNY moduł else { var difficultyAndDistractor = PickNextDiffAndDistract(userId, lastEmoStates); // ustalenie pozycji aktualnego modułu na liście obejrzanych modułów int idx = prevModules.FindIndex(mod => mod.id == currentModuleId); // aktualnie użytkownik ogląda któryś z wczesniej pobranych // => pobranie następnego, który oglądał po aktualnym if (idx < prevModules.Count() - 1 && idx > -1) { newModule = prevModules[idx + 1]; addToUserModules = false; } // aktualnie użytkownik ogląda ostatni z pobranych => // dostosowanie trudności do stanu emocjonalnego i dotychczasowych wyników użytkownika else { var nextDifficulty = difficultyAndDistractor.Item1; newModule = PickNextModule(currentModuleId, nextDifficulty, userId); } // pobranie następnego dystraktora (distractorService sprawdzi czy już można) var nextDistractorType = difficultyAndDistractor.Item2; newDistractor = _distractorService.NextDistractor(userId, nextDistractorType); } // zapisanie kolejnego modułu na liście wysłanych użytkownikowi // oraz zapamiętanie nowego ostatniego modułu użytkownika if (addToUserModules && newModule != null) { user.edumodule.Add(newModule); user.last_module = newModule.id; _userService.SaveChanges(); } return(new ModuleAndDistractorDTO() { module = newModule == null ? null : _moduleService.GetDTOWithQuestions(newModule, userId), distractor = newDistractor == null ? null : DistractorMapper.GetDTO(newDistractor) }); }
public int getModuleIdByModulename(string name) { var id = _moduleRepository.Get(ml => ml.ModuleName == name); return(id.Id); }
public int Get() { return(moduleRepository.Get()); }
public MenuDTO Add(MenuDTO menuDTO) { var menu = menuDTO.ToModel(); menu.Id = IdentityGenerator.NewSequentialGuid(); menu.Created = DateTime.UtcNow; if (menuDTO.Module != null) { menu.Module = _ModuleRepository.Get(menuDTO.Module.Id); } if (menu.Parent == null || menu.Parent.Id == Guid.Empty) { menu.Depth = 1; } else { menu.Parent = _Repository.Get(menuDTO.Parent.Id); menu.Depth = menu.Parent.Depth + 1; } if (menu.Name.IsNullOrBlank()) { throw new DefinedException(UserSystemMessagesResources.Name_Empty); } if (menu.Module == null || menu.Module.Id == Guid.Empty) { throw new DefinedException(UserSystemMessagesResources.Module_Empty); } if (_Repository.Exists(menu)) { throw new DataExistsException(string.Format(UserSystemMessagesResources.Menu_Exists_WithValue, menu.Name)); } foreach (var p in menu.Permissions) { if (p.Id == Guid.Empty) { p.Id = IdentityGenerator.NewSequentialGuid(); p.Created = DateTime.UtcNow; } } menu.Module = _ModuleRepository.Get(menu.Module.Id); _Repository.Add(menu); #region 操作日志 var menuDto = menu.ToDto(); OperateRecorder.RecordOperation(menuDto.Id.ToString(), UserSystemMessagesResources.Add_Menu, menuDto.GetOperationLog()); #endregion //commit the unit of work _Repository.UnitOfWork.Commit(); return(menu.ToDto()); }
public async Task <IActionResult> GetModule(int id) { return(Ok(await _repo.Get(id))); }
public EndDateMessageDTO CustomEndDate(CustomEndDateInputDTO customEndDateInput) { try { string endDate = ""; #region Get total days to train those modules arrangement double totalDays = 0; //List modules arrangement was parsed from ModulesArrangement string List <ModuleArrangementDTO> listModulesArrangement = JsonConvert.DeserializeObject <ModuleArrangementDTO[]>(customEndDateInput.ModulesArrangement).ToList(); //Get list modules information from list modules arrangement above List <ShortModuleDetailDTO> listModulesDetail = new List <ShortModuleDetailDTO>(); foreach (ModuleArrangementDTO moduleArrangement in listModulesArrangement) { ShortModuleDetailDTO shortModule = new ShortModuleDetailDTO(); shortModule.ModuleId = moduleArrangement.ModuleId; shortModule.TrainTime = moduleArrangement.TrainTime; var module = _moduleRepository.Get(moduleArrangement.ModuleId); shortModule.Duration = module.Theory + module.Pratical; //Get total days to train this module if ((shortModule.Duration % shortModule.TrainTime) != 0) { double temp = shortModule.Duration / shortModule.TrainTime; shortModule.TotalDate = Math.Truncate(temp) + 1; } else { shortModule.TotalDate = shortModule.Duration / shortModule.TrainTime; } listModulesDetail.Add(shortModule); } //Get total days to train those modules arrangement foreach (ShortModuleDetailDTO module in listModulesDetail) { totalDays += module.TotalDate; } #endregion #region Calculate end date //List of days off in a week List <int> daysOff = JsonConvert.DeserializeObject <int[]>(_configurationRepository.GetDaysOff()).ToList(); endDate = _compareAppService.CalculateEndDate(customEndDateInput.StartDate, totalDays, daysOff); #endregion return(new EndDateMessageDTO() { status = true, message = L("CalculaterEndDateSuccess"), endDate = endDate }); } catch { return(new EndDateMessageDTO() { status = false, message = L("UnknownError"), endDate = "null" }); } }