public virtual ApiEventStudentClientRequestModel MapServerResponseToClientRequest(
            ApiEventStudentServerResponseModel response)
        {
            var request = new ApiEventStudentClientRequestModel();

            request.SetProperties(
                response.EventId,
                response.StudentId);
            return(request);
        }
        public virtual ApiEventStudentServerResponseModel MapServerRequestToResponse(
            int id,
            ApiEventStudentServerRequestModel request)
        {
            var response = new ApiEventStudentServerResponseModel();

            response.SetProperties(id,
                                   request.EventId,
                                   request.StudentId);
            return(response);
        }
예제 #3
0
        public void MapEntityToModel()
        {
            var          mapper = new DALEventStudentMapper();
            EventStudent item   = new EventStudent();

            item.SetProperties(1, 1, 1);
            ApiEventStudentServerResponseModel response = mapper.MapEntityToModel(item);

            response.EventId.Should().Be(1);
            response.Id.Should().Be(1);
            response.StudentId.Should().Be(1);
        }
예제 #4
0
        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);
        }
예제 #5
0
        public virtual async Task <UpdateResponse <ApiEventStudentServerResponseModel> > Update(
            int id,
            ApiEventStudentServerRequestModel model)
        {
            var validationResult = await this.EventStudentModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                EventStudent record = this.DalEventStudentMapper.MapModelToEntity(id, model);
                await this.EventStudentRepository.Update(record);

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

                ApiEventStudentServerResponseModel apiModel = this.DalEventStudentMapper.MapEntityToModel(record);
                await this.mediator.Publish(new EventStudentUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiEventStudentServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiEventStudentServerResponseModel> .UpdateResponse(validationResult));
            }
        }
예제 #6
0
 public EventStudentUpdatedNotification(ApiEventStudentServerResponseModel record)
 {
     this.Record = record;
 }