Пример #1
0
        public virtual ApiNoteClientRequestModel MapServerResponseToClientRequest(
            ApiNoteServerResponseModel response)
        {
            var request = new ApiNoteClientRequestModel();

            request.SetProperties(
                response.CallId,
                response.DateCreated,
                response.NoteText,
                response.OfficerId);
            return(request);
        }
Пример #2
0
        public virtual ApiNoteServerResponseModel MapServerRequestToResponse(
            int id,
            ApiNoteServerRequestModel request)
        {
            var response = new ApiNoteServerResponseModel();

            response.SetProperties(id,
                                   request.CallId,
                                   request.DateCreated,
                                   request.NoteText,
                                   request.OfficerId);
            return(response);
        }
Пример #3
0
        public void MapEntityToModel()
        {
            var  mapper = new DALNoteMapper();
            Note item   = new Note();

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

            response.CallId.Should().Be(1);
            response.DateCreated.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.Id.Should().Be(1);
            response.NoteText.Should().Be("A");
            response.OfficerId.Should().Be(1);
        }
Пример #4
0
        public virtual ApiNoteServerResponseModel MapEntityToModel(
            Note item)
        {
            var model = new ApiNoteServerResponseModel();

            model.SetProperties(item.Id,
                                item.CallId,
                                item.DateCreated,
                                item.NoteText,
                                item.OfficerId);
            if (item.CallIdNavigation != null)
            {
                var callIdModel = new ApiCallServerResponseModel();
                callIdModel.SetProperties(
                    item.CallIdNavigation.Id,
                    item.CallIdNavigation.AddressId,
                    item.CallIdNavigation.CallDispositionId,
                    item.CallIdNavigation.CallStatusId,
                    item.CallIdNavigation.CallString,
                    item.CallIdNavigation.CallTypeId,
                    item.CallIdNavigation.DateCleared,
                    item.CallIdNavigation.DateCreated,
                    item.CallIdNavigation.DateDispatched,
                    item.CallIdNavigation.QuickCallNumber);

                model.SetCallIdNavigation(callIdModel);
            }

            if (item.OfficerIdNavigation != null)
            {
                var officerIdModel = new ApiOfficerServerResponseModel();
                officerIdModel.SetProperties(
                    item.OfficerIdNavigation.Id,
                    item.OfficerIdNavigation.Badge,
                    item.OfficerIdNavigation.Email,
                    item.OfficerIdNavigation.FirstName,
                    item.OfficerIdNavigation.LastName,
                    item.OfficerIdNavigation.Password);

                model.SetOfficerIdNavigation(officerIdModel);
            }

            return(model);
        }
Пример #5
0
        public virtual async Task <UpdateResponse <ApiNoteServerResponseModel> > Update(
            int id,
            ApiNoteServerRequestModel model)
        {
            var validationResult = await this.NoteModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                Note record = this.DalNoteMapper.MapModelToEntity(id, model);
                await this.NoteRepository.Update(record);

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

                ApiNoteServerResponseModel apiModel = this.DalNoteMapper.MapEntityToModel(record);
                await this.mediator.Publish(new NoteUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiNoteServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiNoteServerResponseModel> .UpdateResponse(validationResult));
            }
        }
Пример #6
0
 public NoteUpdatedNotification(ApiNoteServerResponseModel record)
 {
     this.Record = record;
 }