public JsonResult Create(PosReceiptOfTestingDetailView vm)
        {
            CreatePosReceiptOfTestingRequest request = new CreatePosReceiptOfTestingRequest();

            request.TestDate = vm.TestDate;
            GetPosMerchantRequest posMerchantRequest = new GetPosMerchantRequest();

            posMerchantRequest.MerchantId = vm.PosMerchantMerchantId;
            request.PosMerchant           = _posMerchantService.GetPosMerchant(posMerchantRequest).PosMerchant;
            request.AgentAName            = vm.AgentAName;
            request.AgentBName            = vm.AgentBName;
            request.PosId = vm.PosId;
            CreatePosReceiptOfTestingResponse response = _posReceiptOfTestingService.CreatePosReceiptOfTesting(request);

            return(Json(response));
        }
        public CreatePosReceiptOfTestingResponse CreatePosReceiptOfTesting(CreatePosReceiptOfTestingRequest request)
        {
            CreatePosReceiptOfTestingResponse response = new CreatePosReceiptOfTestingResponse();
            PosReceiptOfTesting posReceiptOfTesting    = new PosReceiptOfTesting();

            posReceiptOfTesting.TestDate     = request.TestDate;
            posReceiptOfTesting.AgentAName   = request.AgentAName;
            posReceiptOfTesting.AgentBName   = request.AgentBName;
            posReceiptOfTesting.PosId        = request.PosId;
            posReceiptOfTesting.PosTerminals = request.PosTerminals.ConvertToPosTerminals();
            posReceiptOfTesting.PosMerchant  = request.PosMerchant.ConvertToPosMerchant();

            if (posReceiptOfTesting.GetBrokenRules().Count() > 0)
            {
                response.Errors = posReceiptOfTesting.GetBrokenRules().ToList();
            }
            else
            {
                try {
                    _posReceiptOfTestingRepository.Add(posReceiptOfTesting);
                    _uow.Commit();
                    response.Errors = new List <BusinessRule>();
                } catch (Exception ex)
                {
                    List <BusinessRule> errors = new List <BusinessRule>();
                    do
                    {
                        errors.Add(new BusinessRule("DAL", "DAL_ERROR: " + ex.Message));
                        ex = ex.InnerException;
                    } while (ex != null);

                    response.Errors = errors;
                }
            }

            return(response);
        }