Ejemplo n.º 1
0
        public ActionResult Add(AddressViewModel model)
        {
            ResponseModel response = new ResponseModel();
            ModelState.Remove("Id");
            if (!ModelState.IsValid)
            {
                foreach (var item in ModelState)
                {
                    if (item.Value.Errors.Count > 0)
                    {
                        response.Success = false;
                        response.Msg = item.Value.Errors.FirstOrDefault().ErrorMessage;
                    }

                }
            }
            else
            {
                Address address = AutoMapper.Mapper.Map<Address>(model);
                address.AccountId = LoginAccount.Id;//关联主外键
                _addressService.Add(address);
                _unitOfWork.Commit();
                response.Success = true;
                response.Msg = "成功添加收货地址";
                response.RedirectUrl = Url.Action("Index");
            }
            return Json(response);
        }
Ejemplo n.º 2
0
 public ActionResult Logout()
 {
     FormsAuthentication.SignOut();
     ResponseModel response = new ResponseModel();
     response.Success = true;
     response.Msg = "登出成功,欢迎下次登陆!";
     return Json(response, JsonRequestBehavior.AllowGet);
 }
Ejemplo n.º 3
0
 public async Task<ActionResult> Buy(Models.TradeBuyViewModel model)
 {
     ResponseModel response = new ResponseModel();
     bool flg = await _mt4Service.Buy(LoginAccount.MT4Account, model.Volume);
     if (flg)
     {
         response.Success = flg;
         response.Msg = "成功买入黄金";
     }
     else
     {
         response.Success = true;
         response.Msg = "账户余额不足,买入黄金失败";
         response.RedirectUrl = Url.Action("Deposit", "Account");
     }
     return Json(response, JsonRequestBehavior.AllowGet);
 }
Ejemplo n.º 4
0
 public ActionResult Modify(AddressViewModel model)
 {
     ResponseModel response = new ResponseModel();
     if (!ModelState.IsValid)
     {
         response.Msg = ModelState.Keys.FirstOrDefault();
     }
     else
     {
         Address address = AutoMapper.Mapper.Map<Address>(model);
         _addressService.Update(address);
         _unitOfWork.Commit();
         response.Msg = "成功修改收货人信息";
         response.Success = true;
         response.RedirectUrl = Url.Action("Index");
     }
     return Json(response);
 }
Ejemplo n.º 5
0
 public ActionResult Login(AccountLoginViewModel model)
 {
     if (Request.IsAuthenticated)
     {
         FormsAuthentication.SignOut();
     }
     ResponseModel response = new ResponseModel();
     Account account = _accountService.AccountLoginByPhoneNumber(model.PhoneNumber, model.LoginPwd);
     if (account != null)
     {
         string result = JsonConvert.SerializeObject(new { Id = account.Id, Name = account.Name, MT4Account = account.MT4Account });
         FormsAuthentication.SetAuthCookie(result, true);
         response.Success = true;
         response.Msg = "登陆成功!";
     }
     else
     {
         response.Msg = "登陆用户名密码错误!";
     }
     return Json(response);
 }
Ejemplo n.º 6
0
 public ActionResult Modify(Models.BankViewModel model)
 {
     ResponseModel response = new ResponseModel();
     if (!ModelState.IsValid)
     {
         response.Success = false;
         response.Msg = ModelState.Keys.FirstOrDefault();
     }
     else
     {
         var account = _accountService.GetById(LoginAccount.Id);
         account.BankBranch = model.BankBranch;
         account.Bank = model.Bank;
         account.BankNumber = model.BankNumber;
         _accountService.Update(account);
         _unitOfWork.Commit();
         response.Success = true;
         response.RedirectUrl = Url.Action("Index");
         response.Msg = "成功修改银行卡!";
     }
     return Json(response);
 }
