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

            model.SetProperties(item.Id,
                                item.Birthday,
                                item.Email,
                                item.FirstName,
                                item.LastName,
                                item.Phone,
                                item.UserId);
            if (item.UserIdNavigation != null)
            {
                var userIdModel = new ApiUserServerResponseModel();
                userIdModel.SetProperties(
                    item.UserIdNavigation.Id,
                    item.UserIdNavigation.Password,
                    item.UserIdNavigation.Username);

                model.SetUserIdNavigation(userIdModel);
            }

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

            request.SetProperties(
                response.Birthday,
                response.Email,
                response.FirstName,
                response.LastName,
                response.Phone,
                response.UserId);
            return(request);
        }
Example #3
0
        public virtual ApiAdminServerResponseModel MapServerRequestToResponse(
            int id,
            ApiAdminServerRequestModel request)
        {
            var response = new ApiAdminServerResponseModel();

            response.SetProperties(id,
                                   request.Birthday,
                                   request.Email,
                                   request.FirstName,
                                   request.LastName,
                                   request.Phone,
                                   request.UserId);
            return(response);
        }
Example #4
0
        public void MapEntityToModel()
        {
            var   mapper = new DALAdminMapper();
            Admin item   = new Admin();

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

            response.Birthday.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.Email.Should().Be("A");
            response.FirstName.Should().Be("A");
            response.Id.Should().Be(1);
            response.LastName.Should().Be("A");
            response.Phone.Should().Be("A");
            response.UserId.Should().Be(1);
        }
Example #5
0
        public virtual async Task <UpdateResponse <ApiAdminServerResponseModel> > Update(
            int id,
            ApiAdminServerRequestModel model)
        {
            var validationResult = await this.AdminModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                Admin record = this.DalAdminMapper.MapModelToEntity(id, model);
                await this.AdminRepository.Update(record);

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

                ApiAdminServerResponseModel apiModel = this.DalAdminMapper.MapEntityToModel(record);
                await this.mediator.Publish(new AdminUpdatedNotification(apiModel));

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