public async Task <RequestResult <Example> > Handle(ExampleCommand request, CancellationToken cancellationToken)
        {
            var result = new RequestResult <Example>();

            var exampleResponse = await _exampleClient.GetExampleFromExternalResource(request.Value);

            if (exampleResponse == null)
            {
                result.AddError(new Error {
                    Code = "EXAMPLE_CODE", Reason = "Response from external example call was null"
                });
                result.AddError("EXAMPLE_CODE", "Response from external example call was null");
                return(result);
            }

            result.Payload = await _exampleRepository.InsertExample(exampleResponse.Value);

            return(result);
        }
示例#2
0
        public void AddExample(HtmlNodeCollection list, int detailsID, int?subsenseID)
        {
            if (list != null)
            {
                foreach (var ex in list)
                {
                    string descr = ex.InnerText;
                    descr = descr.Replace("&lsquo;", "");
                    descr = descr.Replace("&rsquo;", "");

                    Example example = new Example
                    {
                        DetailsID  = detailsID,
                        SubsenseID = subsenseID,
                        Ex         = descr
                    };

                    exampleRepo.InsertExample(example);
                }
            }
        }