Exemplo n.º 1
0
        public JsonPatchDocument <ApiTeamServerRequestModel> CreatePatch(ApiTeamServerRequestModel model)
        {
            var patch = new JsonPatchDocument <ApiTeamServerRequestModel>();

            patch.Replace(x => x.Name, model.Name);
            patch.Replace(x => x.OrganizationId, model.OrganizationId);
            return(patch);
        }
Exemplo n.º 2
0
        public virtual ApiTeamServerRequestModel MapServerResponseToRequest(
            ApiTeamServerResponseModel response)
        {
            var request = new ApiTeamServerRequestModel();

            request.SetProperties(
                response.Name,
                response.OrganizationId);
            return(request);
        }
Exemplo n.º 3
0
        public virtual ApiTeamServerResponseModel MapServerRequestToResponse(
            int id,
            ApiTeamServerRequestModel request)
        {
            var response = new ApiTeamServerResponseModel();

            response.SetProperties(id,
                                   request.Name,
                                   request.OrganizationId);
            return(response);
        }
Exemplo n.º 4
0
        public void MapModelToEntity()
        {
            var mapper = new DALTeamMapper();
            ApiTeamServerRequestModel model = new ApiTeamServerRequestModel();

            model.SetProperties("A", 1);
            Team response = mapper.MapModelToEntity(1, model);

            response.Name.Should().Be("A");
            response.OrganizationId.Should().Be(1);
        }
Exemplo n.º 5
0
        public virtual Team MapModelToEntity(
            int id,
            ApiTeamServerRequestModel model
            )
        {
            Team item = new Team();

            item.SetProperties(
                id,
                model.Name,
                model.OrganizationId);
            return(item);
        }
Exemplo n.º 6
0
        public virtual async Task <CreateResponse <ApiTeamServerResponseModel> > Create(
            ApiTeamServerRequestModel model)
        {
            CreateResponse <ApiTeamServerResponseModel> response = ValidationResponseFactory <ApiTeamServerResponseModel> .CreateResponse(await this.TeamModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                Team record = this.DalTeamMapper.MapModelToEntity(default(int), model);
                record = await this.TeamRepository.Create(record);

                response.SetRecord(this.DalTeamMapper.MapEntityToModel(record));
                await this.mediator.Publish(new TeamCreatedNotification(response.Record));
            }

            return(response);
        }
Exemplo n.º 7
0
        public virtual async Task <UpdateResponse <ApiTeamServerResponseModel> > Update(
            int id,
            ApiTeamServerRequestModel model)
        {
            var validationResult = await this.TeamModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                Team record = this.DalTeamMapper.MapModelToEntity(id, model);
                await this.TeamRepository.Update(record);

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

                ApiTeamServerResponseModel apiModel = this.DalTeamMapper.MapEntityToModel(record);
                await this.mediator.Publish(new TeamUpdatedNotification(apiModel));

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