Ejemplo n.º 7
0
        public ActionResult Apply(WithdrawalsViewModel model)
        {
            ResponseModel response = new ResponseModel();
            //Guid guid = Guid.NewGuid();
            Account account = accountService.GetById(LoginAccount.Id);
            if (string.IsNullOrEmpty(account.Name) || string.IsNullOrEmpty(account.Bank) || string.IsNullOrEmpty(account.BankBranch) || string.IsNullOrEmpty(account.BankNumber))
            {
                response.Success = false;
                response.Msg = "您还未进行实名认证!请完善个人信息和银行卡信息";
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    foreach (var item in ModelState)
                    {
                        if (item.Value.Errors.Count > 0)
                        {
                            response.Success = false;
                            response.Msg = item.Value.Errors.FirstOrDefault().ErrorMessage;
                        }
                    }
                }
                else
                {
                    Withdrawals entity = AutoMapper.Mapper.Map<Withdrawals>(model);
                    entity.AccountId = LoginAccount.Id;
                    entity.IsAudit = false;
                    withdrawalsService.Add(entity);
                    unitOfWork.Commit();
                    response.Success = true;
                    response.RedirectUrl = Url.Action("Index");
                    response.Msg = "已成功申请提现!";
                }
            }
            return Json(response);

        }
Ejemplo n.º 8
0
 public async Task<ActionResult> Sell(List<int> list)
 {
     ResponseModel response = new ResponseModel();
     bool flg = await _mt4Service.Sell(list);
     if (flg)
     {
         response.Success = true;
         response.Msg = "成功卖出黄金";
     }
     else
     {
         response.Success = false;
         response.Msg = "黄金卖出有失败,请重试!";
     }
     return Json(response, JsonRequestBehavior.AllowGet);
 }
Ejemplo n.º 9
0
 public ActionResult Register(AccountViewModel model)
 {
     ResponseModel response = new ResponseModel();
     Account account = Mapper.Map<Account>(model);
     account.LoginPwd = model.LoginPwd.ToMd5String();
     _accountService.RegisterAccount(account);
     _unitOfWork.Commit();
     response.Success = true;
     response.Msg = "欢迎您,已经成功加入我们";
     CustomRaiseEvent.RaiseAccountRegister(account);//触发用户注册事件
     string result = JsonConvert.SerializeObject(new { Id = account.Id, Name = account.Name, MT4Account = account.MT4Account });
     FormsAuthentication.SetAuthCookie(result, true);
     response.RedirectUrl = Url.Action("Deposit", "Account");
     return Json(response, JsonRequestBehavior.AllowGet);
 }
Ejemplo n.º 10
0
        public ActionResult ModifyInfo(AccountInfoViewModel model)
        {
            ResponseModel response = new ResponseModel();
            if (!ModelState.IsValid)
            {
                foreach (var item in ModelState)
                {
                    if (item.Value.Errors.Count > 0)
                    {
                        response.Success = false;
                        response.Msg = item.Value.Errors.FirstOrDefault().ErrorMessage;
                    }
                }
            }
            else
            {
                Account account = _accountService.GetById(model.Id);
                account.UpdateTime = DateTime.Now;
                account.Name = model.Name;
                account.PhoneNumber = model.PhoneNumber;
                account.Email = model.Email;
                _accountService.Update(account);
                _unitOfWork.Commit();
                response.Success = true;
                response.Msg = "已成功修改个人信息";
                response.RedirectUrl = Url.Action("Setting", "Account");
                return Json(response, JsonRequestBehavior.AllowGet);

            }
            return Json(response);

        }
Ejemplo n.º 11
0
        public ActionResult ChangePassword(AccountChangePasswordViewModel model)
        {
            ResponseModel response = new ResponseModel();
            if (!ModelState.IsValid)
            {
                response.Msg = ModelState.Keys.FirstOrDefault();
            }
            else
            {
                Account account = _accountService.GetById(model.AccountId);
                if (!account.LoginPwd.Equals(model.OldPwd.ToMd5String()))
                {
                    response.Msg = "旧密码与现在使用密码不一致!如需修改密码请联系客户";

                }
                else
                {
                    account.LoginPwd = model.NewPwd.ToMd5String();
                    _accountService.Update(account);
                    _unitOfWork.Commit();
                    response.Success = true;
                    response.Msg = "成功修改密码,请重新登录";
                    FormsAuthentication.SignOut();
                }
            }
            return Json(response);
        }