private void LoadCombos() { LookupRepository repository = new LookupRepository(); var items = repository.GetCompanies().Select(s => new ComboboxItem { Text = s.Name, Value = s.Company1.ToString() }).ToList(); cboAssociateCompany.DataSource = items; cboAssociateCompany.DisplayMember = "Text"; cboAssociateCompany.ValueMember = "Value"; items = repository.GetInvoices().Select(s => new ComboboxItem { Text = s.Invoiced, Value = s.ID.ToString() }).ToList(); cboInvoiced.DataSource = items; cboInvoiced.DisplayMember = "Text"; cboInvoiced.ValueMember = "Value"; items = repository.GetPayrolls().Select(s => new ComboboxItem { Text = s.Name, Value = s.PayrollId.ToString() }).ToList(); cboPayroll.DataSource = items; cboPayroll.DisplayMember = "Text"; cboPayroll.ValueMember = "Value"; }
public virtual async Task <ActionResult <TParentResource> > Replace(string id, TAlterResource resource) { var validation = await EntityValidator.ValidateFound(resource.ParentId, nameof(resource.ParentId)); if (validation != null) { return(GetValidationResult(validation)); } var parent = await LookupRepository.Get(resource.ParentId); var validations = await ResourceValidator.ValidateReplace(resource, parent); if (validations.Any()) { return(GetValidationResult(validations)); } var child = await AlterResourceMapper.MapCreate(resource); ParentManager.Replace(parent, child, id); await AlterRepository.Replace(parent); return(await ResourceMapper.Map(parent)); }
public LookupController(IConfigurationWrapper configurationWrapper, LookupRepository lookupRepository, IUserImpersonationService userImpersonationService, IAuthenticationRepository authenticationRepository, IUserRepository userService) : base(userImpersonationService, authenticationRepository) { _configurationWrapper = configurationWrapper; _lookupRepository = lookupRepository; _authenticationRepository = authenticationRepository; _userService = userService; }
public void LoadVatRates() { vatRates = new List <VatRate>(); LookupRepository repository = new LookupRepository(); vatRates = repository.GetVatRates(); }
public void Setup() { _ministryPlatformService = new Mock <IMinistryPlatformService>(); _authenticationService = new Mock <IAuthenticationRepository>(); _configurationWrapper = new Mock <IConfigurationWrapper>(); _fixture = new LookupRepository(_authenticationService.Object, _configurationWrapper.Object, _ministryPlatformService.Object); }
private static List <Technology> SelectedTechnologies(FormCollection form) { var technologies = new List <Technology>(); foreach (var key in form.Keys) { if (key.ToString().StartsWith("Technology.")) { var value = form[key.ToString()]; bool selected = false; if (value.ToLowerInvariant() == "true") { selected = true; } if (HasChanged(value) && GetNewBooleanValue(value)) { selected = true; } if (selected) { var id = ExtractId(key.ToString()); var repo = new LookupRepository(); technologies.Add(repo.GetTechnology(id)); } } } return(technologies); }
private void Construct(Volunteer volunteer) { if (volunteer == null) { Volunteer = new Volunteer(); } else { Volunteer = volunteer; } var lookupRepository = new LookupRepository(); IQueryable <JobRole> roles = lookupRepository.GetAllJobRoles(); JobRoles = new SelectList(roles, "JobRoleID", "Description"); var levels = lookupRepository.GetAllExperienceLevels(); Experience = new SelectList(levels, "ExperienceLevelID", "Description"); var technologies = lookupRepository.GetAllTechnologies(); Technologies = new SelectList(technologies, "TechnologyID", "Description"); }
public virtual async Task <ActionResult <TParentResource> > Update(string id, TAlterResource resource) { var parent = await LookupRepository.Get(resource.ParentId); if (parent == null) { return(NotFound(resource.ParentId)); } if (!ParentManager.Exists(parent, id)) { return(NotFound(id)); } var validations = await ResourceValidator.ValidateUpdate(resource, parent); if (validations.Any()) { return(GetValidationResult(validations)); } var child = ParentManager.Get(parent, id); await AlterResourceMapper.MapUpdate(resource, child); ParentManager.Replace(parent, child, id); await AlterRepository.Update(parent); return(await ResourceMapper.Map(parent)); }
/// <summary> /// Generic method to support getting any Lookup entity type. /// This method uses the BaseLookupRepository directly /// </summary> /// <typeparam name="T"></typeparam> /// <param name="listName"></param> /// <returns></returns> private List <T> GetLookup <T>(string listName, string count) where T : IKPItem, new() { LookupRepository <T> repository = new LookupRepository <T>(this.spDataAccess, listName); List <T> items = repository.GetAllItems(count); return(items); }
public virtual async Task <ActionResult <IEnumerable <TResource> > > GetAll() { var entities = await LookupRepository.Get(); var response = await ResourceMapper.Map(entities); return(response.ToList()); }
public void SetUp() { _configurationWrapper = new ConfigurationWrapper(); _platformService = new PlatformServiceClient(); _ministryPlatformService = new MinistryPlatformServiceImpl(_platformService, _configurationWrapper); _lookupRepository = new LookupRepository(_fixture, _configurationWrapper, _ministryPlatformService); _fixture = new AuthenticationServiceImpl(_platformService, _ministryPlatformService); }
public virtual async Task <ActionResult <IEnumerable <TResource> > > GetAllOwned() { var entities = await LookupRepository.FindAll(e => e.UserId == CurrentUser.Id); var response = await ResourceMapper.Map(entities); return(response.ToList()); }
public override async Task <IEnumerable <StringKeyValuePair> > ValidateCreate(UserAlterResource createResource) { var validation = (await base.ValidateCreate(createResource)).ToList(); if (await LookupRepository.Exists(e => e.Email == createResource.Email)) { AddValidationAlreadyExists(validation, nameof(UserAlterResource.Email)); } return(validation); }
public FluentRecordBase AddRepoLookup() { if (_dbFactory == null) { AddDBFactory(); } _repoL = new LookupRepository(_dbFactory); return(this); }
public virtual async Task <ActionResult <TResource> > GetById(string id) { var entity = await LookupRepository.Get(id); if (entity == null) { return(NotFound(id)); } return(await ResourceMapper.Map(entity)); }
/// <summary> /// Initializes a new instance of the LookupService class. /// </summary> /// <param name="unitOfWork">UnitOfWork information</param> public LookupService(UnitOfWork unitOfWork) { if (unitOfWork == null) { throw new ArgumentNullException(UnitOfWorkConst); } this.unitOfWork = unitOfWork; this.lookUpRepository = new LookupRepository(this.unitOfWork); }
public void LoadCombo() { LookupRepository repository = new LookupRepository(); var items = repository.GetCompanies().Select(s => new ComboboxItem { Text = s.Name, Value = s.Company1.ToString() }).ToList(); comboBox1.DataSource = items; comboBox1.DisplayMember = "Text"; comboBox1.ValueMember = "Value"; }
public IEnumerable <ProductPhoto> GetProductPhotos() { //List<ProductPhotoVM> prodPhotos = new List<ProductPhotoVM>(); IEnumerable <ProductPhoto> prodPhotos = null; using (ILookupRepository lr = new LookupRepository(_context)) { prodPhotos = lr.GetLookup <ProductPhoto>(); } return(prodPhotos); }
private void LoadCombo() { LookupRepository _repository = new LookupRepository(); var items = _repository.GetContractors().Select(s => new ComboboxItem { Text = s.Name + " " + s.Surname, Value = s.ID.ToString() }).ToList(); comboBox1.DataSource = items; comboBox1.DisplayMember = "Text"; comboBox1.ValueMember = "Value"; }
private void LoadCombo() { LookupRepository repository = new LookupRepository(); var items = repository.GetMonths().Select(s => new ComboboxItem { Text = s.Name + " \t " + s.Year, Value = s.Month_ID.ToString() }).ToList(); comboBox1.DataSource = items; comboBox1.DisplayMember = "Text"; comboBox1.ValueMember = "Value"; }
private void LoadCombos() { LookupRepository repository = new LookupRepository(); var items = repository.GetPayrolls().Select(s => new ComboboxItem { Text = s.Name, Value = s.PayrollId.ToString() }).ToList(); comboBox1.DataSource = items; comboBox1.DisplayMember = "Text"; comboBox1.ValueMember = "Value"; }
public virtual async Task <ActionResult> Delete(string id) { var exists = await LookupRepository.Exists(id); if (!exists) { return(NotFound(id)); } await DeleteEntity(id); return(Ok()); }
public async virtual Task <ActionResult <TParentResource> > DeleteAll(string parentId) { var parent = await LookupRepository.Get(parentId); if (parent == null) { return(NotFound(parentId)); } ParentManager.RemoveAll(parent); await AlterRepository.Update(parent); return(await ResourceMapper.Map(parent)); }
/// <summary> /// Gets the lookup items. /// </summary> /// <param name="prefix">The prefix.</param> /// <param name="lookupName">Name of the lookup.</param> /// <param name="lookupcategory">The lookupcategory.</param> /// <returns></returns> public List <LookupItem> GetLookupItems(string prefix, string lookupName, string lookupcategory) { LookupRepository repo = new LookupRepository(); if (!string.IsNullOrEmpty(prefix)) { return(repo.GetFiltered(prefix, lookupName, lookupcategory)); } else { return(repo.GetAll(lookupName, lookupcategory).ToList()); } }
public virtual async Task <ActionResult <IEnumerable <TResource> > > GetByIds(string[] ids) { var entities = await LookupRepository.Get(ids); var notFoundId = ids.FirstOrDefault(id => !entities.Any(e => e.Id == id)); if (notFoundId != null) { return(NotFound(notFoundId)); } var response = await ResourceMapper.Map(entities); return(response.ToList()); }
public async Task <List <DropDown> > GetListByType(List <string> lookupTypes) { try { using (var lookupRepository = new LookupRepository(ApplicationDbContext.Create())) { return(await lookupRepository.GetListByType(lookupTypes)); } } catch (Exception ex) { //LogServices.Insert(ex); return(new List <DropDown>()); } }
private async Task <ActionResult <Dictionary <string, TParentEntity> > > GetParents(IEnumerable <string> parentsIds) { var parents = new Dictionary <string, TParentEntity>(); foreach (var parentsId in parentsIds) { var parnet = await LookupRepository.Get(parentsId); if (parnet == null) { return(NotFound(parentsId)); } parents.Add(parentsId, parnet); } return(parents); }
public async Task <ActionResult> Assign(string resourceId) { var entity = await LookupRepository.FindFirst(e => e.Id == resourceId); if (entity == null) { return(NotFound(resourceId)); } if (entity.UserId != null) { return(Unauthorized()); } entity.UserId = CurrentUser.Id; await AlterRepository.Update(entity); return(Ok()); }
/// <summary> /// Add or update the specified object /// </summary> /// <typeparam name="T"></typeparam> /// <param name="listName"></param> /// <param name="jsonData"></param> /// <returns></returns> private T SaveLookup <T>(string listName, string jsonData) where T : IKPItem, new() { T entity = JsonConvert.DeserializeObject <T>(jsonData); T item = default(T); LookupRepository <T> repository = new LookupRepository <T>(this.spDataAccess, listName); if (entity.KPID == -1 && entity.ID == -1) { item = repository.AddItem(entity); } else { item = repository.UpdateItem(entity); } return(item); }
public virtual async Task <ActionResult <TParentResource> > Delete(string parentId, string childId) { var parent = await LookupRepository.Get(parentId); if (parent == null) { return(NotFound(parentId)); } if (!ParentManager.Exists(parent, childId)) { return(NotFound(childId)); } ParentManager.Remove(parent, childId); await AlterRepository.Update(parent); return(await ResourceMapper.Map(parent)); }
public void ShouldReturnSites() { string _tokenValue = "ABC"; _authenticationService.Setup(m => m.Authenticate(It.IsAny <string>(), It.IsAny <string>())).Returns(new AuthToken { AccessToken = _tokenValue, ExpiresIn = 123 }); _fixture = new LookupRepository(_authenticationService.Object, _configurationWrapper.Object, _ministryPlatformService.Object); var sites = CrossroadsSites(); _ministryPlatformService.Setup(m => m.GetLookupRecords(It.IsAny <int>(), It.IsAny <String>())).Returns(sites); var returnVal = _fixture.CrossroadsLocations(); Assert.IsInstanceOf <List <Dictionary <string, object> > >(returnVal); Assert.AreEqual(sites.Count, returnVal.Count()); }
private void Construct(CharityRequirement charity) { if (charity == null) CharityRequirement = new CharityRequirement(); else CharityRequirement = charity; var lookupRepository = new LookupRepository(); var infrastructureTechnologies = lookupRepository.GetAllTechnologies(); InfrastructureTechnologies = new SelectList(infrastructureTechnologies, "TechnologyID", "Description"); SupportSkills = new SelectList(infrastructureTechnologies, "TechnologyID", "Description"); }
/// <summary> /// Function to retrieve current applicable date. /// </summary> /// <param name="isCheckTime">Value indicating whether to check time or not</param> /// <param name="currentDateTime">Current date time</param> /// <param name="userId">The user identifier.</param> /// <returns> /// Timesheet applicable date /// </returns> public DateTime RetrieveApplicableDate(bool isCheckTime, DateTime currentDateTime, int userId) { var applicationSettings = DependencyInjectionContainer.Instance.Container.Resolve<ApplicationSettings>(); var currentDate = currentDateTime.Date; var currentTime = currentDateTime.TimeOfDay; var lookupRepository = new LookupRepository(this.unitOfWork); var holidays = lookupRepository.RetrieveHolidaysV1(currentDate.Year, userId); if (!isCheckTime || currentTime.Hours < applicationSettings.PreviousDayTimesheetTime.Hours) { var isDateFound = false; currentDate = currentDate.AddDays(-1); do { if (currentDate.Date.DayOfWeek == DayOfWeek.Sunday || currentDate.Date.DayOfWeek == DayOfWeek.Saturday || holidays.Any(item => item.Date == currentDate)) { currentDate = currentDate.AddDays(-1); } else { isDateFound = true; } } while (!isDateFound); } return currentDate; }