Exemplo n.º 1
0
        public JsonResult CreateTransaction(int userId, TransactSave transaction)
        {
            LoggedUserInfo userInfo = _userCache.Get(userId);
            string         error401 = transaction.RecipientID == 0
                ? ConstStrings.ReplenishmentError401
                : ConstStrings.TransferError401;

            if (userInfo != null)
            {
                Result <TransactPresentation> transactionData = _dataService.CreateTransaction(userInfo.Token, transaction);
                if (transactionData.Data != null)
                {
                    userInfo.Balance += transaction.Amount;
                    _userCache.Update(userInfo);

                    return(Json(transactionData.Data, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    if (transactionData.Error.IndexOf("401") != -1 || transactionData.Error.IndexOf("403") != -1)
                    {
                        _userCache.Delete(userId);
                        return(Json(error401, JsonRequestBehavior.AllowGet));
                    }
                    return(Json(transactionData.Error, JsonRequestBehavior.AllowGet));
                }
            }
            return(Json(error401, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
 public ActionResult LogOff(int userId)
 {
     _userCache.Delete(userId);
     return(RedirectToAction("Transfers", "Main"));
 }