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 ApiOfficerCapabilitiesClientRequestModel MapServerResponseToClientRequest(
            ApiOfficerCapabilitiesServerResponseModel response)
        {
            var request = new ApiOfficerCapabilitiesClientRequestModel();

            request.SetProperties(
                response.CapabilityId,
                response.OfficerId);
            return(request);
        }
Пример #3
0
        public virtual ApiOfficerCapabilitiesServerResponseModel MapServerRequestToResponse(
            int id,
            ApiOfficerCapabilitiesServerRequestModel request)
        {
            var response = new ApiOfficerCapabilitiesServerResponseModel();

            response.SetProperties(id,
                                   request.CapabilityId,
                                   request.OfficerId);
            return(response);
        }
Пример #4
0
        public void MapEntityToModel()
        {
            var mapper = new DALOfficerCapabilitiesMapper();
            OfficerCapabilities item = new OfficerCapabilities();

            item.SetProperties(1, 1, 1);
            ApiOfficerCapabilitiesServerResponseModel response = mapper.MapEntityToModel(item);

            response.CapabilityId.Should().Be(1);
            response.Id.Should().Be(1);
            response.OfficerId.Should().Be(1);
        }
Пример #5
0
        public virtual async Task <UpdateResponse <ApiOfficerCapabilitiesServerResponseModel> > Update(
            int id,
            ApiOfficerCapabilitiesServerRequestModel model)
        {
            var validationResult = await this.OfficerCapabilitiesModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                OfficerCapabilities record = this.DalOfficerCapabilitiesMapper.MapModelToEntity(id, model);
                await this.OfficerCapabilitiesRepository.Update(record);

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

                ApiOfficerCapabilitiesServerResponseModel apiModel = this.DalOfficerCapabilitiesMapper.MapEntityToModel(record);
                await this.mediator.Publish(new OfficerCapabilitiesUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiOfficerCapabilitiesServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiOfficerCapabilitiesServerResponseModel> .UpdateResponse(validationResult));
            }
        }
 public OfficerCapabilitiesUpdatedNotification(ApiOfficerCapabilitiesServerResponseModel record)
 {
     this.Record = record;
 }