public virtual ApiUnitOfficerServerResponseModel MapEntityToModel(
            UnitOfficer item)
        {
            var model = new ApiUnitOfficerServerResponseModel();

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

            if (item.UnitIdNavigation != null)
            {
                var unitIdModel = new ApiUnitServerResponseModel();
                unitIdModel.SetProperties(
                    item.UnitIdNavigation.Id,
                    item.UnitIdNavigation.CallSign);

                model.SetUnitIdNavigation(unitIdModel);
            }

            return(model);
        }
        public virtual ApiUnitClientRequestModel MapServerResponseToClientRequest(
            ApiUnitServerResponseModel response)
        {
            var request = new ApiUnitClientRequestModel();

            request.SetProperties(
                response.CallSign);
            return(request);
        }
        public virtual ApiUnitServerResponseModel MapServerRequestToResponse(
            int id,
            ApiUnitServerRequestModel request)
        {
            var response = new ApiUnitServerResponseModel();

            response.SetProperties(id,
                                   request.CallSign);
            return(response);
        }
Beispiel #4
0
        public virtual ApiUnitServerResponseModel MapEntityToModel(
            Unit item)
        {
            var model = new ApiUnitServerResponseModel();

            model.SetProperties(item.Id,
                                item.CallSign);

            return(model);
        }
        public void MapEntityToModel()
        {
            var  mapper = new DALUnitMapper();
            Unit item   = new Unit();

            item.SetProperties(1, "A");
            ApiUnitServerResponseModel response = mapper.MapEntityToModel(item);

            response.CallSign.Should().Be("A");
            response.Id.Should().Be(1);
        }
Beispiel #6
0
        public virtual ApiCallAssignmentServerResponseModel MapEntityToModel(
            CallAssignment item)
        {
            var model = new ApiCallAssignmentServerResponseModel();

            model.SetProperties(item.Id,
                                item.CallId,
                                item.UnitId);
            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.UnitIdNavigation != null)
            {
                var unitIdModel = new ApiUnitServerResponseModel();
                unitIdModel.SetProperties(
                    item.UnitIdNavigation.Id,
                    item.UnitIdNavigation.CallSign);

                model.SetUnitIdNavigation(unitIdModel);
            }

            return(model);
        }
Beispiel #7
0
        public virtual async Task <UpdateResponse <ApiUnitServerResponseModel> > Update(
            int id,
            ApiUnitServerRequestModel model)
        {
            var validationResult = await this.UnitModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                Unit record = this.DalUnitMapper.MapModelToEntity(id, model);
                await this.UnitRepository.Update(record);

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

                ApiUnitServerResponseModel apiModel = this.DalUnitMapper.MapEntityToModel(record);
                await this.mediator.Publish(new UnitUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiUnitServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiUnitServerResponseModel> .UpdateResponse(validationResult));
            }
        }
Beispiel #8
0
 public void SetUnitIdNavigation(ApiUnitServerResponseModel value)
 {
     this.UnitIdNavigation = value;
 }
Beispiel #9
0
 public UnitUpdatedNotification(ApiUnitServerResponseModel record)
 {
     this.Record = record;
 }