Example #1
0
        public virtual ApiChainServerResponseModel MapEntityToModel(
            Chain item)
        {
            var model = new ApiChainServerResponseModel();

            model.SetProperties(item.Id,
                                item.ChainStatusId,
                                item.ExternalId,
                                item.Name,
                                item.TeamId);
            if (item.ChainStatusIdNavigation != null)
            {
                var chainStatusIdModel = new ApiChainStatusServerResponseModel();
                chainStatusIdModel.SetProperties(
                    item.ChainStatusIdNavigation.Id,
                    item.ChainStatusIdNavigation.Name);

                model.SetChainStatusIdNavigation(chainStatusIdModel);
            }

            if (item.TeamIdNavigation != null)
            {
                var teamIdModel = new ApiTeamServerResponseModel();
                teamIdModel.SetProperties(
                    item.TeamIdNavigation.Id,
                    item.TeamIdNavigation.Name,
                    item.TeamIdNavigation.OrganizationId);

                model.SetTeamIdNavigation(teamIdModel);
            }

            return(model);
        }
Example #2
0
        public virtual ApiTeamClientRequestModel MapServerResponseToClientRequest(
            ApiTeamServerResponseModel response)
        {
            var request = new ApiTeamClientRequestModel();

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

            response.SetProperties(id,
                                   request.Name,
                                   request.OrganizationId);
            return(response);
        }
Example #4
0
        public void MapEntityToModel()
        {
            var  mapper = new DALTeamMapper();
            Team item   = new Team();

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

            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
            response.OrganizationId.Should().Be(1);
        }
Example #5
0
        public virtual ApiTeamServerResponseModel MapEntityToModel(
            Team item)
        {
            var model = new ApiTeamServerResponseModel();

            model.SetProperties(item.Id,
                                item.Name,
                                item.OrganizationId);
            if (item.OrganizationIdNavigation != null)
            {
                var organizationIdModel = new ApiOrganizationServerResponseModel();
                organizationIdModel.SetProperties(
                    item.OrganizationIdNavigation.Id,
                    item.OrganizationIdNavigation.Name);

                model.SetOrganizationIdNavigation(organizationIdModel);
            }

            return(model);
        }
Example #6
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));
            }
        }
Example #7
0
 public TeamUpdatedNotification(ApiTeamServerResponseModel record)
 {
     this.Record = record;
 }
 public void SetTeamIdNavigation(ApiTeamServerResponseModel value)
 {
     this.TeamIdNavigation = value;
 }