public virtual ApiOfficerCapabilitiesServerResponseModel MapEntityToModel(
            OfficerCapabilities item)
        {
            var model = new ApiOfficerCapabilitiesServerResponseModel();

            model.SetProperties(item.Id,
                                item.CapabilityId,
                                item.OfficerId);
            if (item.CapabilityIdNavigation != null)
            {
                var capabilityIdModel = new ApiOffCapabilityServerResponseModel();
                capabilityIdModel.SetProperties(
                    item.CapabilityIdNavigation.Id,
                    item.CapabilityIdNavigation.Name);

                model.SetCapabilityIdNavigation(capabilityIdModel);
            }

            if (item.OfficerIdNavigation != null)
            {
                var officerIdModel = new ApiOfficerServerResponseModel();
                officerIdModel.SetProperties(
                    item.OfficerIdNavigation.Id,
                    item.OfficerIdNavigation.Badge,
                    item.OfficerIdNavigation.Email,
                    item.OfficerIdNavigation.FirstName,
                    item.OfficerIdNavigation.LastName,
                    item.OfficerIdNavigation.Password);

                model.SetOfficerIdNavigation(officerIdModel);
            }

            return(model);
        }
Пример #2
0
        public virtual ApiUnitOfficerServerResponseModel MapEntityToModel(
            UnitOfficer item)
        {
            var model = new ApiUnitOfficerServerResponseModel();

            model.SetProperties(item.Id,
                                item.OfficerId,
                                item.UnitId);
            if (item.OfficerIdNavigation != null)
            {
                var officerIdModel = new ApiOfficerServerResponseModel();
                officerIdModel.SetProperties(
                    item.OfficerIdNavigation.Id,
                    item.OfficerIdNavigation.Badge,
                    item.OfficerIdNavigation.Email,
                    item.OfficerIdNavigation.FirstName,
                    item.OfficerIdNavigation.LastName,
                    item.OfficerIdNavigation.Password);

                model.SetOfficerIdNavigation(officerIdModel);
            }

            if (item.UnitIdNavigation != null)
            {
                var unitIdModel = new ApiUnitServerResponseModel();
                unitIdModel.SetProperties(
                    item.UnitIdNavigation.Id,
                    item.UnitIdNavigation.CallSign);

                model.SetUnitIdNavigation(unitIdModel);
            }

            return(model);
        }
Пример #3
0
        public virtual ApiVehicleOfficerServerResponseModel MapEntityToModel(
            VehicleOfficer item)
        {
            var model = new ApiVehicleOfficerServerResponseModel();

            model.SetProperties(item.Id,
                                item.OfficerId,
                                item.VehicleId);
            if (item.OfficerIdNavigation != null)
            {
                var officerIdModel = new ApiOfficerServerResponseModel();
                officerIdModel.SetProperties(
                    item.OfficerIdNavigation.Id,
                    item.OfficerIdNavigation.Badge,
                    item.OfficerIdNavigation.Email,
                    item.OfficerIdNavigation.FirstName,
                    item.OfficerIdNavigation.LastName,
                    item.OfficerIdNavigation.Password);

                model.SetOfficerIdNavigation(officerIdModel);
            }

            if (item.VehicleIdNavigation != null)
            {
                var vehicleIdModel = new ApiVehicleServerResponseModel();
                vehicleIdModel.SetProperties(
                    item.VehicleIdNavigation.Id,
                    item.VehicleIdNavigation.Name);

                model.SetVehicleIdNavigation(vehicleIdModel);
            }

            return(model);
        }
Пример #4
0
        public virtual ApiOfficerClientRequestModel MapServerResponseToClientRequest(
            ApiOfficerServerResponseModel response)
        {
            var request = new ApiOfficerClientRequestModel();

            request.SetProperties(
                response.Badge,
                response.Email,
                response.FirstName,
                response.LastName,
                response.Password);
            return(request);
        }
Пример #5
0
        public virtual ApiOfficerServerResponseModel MapEntityToModel(
            Officer item)
        {
            var model = new ApiOfficerServerResponseModel();

            model.SetProperties(item.Id,
                                item.Badge,
                                item.Email,
                                item.FirstName,
                                item.LastName,
                                item.Password);

            return(model);
        }
Пример #6
0
        public virtual ApiOfficerServerResponseModel MapServerRequestToResponse(
            int id,
            ApiOfficerServerRequestModel request)
        {
            var response = new ApiOfficerServerResponseModel();

            response.SetProperties(id,
                                   request.Badge,
                                   request.Email,
                                   request.FirstName,
                                   request.LastName,
                                   request.Password);
            return(response);
        }
Пример #7
0
        public void MapEntityToModel()
        {
            var     mapper = new DALOfficerMapper();
            Officer item   = new Officer();

            item.SetProperties(1, "A", "A", "A", "A", "A");
            ApiOfficerServerResponseModel response = mapper.MapEntityToModel(item);

            response.Badge.Should().Be("A");
            response.Email.Should().Be("A");
            response.FirstName.Should().Be("A");
            response.Id.Should().Be(1);
            response.LastName.Should().Be("A");
            response.Password.Should().Be("A");
        }
Пример #8
0
        public virtual ApiNoteServerResponseModel MapEntityToModel(
            Note item)
        {
            var model = new ApiNoteServerResponseModel();

            model.SetProperties(item.Id,
                                item.CallId,
                                item.DateCreated,
                                item.NoteText,
                                item.OfficerId);
            if (item.CallIdNavigation != null)
            {
                var callIdModel = new ApiCallServerResponseModel();
                callIdModel.SetProperties(
                    item.CallIdNavigation.Id,
                    item.CallIdNavigation.AddressId,
                    item.CallIdNavigation.CallDispositionId,
                    item.CallIdNavigation.CallStatusId,
                    item.CallIdNavigation.CallString,
                    item.CallIdNavigation.CallTypeId,
                    item.CallIdNavigation.DateCleared,
                    item.CallIdNavigation.DateCreated,
                    item.CallIdNavigation.DateDispatched,
                    item.CallIdNavigation.QuickCallNumber);

                model.SetCallIdNavigation(callIdModel);
            }

            if (item.OfficerIdNavigation != null)
            {
                var officerIdModel = new ApiOfficerServerResponseModel();
                officerIdModel.SetProperties(
                    item.OfficerIdNavigation.Id,
                    item.OfficerIdNavigation.Badge,
                    item.OfficerIdNavigation.Email,
                    item.OfficerIdNavigation.FirstName,
                    item.OfficerIdNavigation.LastName,
                    item.OfficerIdNavigation.Password);

                model.SetOfficerIdNavigation(officerIdModel);
            }

            return(model);
        }
Пример #9
0
        public virtual async Task <UpdateResponse <ApiOfficerServerResponseModel> > Update(
            int id,
            ApiOfficerServerRequestModel model)
        {
            var validationResult = await this.OfficerModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                Officer record = this.DalOfficerMapper.MapModelToEntity(id, model);
                await this.OfficerRepository.Update(record);

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

                ApiOfficerServerResponseModel apiModel = this.DalOfficerMapper.MapEntityToModel(record);
                await this.mediator.Publish(new OfficerUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiOfficerServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiOfficerServerResponseModel> .UpdateResponse(validationResult));
            }
        }
 public void SetOfficerIdNavigation(ApiOfficerServerResponseModel value)
 {
     this.OfficerIdNavigation = value;
 }
Пример #11
0
 public OfficerUpdatedNotification(ApiOfficerServerResponseModel record)
 {
     this.Record = record;
 }