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); }
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); }
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); }
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); }
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)); } }
public StudentUpdatedNotification(ApiStudentServerResponseModel record) { this.Record = record; }
public void SetStudentIdNavigation(ApiStudentServerResponseModel value) { this.StudentIdNavigation = value; }