Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public virtual ApiUserClientRequestModel MapServerResponseToClientRequest(
            ApiUserServerResponseModel response)
        {
            var request = new ApiUserClientRequestModel();

            request.SetProperties(
                response.Password,
                response.Username);
            return(request);
        }
Ejemplo n.º 3
0
        public virtual ApiUserServerResponseModel MapEntityToModel(
            User item)
        {
            var model = new ApiUserServerResponseModel();

            model.SetProperties(item.Id,
                                item.Password,
                                item.Username);

            return(model);
        }
Ejemplo n.º 4
0
        public virtual ApiUserServerResponseModel MapServerRequestToResponse(
            int id,
            ApiUserServerRequestModel request)
        {
            var response = new ApiUserServerResponseModel();

            response.SetProperties(id,
                                   request.Password,
                                   request.Username);
            return(response);
        }
Ejemplo n.º 5
0
        public void MapEntityToModel()
        {
            var  mapper = new DALUserMapper();
            User item   = new User();

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

            response.Id.Should().Be(1);
            response.Password.Should().Be("A");
            response.Username.Should().Be("A");
        }
Ejemplo n.º 6
0
        public virtual ApiStudentServerResponseModel MapEntityToModel(
            Student item)
        {
            var model = new ApiStudentServerResponseModel();

            model.SetProperties(item.Id,
                                item.Birthday,
                                item.Email,
                                item.EmailRemindersEnabled,
                                item.FamilyId,
                                item.FirstName,
                                item.IsAdult,
                                item.LastName,
                                item.Phone,
                                item.SmsRemindersEnabled,
                                item.UserId);
            if (item.FamilyIdNavigation != null)
            {
                var familyIdModel = new ApiFamilyServerResponseModel();
                familyIdModel.SetProperties(
                    item.FamilyIdNavigation.Id,
                    item.FamilyIdNavigation.Notes,
                    item.FamilyIdNavigation.PrimaryContactEmail,
                    item.FamilyIdNavigation.PrimaryContactFirstName,
                    item.FamilyIdNavigation.PrimaryContactLastName,
                    item.FamilyIdNavigation.PrimaryContactPhone);

                model.SetFamilyIdNavigation(familyIdModel);
            }

            if (item.UserIdNavigation != null)
            {
                var userIdModel = new ApiUserServerResponseModel();
                userIdModel.SetProperties(
                    item.UserIdNavigation.Id,
                    item.UserIdNavigation.Password,
                    item.UserIdNavigation.Username);

                model.SetUserIdNavigation(userIdModel);
            }

            return(model);
        }
Ejemplo n.º 7
0
        public virtual async Task <UpdateResponse <ApiUserServerResponseModel> > Update(
            int id,
            ApiUserServerRequestModel model)
        {
            var validationResult = await this.UserModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                User record = this.DalUserMapper.MapModelToEntity(id, model);
                await this.UserRepository.Update(record);

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

                ApiUserServerResponseModel apiModel = this.DalUserMapper.MapEntityToModel(record);
                await this.mediator.Publish(new UserUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiUserServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiUserServerResponseModel> .UpdateResponse(validationResult));
            }
        }
Ejemplo n.º 8
0
 public UserUpdatedNotification(ApiUserServerResponseModel record)
 {
     this.Record = record;
 }
Ejemplo n.º 9
0
 public void SetUserIdNavigation(ApiUserServerResponseModel value)
 {
     this.UserIdNavigation = value;
 }