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

            model.SetProperties(item.Id,
                                item.Address1,
                                item.Address2,
                                item.CityId,
                                item.Date,
                                item.Description,
                                item.EndDate,
                                item.Facebook,
                                item.Name,
                                item.StartDate,
                                item.Website);
            if (item.CityIdNavigation != null)
            {
                var cityIdModel = new ApiCityServerResponseModel();
                cityIdModel.SetProperties(
                    item.CityIdNavigation.Id,
                    item.CityIdNavigation.Name,
                    item.CityIdNavigation.ProvinceId);

                model.SetCityIdNavigation(cityIdModel);
            }

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

            request.SetProperties(
                response.Address1,
                response.Address2,
                response.CityId,
                response.Date,
                response.Description,
                response.EndDate,
                response.Facebook,
                response.Name,
                response.StartDate,
                response.Website);
            return(request);
        }
Example #3
0
        public virtual ApiEventServerResponseModel MapServerRequestToResponse(
            int id,
            ApiEventServerRequestModel request)
        {
            var response = new ApiEventServerResponseModel();

            response.SetProperties(id,
                                   request.Address1,
                                   request.Address2,
                                   request.CityId,
                                   request.Date,
                                   request.Description,
                                   request.EndDate,
                                   request.Facebook,
                                   request.Name,
                                   request.StartDate,
                                   request.Website);
            return(response);
        }
Example #4
0
        public void MapEntityToModel()
        {
            var   mapper = new DALEventMapper();
            Event item   = new Event();

            item.SetProperties(1, "A", "A", 1, DateTime.Parse("1/1/1987 12:00:00 AM"), "A", DateTime.Parse("1/1/1987 12:00:00 AM"), "A", "A", DateTime.Parse("1/1/1987 12:00:00 AM"), "A");
            ApiEventServerResponseModel response = mapper.MapEntityToModel(item);

            response.Address1.Should().Be("A");
            response.Address2.Should().Be("A");
            response.CityId.Should().Be(1);
            response.Date.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.Description.Should().Be("A");
            response.EndDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.Facebook.Should().Be("A");
            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
            response.StartDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.Website.Should().Be("A");
        }
Example #5
0
        public virtual async Task <UpdateResponse <ApiEventServerResponseModel> > Update(
            int id,
            ApiEventServerRequestModel model)
        {
            var validationResult = await this.EventModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                Event record = this.DalEventMapper.MapModelToEntity(id, model);
                await this.EventRepository.Update(record);

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

                ApiEventServerResponseModel apiModel = this.DalEventMapper.MapEntityToModel(record);
                await this.mediator.Publish(new EventUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiEventServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiEventServerResponseModel> .UpdateResponse(validationResult));
            }
        }
Example #6
0
 public EventUpdatedNotification(ApiEventServerResponseModel record)
 {
     this.Record = record;
 }