public CreatePosMerchantResponse CreatePosMerchant(CreatePosMerchantRequest request)
        {
            CreatePosMerchantResponse response = new CreatePosMerchantResponse();
            PosMerchant posMerchant            = new PosMerchant();

            posMerchant.MerchantName           = request.MerchantName;
            posMerchant.BusinessName           = request.BusinessName;
            posMerchant.BannerName             = request.BannerName;
            posMerchant.MerchantIdByHeadQuater = request.MerchantIdByHeadQuater;
            posMerchant.PosReceiptOfTestings   = request.PosReceiptOfTestings.ConvertToPosReceiptOfTestings();
            posMerchant.PosAddress             = request.PosAddress.ConvertToPosAddress();

            if (posMerchant.GetBrokenRules().Count() > 0)
            {
                response.Errors = posMerchant.GetBrokenRules().ToList();
            }
            else
            {
                try {
                    _posMerchantRepository.Add(posMerchant);
                    _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);
        }
        public ModifyPosMerchantResponse ModifyPosMerchant(ModifyPosMerchantRequest request)
        {
            ModifyPosMerchantResponse response = new ModifyPosMerchantResponse();

            PosMerchant posMerchant = _posMerchantRepository
                                      .FindBy(request.MerchantId);

            posMerchant.Id                     = request.MerchantId;
            posMerchant.MerchantName           = request.MerchantName;
            posMerchant.BusinessName           = request.BusinessName;
            posMerchant.BannerName             = request.BannerName;
            posMerchant.MerchantIdByHeadQuater = request.MerchantIdByHeadQuater;
            posMerchant.PosReceiptOfTestings   = request.PosReceiptOfTestings.ConvertToPosReceiptOfTestings();
            posMerchant.PosAddress             = request.PosAddress.ConvertToPosAddress();


            if (posMerchant.GetBrokenRules().Count() > 0)
            {
                response.Errors = posMerchant.GetBrokenRules().ToList();
            }
            else
            {
                try {
                    _posMerchantRepository.Save(posMerchant);
                    _uow.Commit();
                    response.Errors = new List <BusinessRule>();
                } catch (Exception ex)
                {
                    response.Errors = new List <BusinessRule>();
                    response.Errors.Add(new BusinessRule("DAL", "DAL_ERROR: " + ex.Message));
                }
            }


            return(response);
        }