public void CustomerBL_GetAllAtRisk_ReturnValue() { //arrange var customers = new List <Customer> { new Customer { Id = 1, Name = "John" }, new Customer { Id = 4, Name = "Grace" } }; var expectedValue = new List <CustomerDto> { new CustomerDto { Id = 1, Name = "John" }, new CustomerDto { Id = 4, Name = "Grace" } }; var bl = new CustomerBL(_mockMapper.Object, _mockCustomerRepository.Object, _mockBetRepository.Object, _mockCustomerBetRepository.Object); _mockCustomerBetRepository.Setup(x => x.GetAllCustomerAtRisk()).Returns(customers); _mockMapper.Setup(x => x.Map <List <CustomerDto> >(customers)).Returns(expectedValue); //act var result = bl.GetAllAtRisk(); //assert Assert.AreEqual(expectedValue.Count, result.Count); }
public static void CreateLoan() { try { Console.WriteLine("enter your customer ID"); int id = Convert.ToInt32(Console.ReadLine()); var cust = CustomerBL.GetCust(id); Console.WriteLine("enter your loan account name"); var name = Console.ReadLine(); Console.WriteLine("enter your loan amount"); double amount = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("enter your interest rate"); double rate = Convert.ToDouble(Console.ReadLine()); Loan acc = new Loan(name, amount, rate); CustomerBL.AddLoan(cust, acc); Console.WriteLine($"loan account of {acc.Name} is created"); } catch (Exception ex) { Console.WriteLine("registeration fail, please try again"); } }
/// <summary> /// Displays list of Customers. /// </summary> /// <returns></returns> public static async Task ViewCustomers() { try { using (ICustomerBL customerBL = new CustomerBL()) { //Get and display list of system users. List <Customer> customers = await customerBL.GetAllCustomersBL(); WriteLine("CUSTOMERS:"); if (customers != null && customers?.Count > 0) { WriteLine("#\tName\tMobile\tEmail\tCreated\tModified"); int serial = 0; foreach (var customer in customers) { serial++; WriteLine($"{serial}\t{customer.CustomerName}\t{customer.CustomerMobile}\t{customer.Email}\t{customer.CreationDateTime}\t{customer.LastModifiedDateTime}"); } } } } catch (PecuniaException ex) { ExceptionLogger.LogException(ex); WriteLine(ex.Message); } }
static void TermAction(TermDeposit acc, string actionType) { switch (actionType.ToLower()) { case "withdraw": Console.WriteLine("enter withdraw amount"); double withdraw = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("enter withdraw year"); int year = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("enter withdraw month"); int month = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("enter withdraw day"); int day = Convert.ToInt32(Console.ReadLine()); DateTime end = new DateTime(year, month, day); acc.Withdraw(withdraw, end); break; case "transfer": Console.WriteLine("enter 2nd customer id "); int custid = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("enter 2nd account id"); int accId = Convert.ToInt32(Console.ReadLine()); var acc2 = CustomerBL.GetAccount(custid, accId); double transfer = Convert.ToInt32(Console.ReadLine()); acc.Transfer(acc, acc2, transfer); break; default: break; } }
public static void CreateBusiness() { try { Console.WriteLine("enter your customer ID"); int id = Convert.ToInt32(Console.ReadLine()); var cust = CustomerBL.GetCust(id); Console.WriteLine("enter your new business account name"); var name = Console.ReadLine(); Console.WriteLine("enter checking your account amount"); double amount = Convert.ToDouble(Console.ReadLine()); BusinessAccount acc = new BusinessAccount(name, amount); CustomerBL.AddBusiness(cust, acc); Console.WriteLine($"Business Account of {acc.Name} is created"); } catch (Exception ex) { Console.WriteLine("registeration fail, please try again"); } }
public ActionResult Register(CustomerViewModel customerViewModel) { // Create object of CustomerBL CustomerBL customerBL = new CustomerBL(); //Creating object of Customer EntityModel Customer customer = new Customer(); customer.CustomerName = customerViewModel.CustomerName; customer.CustomerMobile = customerViewModel.CustomerMobile; customer.DefaultShippingAddress = customerViewModel.DefaultShippingAddress; customer.Email = customerViewModel.Email; customer.Password = customerViewModel.CustomerPassword; customer.Password = customerViewModel.ConfirmNewPassword; //Invoke the AddProduct method BL bool isAdded = customerBL.AddCustomerBL(customer); if (isAdded) { //Go to Index action method of Product Controller return(RedirectToAction("Index", "Login")); } else { //Return plain html / plain string return(Content("Sorry you were not registered")); } }
private static async Task AddCustomer() { try { Customer newCustomer = new Customer(); WriteLine("Enter Customer Name :"); newCustomer.CustomerID = default; newCustomer.CustomerName = Console.ReadLine(); WriteLine("Enter Phone Number :"); newCustomer.CustomerMobile = Console.ReadLine(); WriteLine("Enter Customer's Email"); newCustomer.Email = Console.ReadLine(); WriteLine("Enter Customer's Password"); newCustomer.Password = Console.ReadLine(); bool customerAdded; Guid newCustomerGuid; CustomerBL cbl = new CustomerBL(); (customerAdded, newCustomerGuid) = await cbl.AddCustomerBL(newCustomer); if (customerAdded) { Console.WriteLine("Customer Added"); Console.WriteLine("Your User id is " + newCustomer.Email); } else { Console.WriteLine("Customer Not Added"); } } catch (EcommerceException ex) { Console.WriteLine(ex.Message); } }
private void btnSave_Click(object sender, EventArgs e) { var dto = new CustomerExchangeDTO() { CustomerId = Convert.ToInt32(txtCustomerId.Text), Model = txtModel.Text, Color = txtColor.Text, MfgDate = Convert.ToDateTime(dtMfgDate.Text), EngineCondition = txtEngCondition.Text, OutlookCondition = txtOutlookCondition.Text, CustomerRate = Convert.ToInt32(txtCustomerRate.Text == "" ? "0" : txtCustomerRate.Text), BrokerName1 = txtBN1.Text, Rate1 = Convert.ToInt32(txtRate1.Text == "" ? "0" : txtRate1.Text), MobileNo1 = txtMNo1.Text, DifferenceAmount1 = Convert.ToInt32(txtDA1.Text == "" ? "0" : txtDA1.Text), BrokerName2 = txtBN2.Text, Rate2 = Convert.ToInt32(txtRate2.Text == "" ? "0" : txtRate2.Text), MobileNo2 = txtMNo2.Text, DifferenceAmount2 = Convert.ToInt32(txtDA2.Text == "" ? "0" : txtDA2.Text), ExchangeRemark = txtRemarks.Text, FinalAmount = Convert.ToInt32(txtFinalAmount.Text == "" ? "0" : txtFinalAmount.Text), CreatedBy = GlobalSetup.Userid, CreatedDate = DateTime.Now, ModifiedBy = GlobalSetup.Userid, ModifiedDate = DateTime.Now }; CustomerBL obj = new CustomerBL(); var exchangeVehicleId = obj.SaveExchangeVehicle(dto); txtExchangeVehilceId.Text = exchangeVehicleId.ToString(); this.Close(); }
public List <CustomerModel> GetCustomers(UICustomerSC sc) { CustomerBL bl = new CustomerBL(); List <Customer> customerDBList = bl.Search(sc); return(customerDBList.Select(c => new CustomerModel(c, false)).ToList()); }
/// <summary> /// Updates Customer /// </summary> /// <returns></returns> public static async Task UpdateCustomerAccount() { try { using (ICustomerBL CustomerBL = new CustomerBL()) { //Read Sl.No Customer Customer = await CustomerBL.GetCustomerByEmailBL(CommonData.CurrentUser.Email); Write("Name: "); Customer.CustomerName = ReadLine(); Write("Email: "); Customer.Email = ReadLine(); //Invoke UpdateCustomerBL method to update bool isUpdated = await CustomerBL.UpdateCustomerBL(Customer); if (isUpdated) { WriteLine(" Account Updated"); } } } catch (System.Exception ex) { ExceptionLogger.LogException(ex); WriteLine(ex.Message); } }
public CustomerMenu(CustomerBL customerBL, OrderBL newOrder, LocationBL locationBL) { _customerBL = customerBL; _orderBL = newOrder; _locationBL = locationBL; _inputValidation = new InputValidation(); }
//******************************** DELETING ACCOUNT DETAILS ****************************************** private void buttonAccountClosureSubmit_Click(object sender, EventArgs e) { int output = 0; try { if (MessageBox.Show("Do you want to delete", " S I S", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { output = CustomerBL.DeleteAccountDetails(textBoxAccountNumber.Text); string Title = "Account Handling"; if (output > 0) { MessageBox.Show("Account deleted successfully !!!", Title); } else { MessageBox.Show("Try again later !!!", Title); } } } catch (Exception ex) { Console.Out.WriteLine(ex.Message.ToString()); } }
public ManagerMenu(LocationBL locationBL, OrderBL orderBL, InventoryBL inventoryBL, CustomerBL customerBL) { this.locationBL = locationBL; this.orderBL = orderBL; this.inventoryBL = inventoryBL; this.customerBL = customerBL; }
public void UpdateCustomer() { LoyaltyPointSystemEntities db = new LoyaltyPointSystemEntities(); CustomerBL Cusbl = new CustomerBL(); Models.Customer Custb = new Models.Customer(); var data = db.Customers.ToList().FirstOrDefault(x => x.ID == CustomerID); double points = 0; if (Convert.ToDecimal(txtTotalAmount.Text) == 100) { points = double.Parse("10", CultureInfo.InvariantCulture); Custb.Loyalty_Points = (decimal)points; } else if (Convert.ToDecimal(txtTotalAmount.Text) == 1000) { points = double.Parse("100", CultureInfo.InvariantCulture); Custb.Loyalty_Points = (decimal)points; } else if (Convert.ToDecimal(txtTotalAmount.Text) < 100) { points = double.Parse("1", CultureInfo.InvariantCulture); Custb.Loyalty_Points = (decimal)points; } else if (Convert.ToDecimal(txtTotalAmount.Text) > 1000) { points = double.Parse("150", CultureInfo.InvariantCulture); Custb.Loyalty_Points = (decimal)points; } Cusbl.UpdateCustomer(Custb); }
public ManagerMenu(LocationBL locationbl, CustomerBL customerBL, OrderBL orderBL) { _locationBL = locationbl; _customerBL = customerBL; _orderBL = orderBL; _inputValidation = new InputValidation(); }
public List <CustomerModel> GetCustomerLookup() { CustomerBL bl = new CustomerBL(); List <Customer> customerDBList = bl.Search(null); return(customerDBList.Select(c => new CustomerModel(c, true)).ToList()); }
private void btnUpdate_Click(object sender, EventArgs e) { if (txtCusID.Text == string.Empty) { MessageBox.Show("Please Select A Customer ID "); return; } else if (MessageBox.Show("Are You Sure To Update Customer?", "UpdateAlert", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { CustomerBL objCus = new CustomerBL() { CustomerID = Convert.ToInt32(txtCusID.Text), Name = txtCusName.Text, Address = txtAddress.Text, Contact = txtContact.Text, CusTypeID = Convert.ToInt32(txtCusType.SelectedValue), Email = txtEmail.Text, ZoneID = Convert.ToInt32(txtZoneID.SelectedValue) }; objCus.Update(); MessageBox.Show("Customer Update Successfull"); LoadData(); ClearGroup(); // Clear(); } else { MessageBox.Show("Customer Not Update"); } }
public ActionResult ViewCustomer(string searchBy, string search) { ViewBag.Message = "View all customer"; var data = CustomerBL.ListAllCustomers(); List <CustomerModel> customers = new List <CustomerModel>(); foreach (var cust in data) { customers.Add(new CustomerModel { ID = cust.CustomerID, Name = cust.Name, Surname = cust.Surname, Address = cust.Address, Town = cust.Town, Country = cust.Country, Mail = cust.Mail, Date_of_birth = cust.DOB, IsActive = cust.IsActive, Username = cust.Username, Password = cust.Password, Rating = cust.Rating }); } return(View(customers)); }
public ActionResult EditPassword(CustomerViewModel customerViewModel) { /* System.Diagnostics.Debug.WriteLine(TempData["employeeEmail"]); * System.Diagnostics.Debug.WriteLine(employeeHomeModel.EmployeePassword);*/ bool isUpdated = false; CustomerBL customerBL = new CustomerBL(); Customer customer = new Customer(); Customer isCorrectCustomer = new Customer(); customer.CustomerID = Guid.Parse(HttpContext.Session.GetString("customerID")); customer.Password = customerViewModel.ConfirmNewPassword; isCorrectCustomer = customerBL.GetCustomerByEmailAndPasswordBL(Convert.ToString(TempData["customerEmail"]), customerViewModel.CustomerPassword); if (isCorrectCustomer != null) { isUpdated = customerBL.UpdateCustomerPasswordBL(customer); if (isUpdated) { return(RedirectToAction("CustomerIndex", "CustomerHome", new { customerID = TempData["customerID"] })); } else { return(Content("Your password was not updated")); } } else { return(RedirectToAction("DisplayMessage", "ShowMessage", new { Message = "Previous password entered is incorrect!" })); //Response.Write("<script>alert('Previous password entered is incorrect!')</script>"); //return RedirectToAction("EditPassword","EmployeeHome", new { employeeID = TempData["employeeID"] }); } }
//Method to search Customer static void SearchCustomer() { try { Console.WriteLine("Enter Customer ID"); string cid = Console.ReadLine(); CustomerBL cbl = new CustomerBL(); Customer c = cbl.SearchCustomer(cid); if (c != null) { Console.WriteLine("CustomerID:{0} CustomerName:{1} Gender:{2} DateOfBirth:{3} Address:{4}", c.CustomerId, c.CustomerName, c.Gender, c.DateOfBirth, c.Address); } else { Console.WriteLine("No such Customer found."); } } catch (FormatException ex) { Console.WriteLine(ex.Message); } catch (SystemException ex) { Console.WriteLine(ex.Message); } }
private void btnCusName_Click(object sender, EventArgs e) { CustomerReport objCus = new CustomerReport(); rptViewer objView = new rptViewer(); if (!string.IsNullOrEmpty(txtSearch.Text)) { objCus.SetParameterValue("@CustomerID", txtSearch.Text); CustomerBL objBL = new CustomerBL() { CustomerID = Convert.ToInt32(txtSearch.Text), }; var dt = objBL.SelectByCus(); if (dt != null) { objCus.SetDataSource(dt); objView.crptViewer.ReportSource = objCus; objView.WindowState = FormWindowState.Maximized; objView.ShowDialog(); } //crptViewerCus.ReportSource = objCus; else { MessageBox.Show("No Record Found"); } txtSearch.Clear(); } else { MessageBox.Show("Please Enter Enter ID"); } }
public void LoginTest4() { CustomerBL userBL = new CustomerBL(); Customer cs = null; Assert.Equal(cs, userBL.GetUserByUsernameAndPass("customer02", "2345677897")); }
static void LoanAction(Loan acc, string actionType) { switch (actionType.ToLower()) { case "deposit": Console.WriteLine("enter amount"); double deposit = Convert.ToInt32(Console.ReadLine()); acc.Deposit(deposit); break; case "withdraw": Console.WriteLine("enter amount"); double withdraw = Convert.ToInt32(Console.ReadLine()); acc.Withdraw(withdraw); break; case "transfer": Console.WriteLine("enter 2nd customer id "); int custid = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("enter 2nd account id"); int accId = Convert.ToInt32(Console.ReadLine()); var acc2 = CustomerBL.GetAccount(custid, accId); double transfer = Convert.ToInt32(Console.ReadLine()); acc.Transfer(acc, acc2, transfer); break; default: break; } }
public static async Task UpdateCustomerAccount() { try { using (ICustomerBL customerBL = new CustomerBL()) { Customer customer = await customerBL.GetCustomerByEmailBL(UserData.CurrentUser.Email); Write("Name: "); customer.CustomerName = ReadLine(); Write("Email: "); customer.Email = ReadLine(); bool isUpdated = await customerBL.UpdateCustomerBL(customer); if (isUpdated) { WriteLine(" Account Updated"); } } } catch (Exception ex) { ExceptionLogger.LogException(ex); WriteLine(ex.Message); } }
public static void CreateTermDeposit() { try { Console.WriteLine("enter your customer ID"); int id = Convert.ToInt32(Console.ReadLine()); var cust = CustomerBL.GetCust(id); Console.WriteLine("enter your new TermDeposit account name"); var name = Console.ReadLine(); Console.WriteLine("enter your deposit amount"); double amount = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("enter your deposit time (in days)"); int days = Convert.ToInt32(Console.ReadLine()); var acc = new TermDeposit(name, amount, days); CustomerBL.AddTermDeposit(cust, acc); Console.WriteLine($"TermDeposit account of {acc.Name} is created"); } catch (Exception ex) { Console.WriteLine("registeration fail, please try again"); } }
public static async Task DeleteCustomerAccount() { try { using (ICustomerBL customerBL = new CustomerBL()) { Write("Current Password: "******"Are you sure? (Y/N): "); string confirmation = ReadLine(); Customer customer = await customerBL.GetCustomerByEmailAndPasswordBL(UserData.CurrentUser.Email, currentPassword); if (confirmation.Equals("Y", StringComparison.OrdinalIgnoreCase)) { bool isDeleted = await customerBL.DeleteCustomerBL(customer.CustomerID); if (isDeleted) { WriteLine("Customer Account Deleted"); } } } } catch (Exception ex) { ExceptionLogger.LogException(ex); WriteLine(ex.Message); } }
private void btnRouteSearch_Click(object sender, EventArgs e) { dgvLedger.DataSource = null; if (txtRoute.Text != "---Select---") { CustomerBL objLedger = new CustomerBL() { ZoneID = Convert.ToInt32(txtRoute.SelectedValue) }; var dt = objLedger.SearchByZone(); if (dt != null) { dgvLedger.DataSource = dt; } else { MessageBox.Show("No Record Found " + txtRoute.Text); } } else { MessageBox.Show("Please Select Route Name"); } }
/// <summary> /// adminVerify is a bool method to verify admin credentials with the credentials that is input by user. /// </summary> /// <returns></returns> public static bool AdminVerify() { bool adminVerified = false; try { Console.WriteLine("\t\t\t\t********************* Login Credentials *************************"); Console.WriteLine("**Hint:- for username and password go into Capgemini.CustomerManagementSystem.Entity project and Find username and password in adminverify method of CustomerEntity class."); Console.WriteLine("\nEnter Username:"******"\nEnter Password:"); string pass = Console.ReadLine(); adminVerified = CustomerBL.AdminVerify(uname, pass); } catch (CustomerManagementException ex) { Console.WriteLine(ex.Message); } catch (Exception ex) { Console.WriteLine(ex.InnerException.Message); AdminVerify(); } return(adminVerified); }
public void Begin(string pathFile) { using (var reader = new StreamReader(pathFile)) { IService <ProductBL> productService = new ProductService(new ProductRepository(new SalesContext()), _mapper); IService <OrderBL> orderService = new OrderService(new OrderRepository(new SalesContext()), _mapper); IService <ManagerBL> managerService = new ManagerService(new ManagerRepository(new SalesContext()), _mapper); IService <ReportBL> reportService = new ReportService(new ReportRepository(new SalesContext()), _mapper); IService <CustomerBL> customerService = new CustomerService(new CustomerRepository(new SalesContext()), _mapper); using (var csvReader = new CsvFileReader(pathFile)) { csvReader.Dilimiter = ';'; string record = string.Empty; while ((record = reader.ReadLine()) != null) { csvReader.CreateObject(record); ProductBL product = csvReader.GetProduct(); CustomerBL customer = csvReader.GetCustomer(); ManagerBL manager = csvReader.GetManager(); DoWorkWithEntity(ref product, productService, _lock); DoWorkWithEntity(ref manager, managerService, _lock); DoWorkWithEntity(ref customer, customerService, _lock); ReportBL report = csvReader.GetReport(manager.Id); report.Manager = manager; DoWorkWithEntity(ref report, reportService, _lock); OrderBL order = csvReader.GetOrder(customer.Id, product.Id, report.Id); DoWorkWithEntity(ref order, orderService, _lock); } } } }
public ActionResult DashBoard(string message = "") { if (sessionDTO.getName() == null) { return(RedirectToAction("Index", "Admin")); } else { string dt = DateTime.Now.ToString("dd/MM/yyyy"); string[] st = dt.Split('/'); //Current Month Stats List <Number> Numlst = new NumberBL().getNumberList().Where(x => x.CreatedAt.Value.Month == Convert.ToInt32(st[1])).ToList(); ViewBag.MNumbersList = Numlst.Count; List <Customer> DNumlst = new CustomerBL().getCustomerList().Where(x => x.CreatedAt.Value.Month == Convert.ToInt32(st[1]) && x.DesiredNumber != null).ToList(); ViewBag.MDNumbersList = DNumlst.Count; List <Customer> SNumlst = new CustomerBL().getCustomerList().Where(x => x.CreatedAt.Value.Month == Convert.ToInt32(st[1]) && x.SellingNumber != null).ToList(); ViewBag.MSNumbersList = SNumlst.Count; List <Subscriber> subslst = new SubscriberBL().getSubscriberList().Where(x => x.CreatedAt.Value.Month == Convert.ToInt32(st[1])).ToList(); ViewBag.SubscribersList = subslst.Count; //Total Stats List <Number> Tnumlst = new NumberBL().getNumberList(); ViewBag.TNumbersList = Tnumlst.Count; List <Customer> TDNumlst = new CustomerBL().getCustomerList().Where(x => x.DesiredNumber != null).ToList(); ViewBag.TDNumbersList = TDNumlst.Count; List <Customer> TSNumlst = new CustomerBL().getCustomerList().Where(x => x.SellingNumber != null).ToList(); ViewBag.TSNumbersList = TSNumlst.Count; List <Subscriber> Tsubslst = new SubscriberBL().getSubscriberList(); ViewBag.TSubscribersList = Tsubslst.Count; ViewBag.message = message; return(View()); } }