public MyFeelsQueryResult Handle(MyFeelsQuery query) { try { var events = new List <FIL.Contracts.Models.Creator.MyFeel>(); if (query.IsApproveModerateScreen) { events = _eventRepository.GetApproveModerateFeels(query.IsActive).Take(500).ToList(); } else { events = _eventRepository.GetMyFeels(query.CreatedBy).Take(500).ToList(); } var steps = _stepRepository.GetAll().ToList(); var stepDetails = _stepDetailsRepository.GetAll().Where(s => s.MasterEventTypeId == Contracts.Enums.MasterEventType.Online && s.IsEnabled).OrderBy(s => s.Id).ToList(); foreach (var currentFeel in events) { if (currentFeel.EventEndDateTime < DateTime.UtcNow) { currentFeel.IsPastEvent = true; } if (!String.IsNullOrEmpty(currentFeel.TimeZoneOffset)) { currentFeel.EventStartDateTime = _localTimeZoneConvertProvider.ConvertToLocal(currentFeel.EventStartDateTime, currentFeel.TimeZoneOffset); currentFeel.EventEndDateTime = _localTimeZoneConvertProvider.ConvertToLocal(currentFeel.EventEndDateTime, currentFeel.TimeZoneOffset); } currentFeel.EventStartDateTimeString = currentFeel.EventStartDateTime.ToString("MMM dd, yyyy HH:mm").ToUpper(); currentFeel.EventEndDateTimeString = currentFeel.EventEndDateTime.ToString("MMM dd, yyyy HH:mm").ToUpper(); if (currentFeel.CompletedStep != null && !query.IsApproveModerateScreen) { var currentStep = GetCurrentTab(stepDetails, currentFeel.CompletedStep); if (currentStep != 0) { currentFeel.CurrentStep = steps.Where(s => s.Id == stepDetails.Where(p => p.Id == currentStep).FirstOrDefault().StepId).FirstOrDefault().Name; currentFeel.IsShowExclamationIcon = true; } } } return(new MyFeelsQueryResult { MyFeels = events, Success = true }); } catch (Exception e) { return(new MyFeelsQueryResult { Success = true }); } }
public async Task <GetAllStepsResponse> Get(GetAllStepsRequest request) { if (!await batchRepository.DoesBatchExist(request.BatchId)) { throw Err.BatchNotFound(request.BatchId); } var steps = await stepRepository.GetAll(request.BatchId); return(new GetAllStepsResponse { Steps = steps.ConvertTo <List <DomainModels.Step> >() }); }
public async Task It_Should_Get_All_Steps() { // Arrange batchRepository.DoesBatchExist(Arg.Any <string>()) .Returns(true); var steps = TestData.Entities.Batches.FullyPopulated.Steps; stepRepository.GetAll(Arg.Any <string>()).Returns(steps); var request = new GetAllStepsRequest { BatchId = TestBatchId, }; // Act var response = await Sut.Get(request); // Assert response.Steps.Should().BeEquivalentTo(TestData.DomainModels.Batches.FullyPopulated.Steps); }
public IEnumerable <StepView> GetAll(long id) { return(_step.GetAll(id)); }