コード例 #1
0
        public virtual ApiEventTeacherClientRequestModel MapServerResponseToClientRequest(
            ApiEventTeacherServerResponseModel response)
        {
            var request = new ApiEventTeacherClientRequestModel();

            request.SetProperties(
                response.EventId,
                response.TeacherId);
            return(request);
        }
コード例 #2
0
        public virtual ApiEventTeacherServerResponseModel MapServerRequestToResponse(
            int id,
            ApiEventTeacherServerRequestModel request)
        {
            var response = new ApiEventTeacherServerResponseModel();

            response.SetProperties(id,
                                   request.EventId,
                                   request.TeacherId);
            return(response);
        }
コード例 #3
0
        public void MapEntityToModel()
        {
            var          mapper = new DALEventTeacherMapper();
            EventTeacher item   = new EventTeacher();

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

            response.EventId.Should().Be(1);
            response.Id.Should().Be(1);
            response.TeacherId.Should().Be(1);
        }
コード例 #4
0
        public virtual ApiEventTeacherServerResponseModel MapEntityToModel(
            EventTeacher item)
        {
            var model = new ApiEventTeacherServerResponseModel();

            model.SetProperties(item.Id,
                                item.EventId,
                                item.TeacherId);
            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.TeacherIdNavigation != null)
            {
                var teacherIdModel = new ApiTeacherServerResponseModel();
                teacherIdModel.SetProperties(
                    item.TeacherIdNavigation.Id,
                    item.TeacherIdNavigation.Birthday,
                    item.TeacherIdNavigation.Email,
                    item.TeacherIdNavigation.FirstName,
                    item.TeacherIdNavigation.LastName,
                    item.TeacherIdNavigation.Phone,
                    item.TeacherIdNavigation.UserId);

                model.SetTeacherIdNavigation(teacherIdModel);
            }

            return(model);
        }
コード例 #5
0
        public virtual async Task <UpdateResponse <ApiEventTeacherServerResponseModel> > Update(
            int id,
            ApiEventTeacherServerRequestModel model)
        {
            var validationResult = await this.EventTeacherModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                EventTeacher record = this.DalEventTeacherMapper.MapModelToEntity(id, model);
                await this.EventTeacherRepository.Update(record);

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

                ApiEventTeacherServerResponseModel apiModel = this.DalEventTeacherMapper.MapEntityToModel(record);
                await this.mediator.Publish(new EventTeacherUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiEventTeacherServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiEventTeacherServerResponseModel> .UpdateResponse(validationResult));
            }
        }
コード例 #6
0
 public EventTeacherUpdatedNotification(ApiEventTeacherServerResponseModel record)
 {
     this.Record = record;
 }