Esempio n. 1
0
        public virtual ApiTeacherServerResponseModel MapEntityToModel(
            Teacher item)
        {
            var model = new ApiTeacherServerResponseModel();

            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);
        }
Esempio n. 2
0
        public virtual ApiTeacherTeacherSkillServerResponseModel MapEntityToModel(
            TeacherTeacherSkill item)
        {
            var model = new ApiTeacherTeacherSkillServerResponseModel();

            model.SetProperties(item.Id,
                                item.TeacherId,
                                item.TeacherSkillId);
            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);
            }

            if (item.TeacherSkillIdNavigation != null)
            {
                var teacherSkillIdModel = new ApiTeacherSkillServerResponseModel();
                teacherSkillIdModel.SetProperties(
                    item.TeacherSkillIdNavigation.Id,
                    item.TeacherSkillIdNavigation.Name);

                model.SetTeacherSkillIdNavigation(teacherSkillIdModel);
            }

            return(model);
        }
        public virtual ApiTeacherClientRequestModel MapServerResponseToClientRequest(
            ApiTeacherServerResponseModel response)
        {
            var request = new ApiTeacherClientRequestModel();

            request.SetProperties(
                response.Birthday,
                response.Email,
                response.FirstName,
                response.LastName,
                response.Phone,
                response.UserId);
            return(request);
        }
        public virtual ApiTeacherServerResponseModel MapServerRequestToResponse(
            int id,
            ApiTeacherServerRequestModel request)
        {
            var response = new ApiTeacherServerResponseModel();

            response.SetProperties(id,
                                   request.Birthday,
                                   request.Email,
                                   request.FirstName,
                                   request.LastName,
                                   request.Phone,
                                   request.UserId);
            return(response);
        }
Esempio n. 5
0
        public void MapEntityToModel()
        {
            var     mapper = new DALTeacherMapper();
            Teacher item   = new Teacher();

            item.SetProperties(1, DateTime.Parse("1/1/1987 12:00:00 AM"), "A", "A", "A", "A", 1);
            ApiTeacherServerResponseModel 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);
        }
        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);
        }
Esempio n. 7
0
        public virtual async Task <UpdateResponse <ApiTeacherServerResponseModel> > Update(
            int id,
            ApiTeacherServerRequestModel model)
        {
            var validationResult = await this.TeacherModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                Teacher record = this.DalTeacherMapper.MapModelToEntity(id, model);
                await this.TeacherRepository.Update(record);

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

                ApiTeacherServerResponseModel apiModel = this.DalTeacherMapper.MapEntityToModel(record);
                await this.mediator.Publish(new TeacherUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiTeacherServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiTeacherServerResponseModel> .UpdateResponse(validationResult));
            }
        }
 public void SetTeacherIdNavigation(ApiTeacherServerResponseModel value)
 {
     this.TeacherIdNavigation = value;
 }
Esempio n. 9
0
 public TeacherUpdatedNotification(ApiTeacherServerResponseModel record)
 {
     this.Record = record;
 }