/// <summary> /// Gets all companies /// </summary> /// <param name="status">A value indicating which status records</param> /// <returns>Company collection</returns> public virtual IList<Company> GetAll(PublishingStatus status = PublishingStatus.Active) { string key = string.Format(COMPANY_ALL_KEY, status.ToString()); return this.cacheManager.Get(key, () => { var query = from c in this.companyRepository.Table orderby c.CompanyName where (status == PublishingStatus.All || c.CurrentPublishingStatusId == (int)status) select c; var companies = query.ToList(); return companies; }); }
public void GetLatestService(PublishingStatus publishingStatus) { // Arrange var item = _list.Where(i => i.PublishingStatusId == PublishingStatusCache.Get(publishingStatus)).FirstOrDefault(); var rootId = item.UnificRootId; var id = item.Id; VersioningManagerMock.Setup(s => s.GetVersionId <ServiceVersioned>(unitOfWorkMockSetup.Object, rootId, null, false)).Returns(id); var service = Arrange(); // Act var result = service.GetServiceById(rootId, 7, VersionStatusEnum.Latest); // Assert result.Should().NotBeNull(); var vmResult = Assert.IsType <V7VmOpenApiService>(result); vmResult.PublishingStatus.Should().Be(publishingStatus.ToString()); VersioningManagerMock.Verify(x => x.GetVersionId <ServiceVersioned>(unitOfWorkMockSetup.Object, rootId, null, false), Times.Once); }
public void GetLatestActiveServiceChannel(PublishingStatus publishingStatus) { // Arrange var channelType = ServiceChannelTypeEnum.ServiceLocation; var item = _channelList.Where(i => i.PublishingStatusId == PublishingStatusCache.Get(publishingStatus)).FirstOrDefault(); item.TypeId = TypeCache.Get <ServiceChannelType>(channelType.ToString()); var rootId = item.UnificRootId; var id = item.Id; VersioningManagerMock.Setup(s => s.GetVersionId <ServiceChannelVersioned>(unitOfWorkMockSetup.Object, rootId, null, true)) .Returns(() => { if (publishingStatus == PublishingStatus.Deleted || publishingStatus == PublishingStatus.OldPublished) { return(null); } return(id); }); var service = Arrange(channelType); // Act var result = service.GetServiceChannelById(rootId, 7, VersionStatusEnum.LatestActive); // Assert // Method should only return draft, modified or published versions. VersioningManagerMock.Verify(x => x.GetVersionId <ServiceChannelVersioned>(unitOfWorkMockSetup.Object, rootId, null, true), Times.Once); if (publishingStatus == PublishingStatus.Draft || publishingStatus == PublishingStatus.Modified || publishingStatus == PublishingStatus.Published) { result.Should().NotBeNull(); var vmResult = Assert.IsType <V7VmOpenApiServiceLocationChannel>(result); vmResult.PublishingStatus.Should().Be(publishingStatus.ToString()); } else { result.Should().BeNull(); } }
protected IList<SelectListItem> PrepareSelectList(IBranchOfficeService officeService, ICacheManager cacheManager, PublishingStatus status = PublishingStatus.Active) { string cacheKey = ModelCacheEventUser.OFFICE_MODEL_KEY.FormatWith( "SelectList.{0}".FormatWith(status.ToString())); var cacheModel = cacheManager.Get(cacheKey, () => { var offices = officeService.GetAll(status) .Select(office => { return new SelectListItem() { Value = office.RowId.ToString(), Text = office.BranchName }; }) .ToList(); return offices; }); return cacheModel; }
protected IList<SelectListItem> PrepareSelectList(IUserService userService, ICacheManager cacheManager, Guid selectedUserId, PublishingStatus status = PublishingStatus.Active) { string cacheKey = ModelCacheEventUser.USERS_MODEL_KEY.FormatWith( "SelectList.{0}".FormatWith(status.ToString())); var cacheModel = cacheManager.Get(cacheKey, () => { var users = userService.GetAll(status) .Select(user => { return new SelectListItem() { Value = user.RowId.ToString(), Text = user.GetFullName(), Selected = user.RowId.Equals(selectedUserId) }; }) .ToList(); return users; }); return cacheModel; }
/// <summary> /// Gets all branch offices /// </summary> /// <returns>Office collection</returns> public virtual IList<BranchOffice> GetAll(PublishingStatus status = PublishingStatus.Active) { string key = string.Format(BRANCHOFFICE_ALL_KEY, status.ToString()); return this.cacheManager.Get(key, () => { var query = from c in this.dataRepository.Table orderby c.BranchName where (status == PublishingStatus.All || c.CurrentPublishingStatusId == (int)status) select c; var offices = query.ToList(); return offices; }); }
public Guid Get(PublishingStatus publishingStatus) { return(Get(publishingStatus.ToString())); }