public HttpResponseMessage GetWalletInfo(UserMobileNumber objUserMobileNumber) { try { string mobileNumber = objUserMobileNumber.MobileNumber; var userwalletDetails = (from user in dbContext.User_Wallet where user.user_code == mobileNumber select user).FirstOrDefault(); if (userwalletDetails != null) { UserWalletViewModel objUserWalletViewModel = new UserWalletViewModel() { Id = userwalletDetails.Id, MobileNumber = userwalletDetails.user_code, // Status = userwalletDetails.Status, WalletBalance = userwalletDetails.UserBalance, }; return(Request.CreateResponse(HttpStatusCode.OK, objUserWalletViewModel)); } objResponse.Message = "User wallet does Not exist"; return(Request.CreateResponse(HttpStatusCode.OK, objResponse)); } catch (Exception ex) { // Log.Info(Convert.ToString(ex.InnerException)); // Log.Info(ex.Message); //objCommonClasses.InsertExceptionDetails(ex, "UserController", "GetUserWalletInfo"); return(Request.CreateErrorResponse(HttpStatusCode.ExpectationFailed, ex.Message)); } }
private async Task <UserWalletViewModel> BuildWalletViewModel() { var userId = _userManager.GetUserId(User); var model = new UserWalletViewModel(); model.AllInfo = await GetAllCoinInfo(); var listOfCoins = _db.AllWalletInfo.Where(e => e.UserID.Equals(userId)).ToList(); // TODO - Hard Coding User id foreach (var followedCoin in listOfCoins) { var coinInfo = await SearchBySymbolExact(followedCoin.Symbol); var tempObject = new CombinedAllAndWatched(); tempObject.CoinSymbol = coinInfo.CoinSymbol; tempObject.UserHigh = followedCoin.UserHigh; tempObject.UserLow = followedCoin.UserLow; tempObject.Price = coinInfo.Price; tempObject.PriceChangePercent = coinInfo.PriceChangePercent; tempObject.Count = coinInfo.Count; model.CombinedInfo.Add(tempObject); } return(model); }
public async Task <UserWalletViewModel> GetUserWallet(string userId) { if (userId != null) { var userWallet = new UserWalletViewModel { Money = _context.UserCurrecnies.FirstOrDefault(w => w.UserId == userId)?.Amount ?? 0, UserStocksWallet = new List <UserStocksWallet>(from stock in _context.UserActionses join company in _context.Companies on stock.ActionCode equals company.Code where stock.UserId == userId select new UserStocksWallet { Name = company.Name, Value = stock.Amount, Amount = company.Unit, Code = company.Code, Unit = company.Unit, ActualPrice = _context.ShereRateses.OrderByDescending(w => w.DateTimeRates).FirstOrDefault(w => w.Code == company.Code).Rate }) }; return(userWallet); } return(new UserWalletViewModel { Money = 0, UserStocksWallet = new List <UserStocksWallet>() }); }
public UserWalletViewModel GetUserWalletViewModel(string userId) { UserWalletViewModel userWallet = new UserWalletViewModel(); userWallet.Money = _db.UserApp .AsNoTracking() .Where(x => x.Id.Equals(userId)) .Select(x => x.Money) .FirstOrDefault(); var userStocksWallet = _db.UserStocks .AsNoTracking() .Where(x => x.UserID.Equals(userId)) .Select(x => new UserWalletStocks { Name = x.Stock.Name, Code = x.Stock.Code, Amount = x.Amount, Unit = x.Stock.Values.OrderByDescending(y => y.PublicationDate).Take(1).Select(s => s.Unit).FirstOrDefault(), Price = x.Stock.Values.OrderByDescending(y => y.PublicationDate).Take(1).Select(s => s.Price).FirstOrDefault() }); userWallet.userStocks = userStocksWallet.ToList(); return(userWallet); }
public HttpResponseMessage UpdateWalletBalance(UserWalletViewModel objAddress) { try { User_Wallet objUserWallet = new User_Wallet(); string mobileNumber = objAddress.MobileNumber; //get mobileNumber from user table var number = (from user in dbContext.Shop_Retailer_UserMaster where user.mobile_number == mobileNumber select user).FirstOrDefault(); if (number != null) { var CheckBalanceforUser = (from balance in dbContext.User_Wallet where balance.user_code == mobileNumber select balance).FirstOrDefault(); if (CheckBalanceforUser != null) { int Availablebalance = Convert.ToInt32(CheckBalanceforUser.UserBalance); int TobeDeductedAmount = Convert.ToInt32(objAddress.WalletBalance); int totalAmount = Availablebalance - TobeDeductedAmount; objUserWallet.Id = CheckBalanceforUser.Id; var getWalletInfo = (from balance in dbContext.User_Wallet where balance.Id == CheckBalanceforUser.Id select balance).FirstOrDefault(); getWalletInfo.UserBalance = totalAmount.ToString(); getWalletInfo.ModifiedDate = DateTime.Now; dbContext.Entry(getWalletInfo).State = EntityState.Modified; var i = dbContext.SaveChanges(); if (i != 0) { objResponse.Message = "Wallet balance updated successfully"; return(Request.CreateResponse(HttpStatusCode.OK, objResponse)); } else { objResponse.Message = "Failed to add wallet balance."; return(Request.CreateResponse(HttpStatusCode.OK, objResponse)); } } else { objResponse.Message = "Mobile number not exists."; return(Request.CreateResponse(HttpStatusCode.OK, objResponse)); } } else { objResponse.Message = "Mobile number not exists."; return(Request.CreateResponse(HttpStatusCode.OK, objResponse)); } } catch (Exception) { throw; } }
// // GET: /UserWalletLog/Create /// <summary> /// This methos will be used to create new wallet. /// </summary> /// <param name="Id"></param> /// <returns></returns> public ActionResult Create(int Id = 0) { logger.Info("Create GET Method Start" + " at " + DateTime.UtcNow); ViewBag.UserProfileId = new SelectList(db.UserProfiles, "UserProfileId", "UserName", Id); UserWalletViewModel viewModel = new UserWalletViewModel(); viewModel.UserProfileId = Id; viewModel.UserWallet = db.UserWallets.Where(t => t.UserProfileId == Id).FirstOrDefault(); ViewData.Model = viewModel; logger.Info("Create GET Method End" + " at " + DateTime.UtcNow); return(View()); }
public ActionResult Dashboard() { ViewBag.Message = TempData["Message"]; ViewBag.MessageType = TempData["MessageType"]; UserWalletViewModel userWalletModel = null; if (User.Identity.IsAuthenticated) { userWalletModel = _userService.GetUserWalletViewModel(User.Identity.GetUserId()); } return(View(userWalletModel)); }
public ActionResult GetResponse(string DR) { logger.Info("GetResponse Method Start" + " at " + DateTime.UtcNow); UserWalletViewModel userWalletViewModal = (UserWalletViewModel)TempData["UserWallet"]; RequestParams parameters = new RequestParams(); UserWalletLog userWalletLog = userWalletViewModal.UserWalletLog; db.Entry(userWalletLog).State = EntityState.Modified; parameters.GetResponse(DR, userWalletViewModal.UserProfileId, userWalletViewModal.UserWalletLog.Amount, ref userWalletLog); userWalletViewModal.UserWalletLog = userWalletLog; logger.Info("GetResponse Method userWalletLog Status" + userWalletLog.Status1 + " at " + DateTime.UtcNow); if (userWalletLog.Status1 == (int)OrderStatus.PaymentSuceess) { UserWallet wallet = db.UserWallets.Where(p => p.UserProfileId == userWalletViewModal.UserProfileId).FirstOrDefault(); if (wallet == null) { wallet = new UserWallet(); wallet.UserProfileId = userWalletViewModal.UserProfileId; wallet.Balance += userWalletLog.Amount; logger.Info("GetResponse Method user " + wallet.UserProfileId + " at " + DateTime.UtcNow); logger.Info("GetResponse Method userWallet Balance " + wallet.Balance + " at " + DateTime.UtcNow); db.UserWallets.Add(wallet); logger.Info("GetResponse Method User wallet details added at " + DateTime.UtcNow); } else { wallet.Balance += userWalletLog.Amount; logger.Info("GetResponse Method userWallet Balance " + wallet.Balance + " at " + DateTime.UtcNow); db.Entry(wallet).State = EntityState.Modified; logger.Info("GetResponse Method User wallet details updated at " + DateTime.UtcNow); } userWalletViewModal.UserWallet = wallet; } db.SaveChanges(); ViewData.Model = userWalletViewModal; logger.Info("GetResponse Method End" + " at " + DateTime.UtcNow); return(View()); }
public ActionResult Create(UserWalletViewModel userwalletViewModel) { logger.Info("Create HttpPost Method Start" + " at " + DateTime.UtcNow); if (ModelState.IsValid) { UserWallet wallet = db.UserWallets.Where(t => t.UserProfileId == userwalletViewModel.UserProfileId).FirstOrDefault(); if (wallet == null) { wallet = new UserWallet(); wallet.UserProfileId = userwalletViewModel.UserProfileId; wallet.Balance += userwalletViewModel.UserWalletLog.Amount; logger.Info("Details Method user " + wallet.UserProfileId + " at " + DateTime.UtcNow); logger.Info("Details Method Balance " + wallet.Balance + " at " + DateTime.UtcNow); db.UserWallets.Add(wallet); logger.Info("Details Method User wallet details added " + " at " + DateTime.UtcNow); } else { wallet.Balance += userwalletViewModel.UserWalletLog.Amount; logger.Info("Details Method Balance " + wallet.Balance + " at " + DateTime.UtcNow); db.Entry(wallet).State = EntityState.Modified; logger.Info("Details Method User wallet details updated " + " at " + DateTime.UtcNow); } userwalletViewModel.UserWalletLog.UserProfileId = userwalletViewModel.UserProfileId; userwalletViewModel.UserWalletLog.TransactionDate = DateTime.Now; db.UserWalletLog.Add(userwalletViewModel.UserWalletLog); db.SaveChanges(); } else { ViewBag.UserProfileId = new SelectList(db.UserProfiles, "UserProfileId", "UserName", userwalletViewModel.UserProfileId); logger.Info("Details Method User " + ViewBag.UserProfileId + " at " + DateTime.UtcNow); ModelState.AddModelError("Select", "Select User"); return(View(userwalletViewModel)); } logger.Info("Create HttpPost Method End" + " at " + DateTime.UtcNow); return(RedirectToAction("Index", "UserWallet")); }
public async Task <IActionResult> UserWallet() { UserWalletViewModel model = await BuildWalletViewModel(); return(View(model)); }
//[Authorize] //[Route("api/User/AddWalletBalance")] public HttpResponseMessage AddWalletBalance(UserWalletViewModel objAddress) { try { // UserWalletViewModel objAddress = new UserWalletViewModel(); User_Wallet objUserWallet = new User_Wallet(); string mobileNumber = objAddress.MobileNumber; //get mobileNumber from user table var number = (from user in dbContext.Shop_Retailer_UserMaster where user.user_code == mobileNumber select user).FirstOrDefault(); if (number != null) { var CheckBalanceforUser = (from balance in dbContext.User_Wallet where balance.user_code == mobileNumber select balance).FirstOrDefault(); if (CheckBalanceforUser == null) { objUserWallet.Id = objAddress.Id; objUserWallet.UserBalance = objAddress.WalletBalance; objUserWallet.user_code = objAddress.MobileNumber; //objUserWallet.Status = true; objUserWallet.CreatedDate = DateTime.Now; dbContext.User_Wallet.Add(objUserWallet); var i = dbContext.SaveChanges(); if (i != 0) { objResponse.Message = "Wallet balance added successfully"; return(Request.CreateResponse(HttpStatusCode.OK, objResponse)); } else { objResponse.Message = "Failed to add wallet balance."; return(Request.CreateResponse(HttpStatusCode.OK, objResponse)); } } else { int Availablebalance = Convert.ToInt32(CheckBalanceforUser.UserBalance); int TobeAddedAmount = Convert.ToInt32(objAddress.WalletBalance); int totalAmount = Availablebalance + TobeAddedAmount; objUserWallet.Id = CheckBalanceforUser.Id; var getWalletInfo = (from balance in dbContext.User_Wallet where balance.Id == CheckBalanceforUser.Id select balance).FirstOrDefault(); getWalletInfo.UserBalance = totalAmount.ToString(); getWalletInfo.ModifiedDate = DateTime.Now; dbContext.Entry(getWalletInfo).State = EntityState.Modified; var i = dbContext.SaveChanges(); if (i != 0) { objResponse.Message = "Wallet balace added successfully"; return(Request.CreateResponse(HttpStatusCode.OK, objResponse)); } else { objResponse.Message = "Failed to add wallet balance."; return(Request.CreateResponse(HttpStatusCode.OK, objResponse)); } } } else { objResponse.Message = "Mobile number not exists."; return(Request.CreateResponse(HttpStatusCode.OK, objResponse)); } } catch (Exception ex) { //Log.Info(Convert.ToString(ex.InnerException)); //Log.Info(ex.Message); //objCommonClasses.InsertExceptionDetails(ex, "UserController", "AddWalletBalance"); objResponse.Message = "Mobile number not exists."; return(Request.CreateErrorResponse(HttpStatusCode.ExpectationFailed, ex.Message)); } }