public JsonPatchDocument <ApiCallServerRequestModel> CreatePatch(ApiCallServerRequestModel model) { var patch = new JsonPatchDocument <ApiCallServerRequestModel>(); patch.Replace(x => x.AddressId, model.AddressId); patch.Replace(x => x.CallDispositionId, model.CallDispositionId); patch.Replace(x => x.CallStatusId, model.CallStatusId); patch.Replace(x => x.CallString, model.CallString); patch.Replace(x => x.CallTypeId, model.CallTypeId); patch.Replace(x => x.DateCleared, model.DateCleared); patch.Replace(x => x.DateCreated, model.DateCreated); patch.Replace(x => x.DateDispatched, model.DateDispatched); patch.Replace(x => x.QuickCallNumber, model.QuickCallNumber); return(patch); }
public virtual async Task <CreateResponse <ApiCallServerResponseModel> > Create( ApiCallServerRequestModel model) { CreateResponse <ApiCallServerResponseModel> response = ValidationResponseFactory <ApiCallServerResponseModel> .CreateResponse(await this.CallModelValidator.ValidateCreateAsync(model)); if (response.Success) { Call record = this.DalCallMapper.MapModelToEntity(default(int), model); record = await this.CallRepository.Create(record); response.SetRecord(this.DalCallMapper.MapEntityToModel(record)); await this.mediator.Publish(new CallCreatedNotification(response.Record)); } return(response); }
public virtual ApiCallServerRequestModel MapServerResponseToRequest( ApiCallServerResponseModel response) { var request = new ApiCallServerRequestModel(); request.SetProperties( response.AddressId, response.CallDispositionId, response.CallStatusId, response.CallString, response.CallTypeId, response.DateCleared, response.DateCreated, response.DateDispatched, response.QuickCallNumber); return(request); }
public void MapModelToEntity() { var mapper = new DALCallMapper(); ApiCallServerRequestModel model = new ApiCallServerRequestModel(); model.SetProperties(1, 1, 1, "A", 1, DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), 1); Call response = mapper.MapModelToEntity(1, model); response.AddressId.Should().Be(1); response.CallDispositionId.Should().Be(1); response.CallStatusId.Should().Be(1); response.CallString.Should().Be("A"); response.CallTypeId.Should().Be(1); response.DateCleared.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.DateCreated.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.DateDispatched.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.QuickCallNumber.Should().Be(1); }
public virtual Call MapModelToEntity( int id, ApiCallServerRequestModel model ) { Call item = new Call(); item.SetProperties( id, model.AddressId, model.CallDispositionId, model.CallStatusId, model.CallString, model.CallTypeId, model.DateCleared, model.DateCreated, model.DateDispatched, model.QuickCallNumber); return(item); }
public virtual async Task <UpdateResponse <ApiCallServerResponseModel> > Update( int id, ApiCallServerRequestModel model) { var validationResult = await this.CallModelValidator.ValidateUpdateAsync(id, model); if (validationResult.IsValid) { Call record = this.DalCallMapper.MapModelToEntity(id, model); await this.CallRepository.Update(record); record = await this.CallRepository.Get(id); ApiCallServerResponseModel apiModel = this.DalCallMapper.MapEntityToModel(record); await this.mediator.Publish(new CallUpdatedNotification(apiModel)); return(ValidationResponseFactory <ApiCallServerResponseModel> .UpdateResponse(apiModel)); } else { return(ValidationResponseFactory <ApiCallServerResponseModel> .UpdateResponse(validationResult)); } }