Example #1
0
        public static RecordingSummaryVM ToSummaryVM(this RecordingDTO dto)
        {
            string title;

            if (dto.Title == null || dto.Title == "")
            {
                title = "No description";
            }
            else
            {
                title = dto.Title;
            }

            var projectName = dto.Project != null ?
                              dto.Project.Name != null ? dto.Project.Name
                : "Unnamed Project" : "No Project Chosen";

            var color = dto.Project == null || dto.Project.Color == null ?
                        new SolidColorBrush(Colors.LightGray) : new SolidColorBrush(dto.Project.Color);
            string elapsed = "";

            if (dto.End != null)
            {
                elapsed = (dto.End.Value - dto.Start).ToHHMMSS();
            }
            return(new RecordingSummaryVM
            {
                Id = dto.Id,
                Title = title,
                ProjectName = projectName,
                ProjectColor = color,
                Duration = elapsed
            });
        }
Example #2
0
        private RecordingDTO[] RecordingToDTO(RecordingList[] recordingList)
        {
            RecordingDTO[] recordingDTO = new RecordingDTO[recordingList.Length];

            for (int i = 0; i < recordingList.Length; i++)
            {
                var item = recordingList[i].Recording;

                QuestionGroupDTO[] questiongroupDTO = new QuestionGroupDTO[item.QuestionGroups.Count];
                for (int j = 0; j < item.QuestionGroups.Count; j++)
                {
                    var source = item.QuestionGroups.ElementAt(j);
                    questiongroupDTO[j] = new QuestionGroupDTO
                    {
                        QuestionNoStart  = source.QuestionNoStart,
                        QuestionNoEnd    = source.QuestionNoEnd,
                        QuestionGroupId  = source.QuestionGroupId,
                        QuestionGroupURL = '/' + source.QuestionGroupURL,
                        TaskType         = source.TaskType,
                    };
                }

                recordingDTO[i] = new RecordingDTO
                {
                    RecordingId    = item.RecordingId,
                    Title          = item.Title,
                    Part           = item.Part,
                    AudioURL       = "/Storage/AudioRecordings/Part" + item.Part + "/" + item.AudioURL,
                    QuestionGroups = questiongroupDTO,
                };
            }

            return(recordingDTO);
        }
Example #3
0
        public static List <RecordingDTO> CreateThreeRecordingDTOs()
        {
            var r1 = new RecordingDTO
            {
                Id          = 1,
                Start       = DateTime.Parse("16-03-2019") - TimeSpan.FromHours(13),
                End         = DateTime.Parse("16-03-2019") - TimeSpan.FromHours(12),
                ProjectId   = 1,
                TemporaryId = 2,
                Title       = "Test title one",
            };
            var r2 = new RecordingDTO
            {
                Id          = 2,
                Start       = DateTime.Parse("17-03-2019") - TimeSpan.FromHours(8),
                End         = DateTime.Parse("17-03-2019") - TimeSpan.FromHours(4),
                ProjectId   = 2,
                TemporaryId = 3,
                Title       = "Test title two",
            };

            var r3 = new RecordingDTO
            {
                Id          = 3,
                Start       = DateTime.Parse("18-03-2019") - TimeSpan.FromHours(5),
                End         = DateTime.Parse("18-03-2019") - TimeSpan.FromHours(3),
                ProjectId   = 3,
                TemporaryId = 4,
                Title       = "Test title three",
            };

            return(new List <RecordingDTO> {
                r1, r2, r3
            });
        }
        private Mock <IRecordingStrategy> createTestFindRecordingStrategy(RecordingDTO dto)
        {
            var recordingRepo = new Mock <IRecordingRepository>();

            recordingRepo.Setup(m => m.FindAsync(It.IsAny <int>())).ReturnsAsync(dto);

            var recordingStrategy = new Mock <IRecordingStrategy>();

            recordingStrategy.Setup(m => m.CreateRepository(It.IsAny <StorageStrategy>())).Returns(recordingRepo.Object);

            return(recordingStrategy);
        }
Example #5
0
 public static Shared.RecordingDTO ToDTO(this RecordingDTO localEntity)
 {
     return(new Shared.RecordingDTO
     {
         Id = localEntity.Id,
         TemporaryId = localEntity.TemporaryId,
         Title = localEntity.Title,
         Start = localEntity.Start,
         End = localEntity.End,
         ProjectId = localEntity.ProjectId,
         Project = localEntity.Project.ToDTO(),
     });
 }
Example #6
0
        public async Task <bool> RecordPosition(RecordingDTO model)
        {
            if (model != null)
            {
                var location = new Location()
                {
                    DeviceID  = model.DeviceID,
                    Latitude  = model.Latitude,
                    Longitude = model.Longitude
                };

                _uow.LocationRepository.Create(location);
                var result = await _uow.SaveChanges();

                if (result > 0)
                {
                    return(true);
                }
            }

            return(false);
        }
Example #7
0
        public async Task <IActionResult> Record(RecordingDTO model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    _logger.LogError("Model validation failed.");
                    return(BadRequest(ModelState));
                }

                // ensure a device or user cannot update the position of another vehicle
                var canRecord = await _registrationService.CanRecordPosition(model.UserID, model.DeviceID);

                if (!canRecord)
                {
                    _logger.LogError("User or Device has not a permission to record this Location.");
                    return(BadRequest("User or Device has not a permission to record this Location."));
                }

                bool result = await _trackingService.RecordPosition(model);

                if (result)
                {
                    _logger.LogInformation("Position Recorded.");
                    return(Ok(true));
                }
                else
                {
                    _logger.LogInformation("Error Occured");
                    return(Ok(false));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(BadRequest("Error Occured"));
            }
        }
Example #8
0
 public Timer(RecordingDTO dto)
 {
     this.dto = dto;
 }