public GenericResponse <List <DepositWithdrawalContract> > GetAllDepositWithdrawals(DepositWithdrawalRequest request) { DbOperation dbOperation = new DbOperation(); try { List <DepositWithdrawalContract> depositWithdrawalsList = new List <DepositWithdrawalContract>(); SqlDataReader reader = dbOperation.GetData("TRN.sel_GelAllDepositWithDrawals"); if (reader.HasRows) { while (reader.Read()) { depositWithdrawalsList.Add(new DepositWithdrawalContract() { Id = (int)reader["Id"], AccountNumber = reader["AccountNumber"].ToString(), AccountSuffix = reader["AccountSuffix"].ToString(), FormedUserId = (int?)reader["FormedUserId"], TransferBranchId = (int?)reader["TransferBranchId"], TransferDate = (DateTime?)reader["TransferDate"], TransferDescription = reader["TransferDescription"].ToString(), TransferType = (int?)reader["TransferType"], CurrencyId = (int?)reader["CurrencyId"], TransferAmount = (decimal)reader["TransferAmount"], CurrencyCode = reader["CurrencyCode"].ToString(), UserName = reader["UserName"].ToString(), BranchName = reader["BranchName"].ToString() }); } return(new GenericResponse <List <DepositWithdrawalContract> >() { IsSuccess = true, Value = depositWithdrawalsList }); } return(new GenericResponse <List <DepositWithdrawalContract> >() { IsSuccess = false, ErrorMessage = "Herhangi bir havale kaydı bulunamadı.", Value = null }); } catch (Exception ex) { return(new GenericResponse <List <DepositWithdrawalContract> >() { Value = null, IsSuccess = false, ErrorMessage = "GetAllDepositWithdrawals işlemi başarısız!" }); throw ex; } }
public GenericResponse <List <BranchContract> > FilterBranchsByProperties(BranchRequest request) { DbOperation dbOperation = new DbOperation(); SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@Id", request.DataContract.Id), new SqlParameter("@BranchName", request.DataContract.BranchName), new SqlParameter("@Adress", request.DataContract.Adress), new SqlParameter("@CityId", request.DataContract.CityId), new SqlParameter("@DateOfLaunch", request.DataContract.DateOfLaunch), new SqlParameter("@MailAdress", request.DataContract.MailAdress), new SqlParameter("@PhoneNumber", request.DataContract.PhoneNumber), }; try { List <BranchContract> branchsList = new List <BranchContract>(); SqlDataReader reader = dbOperation.GetData("COR.sel_FilterBranchsByProperties", parameters); while (reader.Read()) { branchsList.Add(new BranchContract() { Id = (int)reader["Id"], CityId = (int)reader["CityId"], Adress = (string)reader["Adress"], MailAdress = (string)reader["MailAdress"], BranchName = (string)reader["BranchName"], DateOfLaunch = (DateTime)reader["DateOfLaunch"], PhoneNumber = (string)reader["PhoneNumber"], City = reader["CityName"].ToString() }); } return(new GenericResponse <List <BranchContract> >() { Value = branchsList, IsSuccess = true }); } catch { return(new GenericResponse <List <BranchContract> >() { IsSuccess = false, ErrorMessage = "FilterBranchsByProperties isteği başarısız." }); } }
public GenericResponse <List <BranchContract> > GetAllBranches(BranchRequest request) { DbOperation dbOperation = new DbOperation(); List <BranchContract> branchContracts = new List <BranchContract>(); try { SqlDataReader reader = dbOperation.GetData("COR.sel_GetAllBranches"); while (reader.Read()) { branchContracts.Add(new BranchContract() { Id = (int)reader["Id"], CityId = (int)reader["CityId"], Adress = (string)reader["Adress"], MailAdress = (string)reader["MailAdress"], BranchName = (string)reader["BranchName"], DateOfLaunch = (DateTime)reader["DateOfLaunch"], PhoneNumber = (string)reader["PhoneNumber"], City = reader["CityName"].ToString() }); } } catch (Exception) { return(new GenericResponse <List <BranchContract> >() { ErrorMessage = "GetAllBranches metodu başarısız.", IsSuccess = false }); } if (branchContracts.Count > 0) { return(new GenericResponse <List <BranchContract> >() { Value = branchContracts, IsSuccess = true }); } else { return(new GenericResponse <List <BranchContract> >() { IsSuccess = false, ErrorMessage = "Hiç şube getirilemedi." }); } }
public GenericResponse <List <AccountContract> > GetAllAccounts(AccountRequest request) { DbOperation dbOperation = new DbOperation(); List <AccountContract> accountContracts = new List <AccountContract>(); SqlDataReader reader = dbOperation.GetData("CUS.sel_GetAllAccounts"); try { while (reader.Read()) { accountContracts.Add(new AccountContract() { Id = Convert.ToInt32(reader["Id"]), BranchId = (int)reader["BranchId"], CustomerId = (int)reader["CustomerId"], AdditionNo = (int)reader["AdditionNo"], CurrencyId = (int)reader["CurrencyId"], Balance = (decimal)reader["Balance"], DateOfFormation = (DateTime)reader["DateOfFormation"], IBAN = reader["IBAN"].ToString(), IsActive = (bool)reader["IsActive"], /*DateOfDeactivation = (DateTime)reader["DateOfDeactivation"]*/ FormedUserId = (int)reader["FormedUserId"], BranchName = reader["BranchName"].ToString(), CurrencyCode = reader["code"].ToString(), FormedUserName = reader["UserName"].ToString() /*DateOfLastTrasaction = (DateTime)reader["DateOfLastTransaction"]*/ }); } return(new GenericResponse <List <AccountContract> >() { IsSuccess = true, Value = accountContracts }); } catch (Exception) { return(new GenericResponse <List <AccountContract> >() { IsSuccess = false, ErrorMessage = "GetAllAccounts operasyonu başarısız" }); } }
public GenericResponse <CustomerContract> UpdateCustomerbyId(CustomerRequest request) { DbOperation dbOperation = new DbOperation(); SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("CustomerId", request.DataContract.CustomerId), new SqlParameter("@CustomerName", request.DataContract.CustomerName), new SqlParameter("@CustomerLastName", request.DataContract.CustomerLastName), new SqlParameter("@CitizenshipId", request.DataContract.CitizenshipId), new SqlParameter("@MotherName", request.DataContract.MotherName), new SqlParameter("@FatherName", request.DataContract.FatherName), new SqlParameter("@PlaceOfBirth", request.DataContract.PlaceOfBirth), new SqlParameter("@DateOfBirth", request.DataContract.DateOfBirth), new SqlParameter("@JobId", request.DataContract.JobId), new SqlParameter("@EducationLvId", request.DataContract.EducationLvId), new SqlParameter("@BranchId", request.DataContract.BranchId) }; try { var response = dbOperation.spExecuteScalar("CUS.upd_UpdateCustomerbyId", parameters); //TO-DO: DataContract'taki telefon numaraları ve email adresleri için işlem yapılmıyor. Eklenecek. return(new GenericResponse <CustomerContract>() { IsSuccess = true }); } catch (Exception) { return(new GenericResponse <CustomerContract>() { IsSuccess = false, ErrorMessage = "UpdateCustomerbyId isteği başarısız oldu." }); } }
public GenericResponse <List <RemittanceContract> > FilterRemittancesByProperties(RemittanceRequest request) { DbOperation dbOperation = new DbOperation(); SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@StartingDate", request.DataContract.StartingDate), new SqlParameter("@EndingDate", request.DataContract.EndingDate), new SqlParameter("@CurrencyId", request.DataContract.CurrencyId), new SqlParameter("@StartingBalance", request.DataContract.StartingBalance), new SqlParameter("@EndingBalance", request.DataContract.EndingBalance), new SqlParameter("SenderAccountNumber", request.DataContract.SenderAccountNumber), new SqlParameter("ReceiverAccountNumber", request.DataContract.ReceiverAccountNumber) }; try { List <RemittanceContract> remittancesList = new List <RemittanceContract>(); SqlDataReader reader = dbOperation.GetData("TRN.sel_FilterRemittancesByProperties", parameters); if (reader.HasRows) { while (reader.Read()) { remittancesList.Add(new RemittanceContract() { Id = (int)reader["Id"], ReceiverAccountNumber = reader["ReceiverAccountNumber"].ToString(), ReceiverAccountSuffix = reader["ReceiverAccountSuffix"].ToString(), SenderAccountNumber = reader["SenderAccountNumber"].ToString(), SenderAccountSuffix = reader["SenderAccountSuffix"].ToString(), TransactionStatus = (int?)reader["TransactionStatus"], TransactionDate = (DateTime?)reader["TransactionDate"], TransactionDescription = reader["TransactionDescription"].ToString(), TransferAmount = (decimal?)reader["TransferAmount"], ReceiverBranchName = reader["ReceiverBranchName"].ToString(), SenderBranchName = reader["SenderBranchName"].ToString(), SenderLastName = reader["SenderLastName"].ToString(), SenderName = reader["SenderName"].ToString(), ReceiverLastName = reader["ReceiverLastName"].ToString(), ReceiverName = reader["ReceiverName"].ToString(), CurrencyId = (int?)reader["CurrencyId"], CurrencyCode = reader["CurrencyCode"].ToString() }); } return(new GenericResponse <List <RemittanceContract> >() { IsSuccess = true, Value = remittancesList }); } return(new GenericResponse <List <RemittanceContract> >() { IsSuccess = false, ErrorMessage = "Herhangi bir havale kaydı bulunamadı." }); } catch (Exception ex) { return(new GenericResponse <List <RemittanceContract> > { ErrorMessage = "FilterRemittancesByProperties işlemi başarısız!", IsSuccess = false, Value = null }); throw ex; } }
public GenericResponse <CustomerContract> CustomerAdd(CustomerRequest request) { Business.Banking.Email emailBusiness = new Email(); Business.Banking.Phone phoneBusiness = new Phone(); DbOperation dbOperation = new DbOperation(); SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@CustomerName", request.DataContract.CustomerName), new SqlParameter("@CustomerLastName", request.DataContract.CustomerLastName), new SqlParameter("@CitizenshipId", request.DataContract.CitizenshipId), new SqlParameter("@MotherName", request.DataContract.MotherName), new SqlParameter("@FatherName", request.DataContract.FatherName), new SqlParameter("@PlaceOfBirth", request.DataContract.PlaceOfBirth), new SqlParameter("@DateOfBirth", request.DataContract.DateOfBirth), new SqlParameter("@JobId", request.DataContract.JobId), new SqlParameter("@EducationLvId", request.DataContract.EducationLvId), new SqlParameter("@BranchId", request.DataContract.BranchId) }; try { int id = Convert.ToInt32(dbOperation.spExecuteScalar("CUS.ins_AddNewCustomer", parameters)); if (request.DataContract.Emails != null) { try { foreach (CustomerEmailContract email in request.DataContract.Emails) { emailBusiness.EmailAdd(new CustomerEmailContract() { CustomerId = id, EmailType = email.EmailType, MailAdress = email.MailAdress }); } } catch (Exception) { return(new GenericResponse <CustomerContract>() { IsSuccess = false, ErrorMessage = "EmailAdd operasyonu başarısız!" }); } } if (request.DataContract.PhoneNumbers != null) { try { foreach (CustomerPhoneContract phone in request.DataContract.PhoneNumbers) { phoneBusiness.PhoneAdd(new CustomerPhoneContract() { CustomerId = id, PhoneType = phone.PhoneType, PhoneNumber = phone.PhoneNumber }); } } catch (Exception) { return(new GenericResponse <CustomerContract>() { IsSuccess = false, ErrorMessage = "PhoneNumberAdd operasyonu başarısız!" }); } } return(new GenericResponse <CustomerContract>() { Value = new CustomerContract { CustomerId = id }, IsSuccess = true }); } catch (Exception) { return(new GenericResponse <CustomerContract>() { IsSuccess = false, ErrorMessage = "CustomerAdd isteği başarısız." }); } }
public GenericResponse <List <CustomerContract> > GetAllCustomers(CustomerRequest request) { DbOperation dbOperation = new DbOperation(); List <CustomerContract> dataContracts = new List <CustomerContract>(); SqlDataReader reader = dbOperation.GetData("CUS.sel_AllCustomers"); while (reader.Read()) { dataContracts.Add(new CustomerContract { CustomerId = Convert.ToInt32(reader["CustomerId"]), CustomerName = reader["CustomerName"].ToString(), CustomerLastName = reader["CustomerLastName"].ToString(), CitizenshipId = reader["CitizenshipId"].ToString(), MotherName = reader["MotherName"].ToString(), FatherName = reader["FatherName"].ToString(), PlaceOfBirth = reader["PlaceOfBirth"].ToString(), JobId = (int)reader["JobId"], EducationLvId = (int)reader["EducationLvId"], BranchId = (int)reader["BranchId"], DateOfBirth = (DateTime)reader["DateOfBirth"], EducationLevelName = reader["EducationLevel"].ToString(), JobName = reader["JobName"].ToString(), BranchName = reader["BranchName"].ToString(), PhoneNumbers = GetCustomerPhonesByCustomerId(Convert.ToInt32(reader["CustomerId"])), //Bunda sakınca var mı? Sor Emails = GetCustomerEmailsByCustomerId(Convert.ToInt32(reader["CustomerId"])) }); } // public int? CustomerId { get; set; } //public string CustomerName { get; set; } //public string CustomerLastName { get; set; } //public string CitizenshipId { get; set; } //public string MotherName { get; set; } //public string FatherName { get; set; } //public string PlaceOfBirth { get; set; } //public int JobId { get; set; } //public int EducationLvId { get; set; } //public DateTime DateOfBirth { get; set; } //public List<CustomerPhoneContract> PhoneNumbers { get; set; } //public List<CustomerEmailContract> Emails { get; set; } //SqlConnection sqlConnection = new SqlConnection(dbOperation.GetConnectionString()); //SqlCommand sqlCommand = new SqlCommand //{ // Connection = sqlConnection, // CommandType = CommandType.StoredProcedure, // CommandText = "CUS.sel_AllCustomers" //}; //using (sqlConnection) //{ // sqlConnection.Open(); // using (SqlDataReader reader = sqlCommand.ExecuteReader()) // { // while (reader.Read()) // { //dataContracts.Add(new CustomerContract //{ // CustomerId = Convert.ToInt32(reader["CustomerId"]), // CustomerName = reader["CustomerName"].ToString(), // CitizenshipId = reader["CitizenshipId"].ToString() //}); // } // } //} if (dataContracts.Count > 0) { return(new GenericResponse <List <CustomerContract> >() { Value = dataContracts, IsSuccess = true }); } return(new GenericResponse <List <CustomerContract> >() { ErrorMessage = "GetAllCustomers işlemi başarısız oldu.", IsSuccess = false }); }
public GenericResponse <List <AccountContract> > FilterAccountsByProperties(AccountRequest request) { DbOperation dbOperation = new DbOperation(); List <AccountContract> accountContracts = new List <AccountContract>(); SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@Id", request.DataContract.Id), new SqlParameter("@BranchId", request.DataContract.BranchId), new SqlParameter("@CustomerId", request.DataContract.CustomerId), new SqlParameter("@AdditionNo", request.DataContract.AdditionNo), new SqlParameter("@CurrencyId", request.DataContract.CurrencyId), new SqlParameter("@Balance", request.DataContract.Balance), new SqlParameter("@IBAN", request.DataContract.IBAN), new SqlParameter("@IsActive", request.DataContract.IsActive), new SqlParameter("@FormedUserId", request.DataContract.FormedUserId), new SqlParameter("@DateOfFormation", request.DataContract.DateOfFormation), //new SqlParameter("@DateOfDeactivation",request.DataContract.DateOfDeactivation), //new SqlParameter("@DateOfLastTransaction",request.DataContract.DateOfLastTrasaction) }; try { List <AccountContract> accounts = new List <AccountContract>(); SqlDataReader reader = dbOperation.GetData("CUS.sel_FilterAccountsByProperties", parameters); while (reader.Read()) { accounts.Add(new AccountContract() { Id = Convert.ToInt32(reader["Id"]), BranchId = (int)reader["BranchId"], CustomerId = (int)reader["CustomerId"], AdditionNo = (int)reader["AdditionNo"], CurrencyId = (int)reader["CurrencyId"], Balance = (decimal)reader["Balance"], DateOfFormation = (DateTime)reader["DateOfFormation"], IBAN = reader["IBAN"].ToString(), IsActive = (bool)reader["IsActive"], //DateOfDeactivation = (DateTime)reader["DateOfDeactivation"], FormedUserId = (int)reader["FormedUserId"], BranchName = reader["BranchName"].ToString(), CurrencyCode = reader["code"].ToString(), FormedUserName = reader["UserName"].ToString() //DateOfLastTrasaction = (DateTime)reader["DateOfLastTransaction"] }); } return(new GenericResponse <List <AccountContract> >() { Value = accounts, IsSuccess = true }); } catch (Exception) { return(new GenericResponse <List <AccountContract> >() { ErrorMessage = "FilterAccountsByProperties operasyonu başarısız.", IsSuccess = false }); throw; } }
public GenericResponse <List <DepositWithdrawalContract> > FilterDepositWithdrawalsByProperties(DepositWithdrawalRequest request) { DbOperation dbOperation = new DbOperation(); SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@StartingDate", request.DataContract.StartingDate), new SqlParameter("@TransferBranchId", request.DataContract.TransferBranchId), new SqlParameter("@EndingDate", request.DataContract.EndingDate), new SqlParameter("@CurrencyId", request.DataContract.CurrencyId), new SqlParameter("@AccountNumber", request.DataContract.AccountNumber), new SqlParameter("@AccountSuffix", request.DataContract.AccountSuffix), new SqlParameter("@StartingAmount", request.DataContract.StartingAmount), new SqlParameter("@EndingAmount", request.DataContract.EndingAmount), new SqlParameter("@FormedUserId", request.DataContract.FormedUserId), new SqlParameter("@Id", request.DataContract.Id), new SqlParameter("@TransferDate", request.DataContract.TransferDate), new SqlParameter("@TransferDescription", request.DataContract.TransferDescription), new SqlParameter("@TransferType", request.DataContract.TransferType) }; try { List <DepositWithdrawalContract> depositWithdrawalsList = new List <DepositWithdrawalContract>(); SqlDataReader reader = dbOperation.GetData("TRN.sel_FilterDepositWithdrawalsByProperties", parameters); if (reader.HasRows) { while (reader.Read()) { depositWithdrawalsList.Add(new DepositWithdrawalContract() { Id = (int)reader["Id"], AccountNumber = reader["AccountNumber"].ToString(), AccountSuffix = reader["AccountSuffix"].ToString(), FormedUserId = (int?)reader["FormedUserId"], TransferBranchId = (int?)reader["TransferBranchId"], TransferDate = (DateTime?)reader["TransferDate"], TransferDescription = reader["TransferDescription"].ToString(), TransferType = (int?)reader["TransferType"], CurrencyId = (int?)reader["CurrencyId"], TransferAmount = (decimal)reader["TransferAmount"], CurrencyCode = reader["CurrencyCode"].ToString(), UserName = reader["UserName"].ToString(), BranchName = reader["BranchName"].ToString() }); } return(new GenericResponse <List <DepositWithdrawalContract> >() { IsSuccess = true, Value = depositWithdrawalsList }); } return(new GenericResponse <List <DepositWithdrawalContract> >() { IsSuccess = false, ErrorMessage = "Herhangi bir havale kaydı bulunamadı.", Value = null }); } catch (Exception ex) { return(new GenericResponse <List <DepositWithdrawalContract> > { ErrorMessage = "FilterDepositWithdrawalsByProperties işlemi başarısız!", IsSuccess = false, Value = null }); throw ex; } }