public virtual ApiDeviceClientRequestModel MapServerResponseToClientRequest(
            ApiDeviceServerResponseModel response)
        {
            var request = new ApiDeviceClientRequestModel();

            request.SetProperties(
                response.DateOfLastPing,
                response.IsActive,
                response.Name,
                response.PublicId);
            return(request);
        }
Esempio n. 2
0
        public virtual ApiDeviceServerResponseModel MapEntityToModel(
            Device item)
        {
            var model = new ApiDeviceServerResponseModel();

            model.SetProperties(item.Id,
                                item.DateOfLastPing,
                                item.IsActive,
                                item.Name,
                                item.PublicId);

            return(model);
        }
        public virtual ApiDeviceServerResponseModel MapServerRequestToResponse(
            int id,
            ApiDeviceServerRequestModel request)
        {
            var response = new ApiDeviceServerResponseModel();

            response.SetProperties(id,
                                   request.DateOfLastPing,
                                   request.IsActive,
                                   request.Name,
                                   request.PublicId);
            return(response);
        }
Esempio n. 4
0
        public void MapEntityToModel()
        {
            var    mapper = new DALDeviceMapper();
            Device item   = new Device();

            item.SetProperties(1, DateTime.Parse("1/1/1987 12:00:00 AM"), true, "A", Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
            ApiDeviceServerResponseModel response = mapper.MapEntityToModel(item);

            response.DateOfLastPing.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.Id.Should().Be(1);
            response.IsActive.Should().Be(true);
            response.Name.Should().Be("A");
            response.PublicId.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
        }
Esempio n. 5
0
        public virtual async Task <UpdateResponse <ApiDeviceServerResponseModel> > Update(
            int id,
            ApiDeviceServerRequestModel model)
        {
            var validationResult = await this.DeviceModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                Device record = this.DalDeviceMapper.MapModelToEntity(id, model);
                await this.DeviceRepository.Update(record);

                record = await this.DeviceRepository.Get(id);

                ApiDeviceServerResponseModel apiModel = this.DalDeviceMapper.MapEntityToModel(record);
                await this.mediator.Publish(new DeviceUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiDeviceServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiDeviceServerResponseModel> .UpdateResponse(validationResult));
            }
        }
Esempio n. 6
0
        public virtual ApiDeviceActionServerResponseModel MapEntityToModel(
            DeviceAction item)
        {
            var model = new ApiDeviceActionServerResponseModel();

            model.SetProperties(item.Id,
                                item.Action,
                                item.DeviceId,
                                item.Name);
            if (item.DeviceIdNavigation != null)
            {
                var deviceIdModel = new ApiDeviceServerResponseModel();
                deviceIdModel.SetProperties(
                    item.DeviceIdNavigation.Id,
                    item.DeviceIdNavigation.DateOfLastPing,
                    item.DeviceIdNavigation.IsActive,
                    item.DeviceIdNavigation.Name,
                    item.DeviceIdNavigation.PublicId);

                model.SetDeviceIdNavigation(deviceIdModel);
            }

            return(model);
        }
Esempio n. 7
0
 public DeviceUpdatedNotification(ApiDeviceServerResponseModel record)
 {
     this.Record = record;
 }
 public void SetDeviceIdNavigation(ApiDeviceServerResponseModel value)
 {
     this.DeviceIdNavigation = value;
 }