Exemplo n.º 1
0
        public virtual ApiUserServerResponseModel MapEntityToModel(
            User item)
        {
            var model = new ApiUserServerResponseModel();

            model.SetProperties(item.UserId,
                                item.BioImgUrl,
                                item.Birthday,
                                item.ContentDescription,
                                item.Email,
                                item.FullName,
                                item.HeaderImgUrl,
                                item.Interest,
                                item.LocationLocationId,
                                item.Password,
                                item.PhoneNumber,
                                item.Privacy,
                                item.Username,
                                item.Website);
            if (item.LocationLocationIdNavigation != null)
            {
                var locationLocationIdModel = new ApiLocationServerResponseModel();
                locationLocationIdModel.SetProperties(
                    item.LocationLocationIdNavigation.LocationId,
                    item.LocationLocationIdNavigation.GpsLat,
                    item.LocationLocationIdNavigation.GpsLong,
                    item.LocationLocationIdNavigation.LocationName);

                model.SetLocationLocationIdNavigation(locationLocationIdModel);
            }

            return(model);
        }
Exemplo n.º 2
0
        public virtual ApiLocationClientRequestModel MapServerResponseToClientRequest(
            ApiLocationServerResponseModel response)
        {
            var request = new ApiLocationClientRequestModel();

            request.SetProperties(
                response.GpsLat,
                response.GpsLong,
                response.LocationName);
            return(request);
        }
Exemplo n.º 3
0
        public virtual ApiLocationServerResponseModel MapServerRequestToResponse(
            int locationId,
            ApiLocationServerRequestModel request)
        {
            var response = new ApiLocationServerResponseModel();

            response.SetProperties(locationId,
                                   request.GpsLat,
                                   request.GpsLong,
                                   request.LocationName);
            return(response);
        }
Exemplo n.º 4
0
        public virtual ApiLocationServerResponseModel MapEntityToModel(
            Location item)
        {
            var model = new ApiLocationServerResponseModel();

            model.SetProperties(item.LocationId,
                                item.GpsLat,
                                item.GpsLong,
                                item.LocationName);

            return(model);
        }
Exemplo n.º 5
0
        public void MapEntityToModel()
        {
            var      mapper = new DALLocationMapper();
            Location item   = new Location();

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

            response.GpsLat.Should().Be(1);
            response.GpsLong.Should().Be(1);
            response.LocationId.Should().Be(1);
            response.LocationName.Should().Be("A");
        }
Exemplo n.º 6
0
        public virtual async Task <UpdateResponse <ApiLocationServerResponseModel> > Update(
            int locationId,
            ApiLocationServerRequestModel model)
        {
            var validationResult = await this.LocationModelValidator.ValidateUpdateAsync(locationId, model);

            if (validationResult.IsValid)
            {
                Location record = this.DalLocationMapper.MapModelToEntity(locationId, model);
                await this.LocationRepository.Update(record);

                record = await this.LocationRepository.Get(locationId);

                ApiLocationServerResponseModel apiModel = this.DalLocationMapper.MapEntityToModel(record);
                await this.mediator.Publish(new LocationUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiLocationServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiLocationServerResponseModel> .UpdateResponse(validationResult));
            }
        }
Exemplo n.º 7
0
 public void SetLocationIdNavigation(ApiLocationServerResponseModel value)
 {
     this.LocationIdNavigation = value;
 }
Exemplo n.º 8
0
 public LocationUpdatedNotification(ApiLocationServerResponseModel record)
 {
     this.Record = record;
 }