public JsonResult Accounts(PayPointAccountModel model)
        {
            string errorMsg;

            if (!PayPointConnector.Validate(model.mid, model.vpnPassword, model.remotePassword, out errorMsg))
            {
                var errorObject = new { error = errorMsg };
                Log.ErrorFormat("PayPoint validation failed: {0}", errorObject);
                return(Json(errorObject));
            }
            try
            {
                var mpId = SavePaypoint(model);
                m_oServiceClient.Instance.UpdateMarketplace(_context.Customer.Id, mpId, true, _context.Customer.Id);
                return(Json(model));
            }
            catch (MarketPlaceAddedByThisCustomerException e)
            {
                Log.Error(e);
                return(Json(new { error = DbStrings.AccountAddedByYou }));
            }
            catch (MarketPlaceIsAlreadyAddedException e)
            {
                Log.Error(e);
                return(Json(new { error = DbStrings.StoreAlreadyExistsInDb }));
            }
            catch (Exception e)
            {
                Log.Error(e);
                return(Json(new { error = e.Message }));
            }
        }
        private int SavePaypoint(PayPointAccountModel model)
        {
            var customer = _context.Customer;
            var username = model.mid;
            var payPointDatabaseMarketPlace = new PayPointDatabaseMarketPlace();

            _mpChecker.Check(payPointDatabaseMarketPlace.InternalId, customer, username);

            var payPointSecurityInfo = new PayPointSecurityInfo(model.id, model.remotePassword, model.vpnPassword, model.mid);

            var payPoint = _helper.SaveOrUpdateCustomerMarketplace(username, payPointDatabaseMarketPlace, payPointSecurityInfo, customer);

            return(payPoint.Id);
        }