Exemple #1
0
        public virtual ApiOfficerCapabilitiesServerRequestModel MapServerResponseToRequest(
            ApiOfficerCapabilitiesServerResponseModel response)
        {
            var request = new ApiOfficerCapabilitiesServerRequestModel();

            request.SetProperties(
                response.CapabilityId,
                response.OfficerId);
            return(request);
        }
Exemple #2
0
        public virtual ApiOfficerCapabilitiesServerResponseModel MapServerRequestToResponse(
            int id,
            ApiOfficerCapabilitiesServerRequestModel request)
        {
            var response = new ApiOfficerCapabilitiesServerResponseModel();

            response.SetProperties(id,
                                   request.CapabilityId,
                                   request.OfficerId);
            return(response);
        }
Exemple #3
0
        public void MapModelToEntity()
        {
            var mapper = new DALOfficerCapabilitiesMapper();
            ApiOfficerCapabilitiesServerRequestModel model = new ApiOfficerCapabilitiesServerRequestModel();

            model.SetProperties(1, 1);
            OfficerCapabilities response = mapper.MapModelToEntity(1, model);

            response.CapabilityId.Should().Be(1);
            response.OfficerId.Should().Be(1);
        }
        public virtual OfficerCapabilities MapModelToEntity(
            int id,
            ApiOfficerCapabilitiesServerRequestModel model
            )
        {
            OfficerCapabilities item = new OfficerCapabilities();

            item.SetProperties(
                id,
                model.CapabilityId,
                model.OfficerId);
            return(item);
        }
Exemple #5
0
        public virtual async Task <CreateResponse <ApiOfficerCapabilitiesServerResponseModel> > Create(
            ApiOfficerCapabilitiesServerRequestModel model)
        {
            CreateResponse <ApiOfficerCapabilitiesServerResponseModel> response = ValidationResponseFactory <ApiOfficerCapabilitiesServerResponseModel> .CreateResponse(await this.OfficerCapabilitiesModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                OfficerCapabilities record = this.DalOfficerCapabilitiesMapper.MapModelToEntity(default(int), model);
                record = await this.OfficerCapabilitiesRepository.Create(record);

                response.SetRecord(this.DalOfficerCapabilitiesMapper.MapEntityToModel(record));
                await this.mediator.Publish(new OfficerCapabilitiesCreatedNotification(response.Record));
            }

            return(response);
        }
Exemple #6
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));
            }
        }
Exemple #7
0
        public JsonPatchDocument <ApiOfficerCapabilitiesServerRequestModel> CreatePatch(ApiOfficerCapabilitiesServerRequestModel model)
        {
            var patch = new JsonPatchDocument <ApiOfficerCapabilitiesServerRequestModel>();

            patch.Replace(x => x.CapabilityId, model.CapabilityId);
            patch.Replace(x => x.OfficerId, model.OfficerId);
            return(patch);
        }