public ActionResult AddMerchant(AddMerchantModel MerchantToAdd)
        {
            IMerchantDAO MerchantData = new MerchantDAO();

            if (MerchantToAdd.MerchantID != null)
            {
                if (MerchantData.GetMerchant(MerchantToAdd.MerchantID) != null)
                {
                    ModelState.AddModelError("MerchantID", "Merchant ID already on file");
                }
            }

            if (MerchantToAdd.MerchantUserName != null)
            {
                //if (MerchantData.GetMerchantByUserName(MerchantToAdd.MerchantUserName) != null)
                //    ModelState.AddModelError("UserName", "Merchant User Name already on file");

                IUserDAO UserDAO = new UserDAO();
                if (UserDAO.GetUser(MerchantToAdd.MerchantUserName) != null)
                {
                    ModelState.AddModelError("UserName", "Merchant 'user name' already on file");
                }
            }
            if (ModelState.IsValid)
            {
                // Attempt to add the merchant
                try
                {
                    String AgentUserName = (String)Session["AgentUserName"];
                    if (AgentUserName == null)
                    {
                        AgentUserName = User.Identity.Name;
                    }
                    if (AgentUserName.Length == 0)
                    {
                        AgentUserName = User.Identity.Name;
                    }
                    bool createStatus = MerchantServiceInstance.AddMerchant(MerchantToAdd,
                                                                            AgentUserName, Roles.IsUserInRole(AgentUserName, "Agent"));

                    if (createStatus == true)
                    {
                        ModelState.AddModelError("", "Merchant Created");
                    }
                    else
                    {
                        ModelState.AddModelError("", "Failed to create the merchant");
                    }
                }
                catch (Exception Ex)
                {
                    ModelState.AddModelError("", Common.StandardExceptionErrorMessage(Ex));
                }
            }
            // If we got this far, something failed, redisplay form

            return(View(MerchantToAdd));
        }
예제 #2
0
        public ResultModel Add(AddMerchantModel model)
        {
            return(this._database.RunQuery(db =>
            {
                var result = new ResultModel();

                db.YH_MerchantInfo.Insert(model);

                return result;
            }));
        }
예제 #3
0
        public JsonResult Add(AddMerchantModel model)
        {
            var result = this._merchantService.Add(model);

            return(this.Json(result));
        }