public JsonPatchDocument <ApiRateServerRequestModel> CreatePatch(ApiRateServerRequestModel model)
        {
            var patch = new JsonPatchDocument <ApiRateServerRequestModel>();

            patch.Replace(x => x.AmountPerMinute, model.AmountPerMinute);
            patch.Replace(x => x.TeacherId, model.TeacherId);
            patch.Replace(x => x.TeacherSkillId, model.TeacherSkillId);
            return(patch);
        }
        public virtual ApiRateServerRequestModel MapServerResponseToRequest(
            ApiRateServerResponseModel response)
        {
            var request = new ApiRateServerRequestModel();

            request.SetProperties(
                response.AmountPerMinute,
                response.TeacherId,
                response.TeacherSkillId);
            return(request);
        }
        public virtual ApiRateServerResponseModel MapServerRequestToResponse(
            int id,
            ApiRateServerRequestModel request)
        {
            var response = new ApiRateServerResponseModel();

            response.SetProperties(id,
                                   request.AmountPerMinute,
                                   request.TeacherId,
                                   request.TeacherSkillId);
            return(response);
        }
Esempio n. 4
0
        public void MapModelToEntity()
        {
            var mapper = new DALRateMapper();
            ApiRateServerRequestModel model = new ApiRateServerRequestModel();

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

            response.AmountPerMinute.Should().Be(1m);
            response.TeacherId.Should().Be(1);
            response.TeacherSkillId.Should().Be(1);
        }
Esempio n. 5
0
        public virtual Rate MapModelToEntity(
            int id,
            ApiRateServerRequestModel model
            )
        {
            Rate item = new Rate();

            item.SetProperties(
                id,
                model.AmountPerMinute,
                model.TeacherId,
                model.TeacherSkillId);
            return(item);
        }
Esempio n. 6
0
        public virtual async Task <CreateResponse <ApiRateServerResponseModel> > Create(
            ApiRateServerRequestModel model)
        {
            CreateResponse <ApiRateServerResponseModel> response = ValidationResponseFactory <ApiRateServerResponseModel> .CreateResponse(await this.RateModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                Rate record = this.DalRateMapper.MapModelToEntity(default(int), model);
                record = await this.RateRepository.Create(record);

                response.SetRecord(this.DalRateMapper.MapEntityToModel(record));
                await this.mediator.Publish(new RateCreatedNotification(response.Record));
            }

            return(response);
        }
Esempio n. 7
0
        public virtual async Task <UpdateResponse <ApiRateServerResponseModel> > Update(
            int id,
            ApiRateServerRequestModel model)
        {
            var validationResult = await this.RateModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                Rate record = this.DalRateMapper.MapModelToEntity(id, model);
                await this.RateRepository.Update(record);

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

                ApiRateServerResponseModel apiModel = this.DalRateMapper.MapEntityToModel(record);
                await this.mediator.Publish(new RateUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiRateServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiRateServerResponseModel> .UpdateResponse(validationResult));
            }
        }