public override bool Execute() { if (IdBankAccount <= 0) { Information = StringSource.BankAccountNotFound(); return(false); } using (var service = new BankServiceClient()) { BankAccount = service.GetBankAccountById(IdBankAccount); if (BankAccount != null) { service.RemoveBankAccount(BankAccount); Information = StringSource.BankAccountRemoved(); return(true); } else { Information = StringSource.BankAccountNotFound(); return(false); } } }
public bool RemoveClientInformationById(int IdClient, bool isRemoveClient = false) { Customer client; using (var localrepos = new Repositories()) { client = localrepos.Customers.GetSingle(IdClient); if (client == null) { return(false); } } if (client != null) { CardAccount[] cardaccounts = null; BankAccount bankaccount = null; using (var bankservice = new BankServiceClient()) { cardaccounts = bankservice.GetCardAccountsByCustomerId(client.CustomerID); if (cardaccounts != null) { for (int i = 0; i < cardaccounts.Length; i++) { bankaccount = bankservice.GetBankAccountById(cardaccounts[i].BankAccountID); if (bankaccount != null) { bankservice.RemoveBankAccount(bankaccount); } bankservice.RemoveCardAccount(cardaccounts[i]); } } } if (isRemoveClient) { using (var localrepos = new Repositories()) { localrepos.Customers.Remove(client); localrepos.SaveChanges(); } } } else { return(false); } return(true); }
public override bool Execute() { if (IdBankAccount <= 0) { Information = StringSource.BankAccountNotFound(); return(false); } //if (IdCurrency <= 0) { // Information = StringSource.CurrencyNotFound(); // return false; //} if (!Verifier.CheckBalance(Balance)) { Information = StringSource.BalanceStructureError(); return(false); } //if (!Verifier.CheckPassword(Password)) { // Information = StringSource.PasswordStructureError(); // return false; //} using (var bankservice = new BankServiceClient()) { BankAccount = bankservice.GetBankAccountById(IdBankAccount); if (BankAccount != null) { //if (Password != BankAccount.Password) { // Information = StringSource.PasswordError(); // return false; //} BankAccount.Balance += double.Parse(Balance); //BankAccount.CurrencyID = IdCurrency; bankservice.UpdateBankAccount(BankAccount); BankAccountNumber = BankAccount.AcountNumber; Information = StringSource.BankAccountBalanceUp(); return(true); } } Information = StringSource.BankAccountNotFound(); return(false); }
public ActionResult Arbitrary(ArbitraryPaymentModel paymentInfo, FormCollection collection) { int cardId; if (!int.TryParse(collection["item.CardAccount.CardAccountID"], out cardId)) { ModelState.Clear(); ModelState.AddModelError("CustomError", "Карта не найдена"); return(View(paymentInfo)); } else if (ModelState.IsValid) { Customer customer = rep.Customers.GetSingle(WebSecurity.CurrentUserId); if (customer.IsLocked) { ModelState.Clear(); ModelState.AddModelError("CustomError", "Ваш аккаунт заблокирован"); return(View(paymentInfo)); } paymentInfo.AccountCardId = cardId; CardAccount c = service.GetCardAccountById(cardId); if (c == null) { ModelState.Clear(); ModelState.AddModelError("CustomError", "Карта не найдена"); return(View(paymentInfo)); } paymentInfo.AccountCardNumber = CardAccountModule.ConvertCardNumberString(c.CardNumber); if (c.IsLocked) { ModelState.Clear(); ModelState.AddModelError("CustomError", "Ваша платежная карта заблокирована"); return(View(paymentInfo)); } if (c.ExpiredDate < Time.GetTime()) { c.Status = "Истек срок действия"; service.UpdateCardAccount(c); ModelState.Clear(); ModelState.AddModelError("CustomError", "Истек срок действия карты"); return(View(paymentInfo)); } var bankAccount = service.GetBankAccountById(c.BankAccountID); if (bankAccount == null) { ModelState.Clear(); ModelState.AddModelError("CustomError", "Ошибка базы"); return(View(paymentInfo)); } if (paymentInfo.Amount <= 0) { ModelState.Clear(); ModelState.AddModelError("CustomError", "Сумма должна быть больше нуля"); return(View(paymentInfo)); } if (!service.IsEnoughBalance(cardId, paymentInfo.Amount)) { ModelState.Clear(); ModelState.AddModelError("CustomError", "Недостаточно средств на счете"); return(View(paymentInfo)); } return(RedirectToAction("ConfirmArbitrary", paymentInfo)); } else { return(View(paymentInfo)); } }
public ActionResult HistoryList(FormCollection collection) { var id = collection["id"]; var type = collection["type"]; if (id == null || type == null) { return(RedirectToAction("Index")); } RouteValueDictionary RouteValues = new RouteValueDictionary(); RouteValues.Add("item.CardAccount.CardAccountID", collection["item.CardAccount.CardAccountID"]); RouteValues.Add("datepicker-from", collection["datepicker-from"]); RouteValues.Add("datepicker-to", collection["datepicker-to"]); RouteValues.Add("arbitrary_payments", collection["arbitrary_payments"]); RouteValues.Add("ssisp_payments", collection["ssisp_payments"]); RouteValues.Add("mobile_payments", collection["mobile_payments"]); RouteValues.Add("transfer_payments", collection["transfer_payments"]); if (type == PaymentType.Mobile.ToString()) { var mobileTransaction = service.GetMobileTransactionById(Int32.Parse(id)); var cardAccout = service.GetCardAccountById(mobileTransaction.CardAccountID); var bankAccout = service.GetBankAccountById(cardAccout.BankAccountID); var currency = service.GetCurrencyById(bankAccout.CurrencyID); HistoryPaymentDetails info = new HistoryPaymentDetails(); info.BackRouteValues = RouteValues; info.Dictionary = new Dictionary <string, string>(); info.Dictionary.Add("Дата", mobileTransaction.Date.ToString()); info.Dictionary.Add("Номер карты", CardAccountModule.ConvertCardNumberString(cardAccout.CardNumber)); info.Dictionary.Add("Оператор", mobileTransaction.MobileProvider); info.Dictionary.Add("Номер телефона", mobileTransaction.Phone); info.Dictionary.Add("Сумма", mobileTransaction.Amount + " " + currency.ShortName); return(View("Details", info)); } if (type == PaymentType.Arbitrary.ToString()) { var transaction = service.GetArbitraryTransactionById(Int32.Parse(id)); var cardAccout = service.GetCardAccountById(transaction.CardAccountID); var bankAccout = service.GetBankAccountById(cardAccout.BankAccountID); var currency = service.GetCurrencyById(bankAccout.CurrencyID); HistoryPaymentDetails info = new HistoryPaymentDetails(); info.BackRouteValues = RouteValues; info.Dictionary = new Dictionary <string, string>(); info.Dictionary.Add("Дата", transaction.Date.ToString()); info.Dictionary.Add("Номер карты", CardAccountModule.ConvertCardNumberString(cardAccout.CardNumber)); info.Dictionary.Add("УНП", transaction.UNP); info.Dictionary.Add("Номер счета получателя", transaction.RecipientAccount); info.Dictionary.Add("Получатель", transaction.Recipient); info.Dictionary.Add("Цель", transaction.Target); info.Dictionary.Add("Сумма", transaction.Amount + " " + currency.ShortName); return(View("Details", info)); } if (type == PaymentType.Transfer.ToString()) { var transaction = service.GetTransferTransactionById(Int32.Parse(id)); var cardAccout = service.GetCardAccountById(transaction.CardAccountID); var bankAccout = service.GetBankAccountById(cardAccout.BankAccountID); var currency = service.GetCurrencyById(bankAccout.CurrencyID); HistoryPaymentDetails info = new HistoryPaymentDetails(); info.BackRouteValues = RouteValues; info.Dictionary = new Dictionary <string, string>(); info.Dictionary.Add("Дата", transaction.Date.ToString()); info.Dictionary.Add("Номер карты", CardAccountModule.ConvertCardNumberString(cardAccout.CardNumber)); string targetNumber = service.GetCardAccountById(transaction.TargetCardAccountID).CardNumber; info.Dictionary.Add("Номер карты получателя", CardAccountModule.ConvertCardNumberString(targetNumber)); info.Dictionary.Add("Сумма", transaction.Amount + " " + currency.ShortName); return(View("Details", info)); } if (type == PaymentType.SSIS.ToString()) { var transaction = service.GetSSISTransactionById(Int32.Parse(id)); var cardAccout = service.GetCardAccountById(transaction.CardAccountID); var bankAccout = service.GetBankAccountById(cardAccout.BankAccountID); var currency = service.GetCurrencyById(bankAccout.CurrencyID); var payment = rep.SSISPayments.GetSingle(transaction.SSISPaymentID); HistoryPaymentDetails info = new HistoryPaymentDetails(); info.BackRouteValues = RouteValues; info.Dictionary = new Dictionary <string, string>(); info.Dictionary.Add("Дата", transaction.Date.ToString()); info.Dictionary.Add("Номер карты", CardAccountModule.ConvertCardNumberString(cardAccout.CardNumber)); info.Dictionary.Add("Имя ЕРИП платежа", payment.Name); info.Dictionary.Add(payment.NumberLabel, transaction.Number); info.Dictionary.Add("Сумма", transaction.Amount + " " + currency.ShortName); return(View("Details", info)); } return(View("Index")); }
public ActionResult Create(MobileAutoPayModel model, FormCollection collection) { var custome = repo.Customers.GetSingle(WebSecurity.CurrentUserId); ViewBag.FirstName = custome.FirstName; ViewBag.MiddleName = custome.MiddleName; ViewBag.LastName = custome.LastName; string language = "ru"; string culture = "RU"; Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(string.Format("{0}-{1}", language, culture)); Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(string.Format("{0}-{1}", language, culture)); DateTime date = DateTime.ParseExact(collection["StartDate"], "dd.MM.yyyy", CultureInfo.CurrentCulture); model.StartDate = date; ModelState.Clear(); int cardId; if (!int.TryParse(collection["item.CardAccount.CardAccountID"], out cardId)) { ModelState.Clear(); ModelState.AddModelError("CustomError", "Карта не найдена"); return(View(model)); } else if (ModelState.IsValid) { if ((model.IntervalDays <= 0) && (model.IntervalHours <= 0) && (model.IntervalMinutes <= 0)) { ModelState.Clear(); ModelState.AddModelError("CustomError", "Интервал должен быть положительным"); return(View(model)); } Customer customer = repo.Customers.GetSingle(WebSecurity.CurrentUserId); if (customer.IsLocked) { ModelState.Clear(); ModelState.AddModelError("CustomError", "Ваш аккаунт заблокирован"); return(View(model)); } model.CardAccountID = cardId; CardAccount c = service.GetCardAccountById(cardId); if (c == null) { ModelState.Clear(); ModelState.AddModelError("CustomError", "Карта не найдена"); return(View(model)); } model.CardNumber = CardAccountModule.ConvertCardNumberString(c.CardNumber); if (c.IsLocked) { ModelState.Clear(); ModelState.AddModelError("CustomError", "Ваша платежная карта заблокирована"); return(View(model)); } if (c.ExpiredDate < Time.GetTime()) { c.Status = "Истек срок действия"; service.UpdateCardAccount(c); ModelState.Clear(); ModelState.AddModelError("CustomError", "Истек срок действия карты"); return(View(model)); } var bankAccount = service.GetBankAccountById(c.BankAccountID); if (bankAccount == null) { ModelState.Clear(); ModelState.AddModelError("CustomError", "Ошибка базы"); return(View(model)); } if (bankAccount.CurrencyID != 1) { ModelState.Clear(); ModelState.AddModelError("CustomError", "Оплату мобильной связи можно проводить только беларусскими рублями"); return(View(model)); } if (model.Amount <= 0) { ModelState.Clear(); ModelState.AddModelError("CustomError", "Сумма должна быть больше нуля"); return(View(model)); } if (!service.IsEnoughBalance(cardId, model.Amount)) { ModelState.Clear(); ModelState.AddModelError("CustomError", "Недостаточно средств на счете"); return(View(model)); } model.StartDate = model.StartDate.AddMinutes(model.StartMinutes); model.StartDate = model.StartDate.AddHours(model.StartHours); return(RedirectToAction("ConfirmAutoPay", model)); } else { return(View(model)); } }
public override bool Execute() { if (IdClient <= 0) { Information = StringSource.ClientNotFound(); return(false); } var info = new StringBuilder(); using (var localrepos = new Repositories()) { Client = localrepos.Customers.GetSingle(IdClient); if (Client == null) { Information = StringSource.ClientNotFound(); return(false); } Client.AccessCards = Client.AccessCards.ToList(); foreach (var el in Client.AccessCards) { el.AccessCodes = localrepos.AccessCodes.GetAll(el2 => el2.AccessCardID == el.AccessCardID).ToList(); } } info.Append(StringSource.ClientInformation(Client, true)); Currency currency = null; BankAccount bankacc = null; CardAccount[] cardaccounts = null; using (var bankservice = new BankServiceClient()) { cardaccounts = bankservice.GetCardAccountsByCustomerId(Client.CustomerID); if (cardaccounts == null || cardaccounts.Length <= 0) { info.Append(StringSource.CardAccountNotFound()); } foreach (var el in cardaccounts) { bankacc = bankservice.GetBankAccountById(el.BankAccountID); if (bankacc == null) { info.Append(StringSource.BankAccountNotFound()); } else { currency = bankservice.GetCurrencyById(bankacc.CurrencyID); if (currency == null) { info.Append(StringSource.CurrencyNotFound()); } else { info.Append(StringSource.CardAccountInformation(el, bankacc, currency)); } } } } Information = info.ToString(); return(true); }