public virtual ApiEventStudentServerResponseModel MapEntityToModel(
            EventStudent item)
        {
            var model = new ApiEventStudentServerResponseModel();

            model.SetProperties(item.Id,
                                item.EventId,
                                item.StudentId);
            if (item.EventIdNavigation != null)
            {
                var eventIdModel = new ApiEventServerResponseModel();
                eventIdModel.SetProperties(
                    item.EventIdNavigation.Id,
                    item.EventIdNavigation.ActualEndDate,
                    item.EventIdNavigation.ActualStartDate,
                    item.EventIdNavigation.BillAmount,
                    item.EventIdNavigation.EventStatusId,
                    item.EventIdNavigation.ScheduledEndDate,
                    item.EventIdNavigation.ScheduledStartDate,
                    item.EventIdNavigation.StudentNotes,
                    item.EventIdNavigation.TeacherNotes);

                model.SetEventIdNavigation(eventIdModel);
            }

            if (item.StudentIdNavigation != null)
            {
                var studentIdModel = new ApiStudentServerResponseModel();
                studentIdModel.SetProperties(
                    item.StudentIdNavigation.Id,
                    item.StudentIdNavigation.Birthday,
                    item.StudentIdNavigation.Email,
                    item.StudentIdNavigation.EmailRemindersEnabled,
                    item.StudentIdNavigation.FamilyId,
                    item.StudentIdNavigation.FirstName,
                    item.StudentIdNavigation.IsAdult,
                    item.StudentIdNavigation.LastName,
                    item.StudentIdNavigation.Phone,
                    item.StudentIdNavigation.SmsRemindersEnabled,
                    item.StudentIdNavigation.UserId);

                model.SetStudentIdNavigation(studentIdModel);
            }

            return(model);
        }
示例#2
0
        public virtual ApiStudentClientRequestModel MapServerResponseToClientRequest(
            ApiStudentServerResponseModel response)
        {
            var request = new ApiStudentClientRequestModel();

            request.SetProperties(
                response.Birthday,
                response.Email,
                response.EmailRemindersEnabled,
                response.FamilyId,
                response.FirstName,
                response.IsAdult,
                response.LastName,
                response.Phone,
                response.SmsRemindersEnabled,
                response.UserId);
            return(request);
        }
示例#3
0
        public virtual ApiStudentServerResponseModel MapServerRequestToResponse(
            int id,
            ApiStudentServerRequestModel request)
        {
            var response = new ApiStudentServerResponseModel();

            response.SetProperties(id,
                                   request.Birthday,
                                   request.Email,
                                   request.EmailRemindersEnabled,
                                   request.FamilyId,
                                   request.FirstName,
                                   request.IsAdult,
                                   request.LastName,
                                   request.Phone,
                                   request.SmsRemindersEnabled,
                                   request.UserId);
            return(response);
        }
示例#4
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);
        }
        public void MapEntityToModel()
        {
            var     mapper = new DALStudentMapper();
            Student item   = new Student();

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

            response.Birthday.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.Email.Should().Be("A");
            response.EmailRemindersEnabled.Should().Be(true);
            response.FamilyId.Should().Be(1);
            response.FirstName.Should().Be("A");
            response.Id.Should().Be(1);
            response.IsAdult.Should().Be(true);
            response.LastName.Should().Be("A");
            response.Phone.Should().Be("A");
            response.SmsRemindersEnabled.Should().Be(true);
            response.UserId.Should().Be(1);
        }
示例#6
0
        public virtual async Task <UpdateResponse <ApiStudentServerResponseModel> > Update(
            int id,
            ApiStudentServerRequestModel model)
        {
            var validationResult = await this.StudentModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                Student record = this.DalStudentMapper.MapModelToEntity(id, model);
                await this.StudentRepository.Update(record);

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

                ApiStudentServerResponseModel apiModel = this.DalStudentMapper.MapEntityToModel(record);
                await this.mediator.Publish(new StudentUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiStudentServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiStudentServerResponseModel> .UpdateResponse(validationResult));
            }
        }
示例#7
0
 public StudentUpdatedNotification(ApiStudentServerResponseModel record)
 {
     this.Record = record;
 }
示例#8
0
 public void SetStudentIdNavigation(ApiStudentServerResponseModel value)
 {
     this.StudentIdNavigation = value;
 }