/// <summary> /// Returns true if TokenResponse instances are equal /// </summary> /// <param name="other">Instance of TokenResponse to be compared</param> /// <returns>Boolean</returns> public bool Equals(TokenResponse other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return ( Card == other.Card || Card != null && Card.Equals(other.Card) ) && ( EWallet == other.EWallet || EWallet != null && EWallet.Equals(other.EWallet) ) && ( Id == other.Id || Id != null && Id.Equals(other.Id) ) && ( PaymentProductId == other.PaymentProductId || PaymentProductId != null && PaymentProductId.Equals(other.PaymentProductId) ); }
public void AddOrUpdateEWallet(EWallet eWallet, bool isAdd) { if (isAdd) { _context.EWallet.Add(eWallet); } else { _context.EWallet.Update(eWallet); } }
public ActionResult EWallet() { if (Session["user"] == null) { return(RedirectToAction("Login", "Account")); } TB_User user = (TB_User)Session["user"]; EWallet wallet = entities.EWallets.Where(x => x.UserID == user.UserId).FirstOrDefault(); return(View(wallet)); }
public ActionResult PayUsingWallet() { RechargeModel model = (RechargeModel)Session["recharge"]; EWallet wallet = null; if (Session["user"] != null) { TB_User user = (TB_User)Session["user"]; wallet = user.EWallets.FirstOrDefault(); if (Convert.ToDecimal(model.amount) < wallet.Amount) { ServiceReference1.ClientAPIServiceSoapClient s = new ServiceReference1.ClientAPIServiceSoapClient(); string clientId = ConfigurationManager.AppSettings["ClientId"]; string clientPwd = ConfigurationManager.AppSettings["ClientPwd"]; string responseid = ""; string status = ""; string balances = ""; string number = Guid.NewGuid().ToString().Substring(0, 6); TB_Transaction tx = repo.createTransaction(number, model.amount, wallet.UserID ?? 0, Convert.ToInt32(model.ProductId), model.phone); bool result = s.RequestInput(clientId, clientPwd, number, model.Operators, Convert.ToDecimal(model.amount), model.phone, ref responseid, ref status, ref balances); tx.Status = status; tx.ResponseId = responseid; repo.updateTrasnaction(tx); if (status == "SUBMIT_SUCCESS") { TB_Transaction txu = entities.TB_Transaction.Where(x => x.TransactionId == tx.TransactionId).FirstOrDefault(); txu.PaymentStatus = "Payment Recieved."; entities.SaveChanges(); repo.DeductMoneyFromWallet(((TB_User)Session["user"]).UserId, Convert.ToDecimal(model.amount)); TB_Paypal paypal = new TB_Paypal(); paypal.Amount = Convert.ToDecimal(model.amount); paypal.date = DateTime.Now; paypal.EWalletID = wallet.EWalletID; paypal.Type = "Mobile Recharge"; paypal.UserID = user.UserId; paypal.TransactionID = txu.TransactionId; entities.TB_Paypal.Add(paypal); entities.SaveChanges(); ViewBag.Message = "Recharge Succesful !"; } else { ViewBag.Message = "Recharge was UnSuccesful !"; ViewBag.MessageDesc = "Some issue occured in the backend. We haven't deducted money from your wallet. Please try again later"; } } } return(View(model)); }
public ActionResult RedirectFromPaypal(int id) { TB_Paypal p = entities.TB_Paypal.Where(x => x.PaypalId == id).FirstOrDefault(); EWallet wa = entities.EWallets.Where(x => x.EWalletID == p.EWalletID).FirstOrDefault(); p.TransactionID = 1; wa.Amount = wa.Amount + p.Amount; entities.SaveChanges(); ViewBag.Message = "Recharge Succesful !"; ViewBag.MessageDesc = ""; return(View()); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (Card != null) hashCode = hashCode * 59 + Card.GetHashCode(); if (EWallet != null) hashCode = hashCode * 59 + EWallet.GetHashCode(); if (Id != null) hashCode = hashCode * 59 + Id.GetHashCode(); if (PaymentProductId != null) hashCode = hashCode * 59 + PaymentProductId.GetHashCode(); return hashCode; } }
public ActionResult Register(FormCollection forms) { string username = forms["username"]; string email = forms["email"]; string password = forms["password"]; string phone = forms["phone"]; string repassword = forms["repassword"]; TB_User conflict = entities.TB_User.Where(x => x.UserName == username).FirstOrDefault(); if (conflict != null) { ViewBag.Message = "Username already taken !"; return(View("AskForLogin")); } if (password != repassword) { ViewBag.Message = "Passwords do not match!"; return(View("AskForLogin")); } TB_User u = new TB_User(); u.UserName = username; u.Email = email; u.Password = password; u.MobileNumber = phone; u.Active = "true"; entities.TB_User.Add(u); entities.SaveChanges(); EWallet w = new EWallet(); w.Amount = 0; w.Active = "true"; w.UserID = u.UserId; entities.EWallets.Add(w); entities.SaveChanges(); TB_User newuser = entities.TB_User.Where(x => x.UserId == u.UserId).FirstOrDefault(); Session["user"] = newuser; return(RedirectToAction("MakePayment")); }
public async Task <object> GetBy(EWallet parameters) { var x = await Uow.Repository <PNRGeneration>().SingleOrDefaultAsync(t => t.PNRId == parameters.PNRId); if (x != null) { var pnrDetails = await Uow.Repository <PassengerInvoice>().SingleOrDefaultAsync(r => r.passengerInvoiceId == x.PassengerInvoiceId); var z = pnrDetails.TotalPrice / pnrDetails.NumberOfPassengers; var currentDate = DateTime.Now; var time = await Uow.Repository <Payment>().SingleOrDefaultAsync(r => r.UserId == x.UserId); TimeSpan t = currentDate - time.PaymentDate; int d; if (t.TotalHours <= 12) { d = (50 * z) / 100; return(d); } else { d = (70 * z) / 100; return(d); } /* parameters.PaymentId = x.PaymentId; * parameters.UserId = x.UserId; * parameters.Refund = d; * await Uow.RegisterNewAsync(parameters); * * var deletePNR = Uow.Repository<PNRGeneration>().FindByKey(x.PNRId); * await Uow.RegisterDeletedAsync(deletePNR); * await Uow.CommitAsync(); * return "REFUND SUCCESSFUL";*/ } else { return("PNR INVALID"); } }
public ActionResult MakePayment() { PaymentViewModel vm = new PaymentViewModel(); RechargeModel model = (RechargeModel)Session["recharge"]; EWallet wallet = null; if (model == null) { return(RedirectToAction("Index")); } vm.recharge = model; if (Session["user"] != null) { wallet = ((TB_User)Session["user"]).EWallets.FirstOrDefault(); vm.eWallet = wallet; } ViewBag.rechargeModel = model; return(View(vm)); }
private async Task <EWallet> GenerateEWalletByTopUp(TopUpResource topUpResource, string userId) { var eWallet = await _eWalletRepository.FindByUserIdAsync(userId); var isAddNewEWallet = false; if (eWallet == null) { eWallet = new EWallet { UserId = userId, Balance = topUpResource.Status == Status.Success ? topUpResource.Amount : 0, TopUpHistories = new List <TopUpHistory>() }; isAddNewEWallet = true; } else { if (ExistSuccessTopUpTransactionId(topUpResource.TransactionId, eWallet.TopUpHistories)) { throw new Exception(string.Format(Constants.TransactionIdExistsErrMsg, topUpResource.TransactionId)); } eWallet.Balance += topUpResource.Status == Status.Success ? topUpResource.Amount : 0; } var topUpHistory = _mapper.Map <TopUpResource, TopUpHistory>(topUpResource); topUpHistory.UserId = userId; eWallet.TopUpHistories.Add(topUpHistory); eWallet.LastUpdateDate = topUpHistory.ActionDate; _eWalletRepository.AddOrUpdateEWallet(eWallet, isAddNewEWallet); return(eWallet); }
private SaveTransactionResponse(bool success, string message, EWallet eWallet) { EWallet = eWallet; BaseResponse = new BaseResponse(success, message); }
public SaveTransactionResponse(EWallet eWallet) : this(true, string.Empty, eWallet) { }
public Task DeleteAsync(EWallet parameters) { throw new NotImplementedException(); }
public HashSet <string> DeleteValidation(EWallet parameters) { return(ValidationMessages); }
public async Task UpdateAsync(EWallet entity) { await Uow.RegisterDirtyAsync(entity); await Uow.CommitAsync(); }
public HashSet <string> UpdateValidation(EWallet entity) { return(ValidationMessages); }
public Task <object> GetAsync(EWallet parameters) { throw new NotImplementedException(); }
public async Task AddAsync(EWallet entity) { await Uow.RegisterNewAsync(entity); await Uow.CommitAsync(); }
private async Task <EWallet> SaveDeductHistory(DeductResource deductResource, EWallet eWallet, Status status, string errorMessage = "") { var deductHistory = _mapper.Map <DeductResource, DeductHistory>(deductResource); deductHistory.Status = status; deductHistory.Comment = errorMessage; eWallet.DeductHistories.Add(deductHistory); eWallet.LastUpdateDate = deductResource.ActionDate; _eWalletRepository.AddOrUpdateEWallet(eWallet, false); await _unitOfWork.CompleteAsync(); return(eWallet); }