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);
        }
Example #2
0
        public virtual ApiOffCapabilityClientRequestModel MapServerResponseToClientRequest(
            ApiOffCapabilityServerResponseModel response)
        {
            var request = new ApiOffCapabilityClientRequestModel();

            request.SetProperties(
                response.Name);
            return(request);
        }
Example #3
0
        public virtual ApiOffCapabilityServerResponseModel MapServerRequestToResponse(
            int id,
            ApiOffCapabilityServerRequestModel request)
        {
            var response = new ApiOffCapabilityServerResponseModel();

            response.SetProperties(id,
                                   request.Name);
            return(response);
        }
        public virtual ApiOffCapabilityServerResponseModel MapEntityToModel(
            OffCapability item)
        {
            var model = new ApiOffCapabilityServerResponseModel();

            model.SetProperties(item.Id,
                                item.Name);

            return(model);
        }
        public void MapEntityToModel()
        {
            var           mapper = new DALOffCapabilityMapper();
            OffCapability item   = new OffCapability();

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

            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
        }
Example #6
0
        public virtual async Task <UpdateResponse <ApiOffCapabilityServerResponseModel> > Update(
            int id,
            ApiOffCapabilityServerRequestModel model)
        {
            var validationResult = await this.OffCapabilityModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                OffCapability record = this.DalOffCapabilityMapper.MapModelToEntity(id, model);
                await this.OffCapabilityRepository.Update(record);

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

                ApiOffCapabilityServerResponseModel apiModel = this.DalOffCapabilityMapper.MapEntityToModel(record);
                await this.mediator.Publish(new OffCapabilityUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiOffCapabilityServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiOffCapabilityServerResponseModel> .UpdateResponse(validationResult));
            }
        }
 public OffCapabilityUpdatedNotification(ApiOffCapabilityServerResponseModel record)
 {
     this.Record = record;
 }
 public void SetCapabilityIdNavigation(ApiOffCapabilityServerResponseModel value)
 {
     this.CapabilityIdNavigation = value;
 }