Exemplo n.º 1
0
 // Methods
 public static List<CustomerType> Types()
 {
     List<CustomerType> list = new List<CustomerType>();
     string str = "SELECT CustomerType, ShortDescription FROM CodeCustomerType order by ShortDescription ";
     SqlConnection connection = new SqlConnection();
     SqlCommand command = new SqlCommand();
     connection.ConnectionString = ConfigurationManager.ConnectionStrings["ChargeProgramConnectionString"].ConnectionString;
     command.CommandText = str;
     command.Connection = connection;
     connection.Open();
     SqlDataReader reader = command.ExecuteReader(CommandBehavior.SingleResult);
     CustomerType item = new CustomerType();
     item.description = "ALL";
     item.type = "ALL";
     list.Add(item);
     while (reader.Read())
     {
         CustomerType type2 = new CustomerType();
         type2.Type = reader["CustomerType"].ToString();
         type2.Description = reader["ShortDescription"].ToString();
         list.Add(type2);
     }
     reader.Close();
     connection.Close();
     return list;
 }
Exemplo n.º 2
0
 public Account(string customer, CustomerType customerType, decimal balance, decimal interestRate)
 {
     this.Customer = customer;
     this.CustomerType = customerType;
     this.Balance = balance;
     this.InterestRate = interestRate;
 }
Exemplo n.º 3
0
 public IList<Product> GetAllProductFor(CustomerType customerType)
 {
     IDiscountStrategy discountStrategy = DiscountFactory.GetDiscountStrtegyFor(customerType);
     IList<Product> products = _productRepository.Findall();
     products.Apply(discountStrategy);
     return products;
 }
 public AbstractCustomer(CustomerType customerType)
 {
     this._accountList = new List<IAccount>();
     this._customerType = customerType;
     this._validator = Validation.VALIDATOR;
     this._accountFactory = AccountFactory.ACCOUNT_FACTORY;
 }
        public void RegisterCustomer(string name, CustomerType customerType)
        {            
            try
            {
                using (var transaction = new TransactionScope())
                {
                    Customer customer = new Customer();
                    customer.Name = name;
                    customer.Type = customerType;

                    customer.Agreements.Add(
                        new Agreement
                            {
                                Number = agreementManagementService.GenerateAgreementNumber(),
                                CreatedOn = DateTime.Now,
                                Customer = customer
                            });

                    repository.Save(customer);
                    repository.Commit();

                    transaction.Complete();
                }
            }
            catch (Exception ex)
            {                
                throw new RegistrationException(string.Format("Failed to register customer with name '{0}' and type {1}.", name, customerType), ex);
            }                                
        }
Exemplo n.º 6
0
Arquivo: Account.cs Projeto: GAlex7/TA
 public Account(string customerName, CustomerType type, decimal interest, decimal amount)
 {
     this.Customer = customerName;
     this.Type = type;
     this.Interest = interest;
     this.Balance = amount;
 }
Exemplo n.º 7
0
 internal Customer(CustomerType type, string note, string name, IDataAccessFacade dataAccessFacade)
 {
     validateName(name);
     this.dataAccessFacade = dataAccessFacade;
     _customerEntity = dataAccessFacade.CreateCustomer(type, note, name);
     initializeParty(_customerEntity);
 }
Exemplo n.º 8
0
 //Constructors
 public Account(CustomerType type, decimal balance, decimal interestRate)
 {
     this.Type = type;
     this.Balance = balance;
     this.InterestRate = interestRate;
     this.existance = 0;
 }
Exemplo n.º 9
0
 public void SetValidData()
 {
     dataAccessFacadeStub = new DataAccessFacadeStub();
     validName = "VF Jan";
     validNote = "8 Persons";
     validType = CustomerType.Bureau;
 }
Exemplo n.º 10
0
 internal Customer Create(CustomerType type, string note, string name)
 {
     //Adds a new customer object and adds it to the list.
     Customer customer = new Customer(type, note, name, dataAccessFacade);
     customers.Add(customer);
     return customer;
 }
        public Customer(string name,CustomerType customerType)
        {

            this.CustomerType = customerType;
            this.Name = name;

        }
Exemplo n.º 12
0
 public Customer(string companyName,string userName /*,string password */)
 {
     this.companyName = companyName;
     this.username = userName;
     //this.password = password;
     this.customerType = CustomerType.Company;
 }
Exemplo n.º 13
0
        public Customer(CustomerType customerType,string customerName)
        {
            this.CustomerType = customerType;
            this.CustomerName = customerName;

            customerIndexator++;
        }
Exemplo n.º 14
0
 public Deposit(CustomerType customer, decimal balance, decimal interestRate)
     : base(customer, balance, interestRate)
 {
     if (this.InterestRate <= 0 || this.Balance <= 0)
     {
         throw new ArgumentException("Balance and interest rate must be greater than zero.");
     }
 }
Exemplo n.º 15
0
 public Account(DateTime date, CustomerType customer, decimal balance)
 {
     this.CreatedOn = date;
     this.Customer = customer;
     this.Balance = balance;
     this.InterestRate = this.CalculateInterestRate();
     this.NumberOfMonths = this.CalcMonths();
 }
Exemplo n.º 16
0
 protected Account(string  customerID,CustomerType customerType,decimal  balance,decimal interest)
 {
     this.CustomerID = customerID;
     this.Balance = balance;
     this.Interest = interest;
     this.startDate = DateTime.Today;
     this.CustomerType=customerType;
 }
Exemplo n.º 17
0
 public Account(string customerFirstName, string customerLastName, CustomerType customerType, double balance, double interestRate)
 {
     this.customerFirstName = customerFirstName;
     this.customerLastName = customerLastName;
     this.customerType = customerType;
     this.balance = balance;
     this.interestRate = interestRate;
 }
Exemplo n.º 18
0
 public Account(CustomerType customer, double balance, 
     double monthlyInterest, int numberOfMonths, AccountType account)
 {
     this.BankCustomer = customer;
     this.Balance = balance;
     this.MonthlyInterest = monthlyInterest;
     this.NumberOfMonths = numberOfMonths;
     this.BankAccount = account;
 }
Exemplo n.º 19
0
        public CustomerType Insert_CustomerType()
        {
            CustomerType customerType = new CustomerType();
            customerType.Id = 1;
            customerType.Name = "Bireysel";

            customerTypeDao.Insert(customerType);
            return customerType;
        }
Exemplo n.º 20
0
 //
 // GET: /Platform/SysDepartment/Edit/5
 public ActionResult Edit(Guid? id)
 {
     var item = new CustomerType();
     if (id.HasValue)
     {
         item = _iCustomerTypeService.GetById(id.Value);
     }
     return View(item);
 }
Exemplo n.º 21
0
 //Gamla sättet med strängar
 //public IPriceStrategy GetPriceStrategy(string name) {
 //    if ( name == PercentDiscount.Name )
 //        return new PercentDiscount();
 //    else if ( name == ThresholdDiscount.Name )
 //        return new ThresholdDiscount();
 //    return null;
 //}
 public IPriceStrategy GetPriceStrategy(CustomerType cType )
 {
     if ( cType == CustomerType.Private ) {
         BestForCustomer bc = new BestForCustomer();
         bc.Add( percentDiscount );
         bc.Add( thresholdDiscount );
         return bc.GetTotal( order );
     }
     return null;
 }
Exemplo n.º 22
0
 public static IDiscountStrategy GetDiscountStrategyFor(CustomerType customerType)
 {
     switch (customerType)
     {
         case CustomerType.Trade:
             return new TradeDiscountStrategy();
         default:
             return new NullDiscountStrategy();
     }
 }
Exemplo n.º 23
0
 public CustomerEntity(CustomerType type, string note, string name)
     : base(note, name)
 {
     Type = type;
     ContactPerson = "";
     Email = "";
     Address = "";
     PhoneNo = "";
     FaxNo = "";
 }
        private decimal CalcInterestForIndividual(DateTime openDate, int months, decimal interestRate,
            decimal balance, CustomerType type)
        {
            if (months - 6 > 0)
            {
                return 0m;
            }

            decimal interest = balance * (1 + interestRate * months);
            return interest;
        }
Exemplo n.º 25
0
        public static string customerType2Str(Util.Resource resource, CustomerType type)
        {
            switch (type)
            {
                case CustomerType.AGENT: return resource.getMsg("customer_type_agent");
                case CustomerType.PERSONAL: return resource.getMsg("customer_type_personal");
                case CustomerType.OTHER: return resource.getMsg("customer_type_other");
                default: return resource.getMsg("customer_type_personal");

            }
        }
Exemplo n.º 26
0
 public Customer(string firstName, string middleName, string lastName, string id, string permanentAddress, string mobilePhone, string email, IList<Payment> payments, CustomerType type)
 {
     this.FirstName = firstName;
     this.MiddleName = middleName;
     this.LastName = lastName;
     this.ID = id;
     this.PermanentAddress = permanentAddress;
     this.MobilePhone = mobilePhone;
     this.Email = email;
     this.payments = payments;
     this.Type = type;
 }
Exemplo n.º 27
0
        public ActionResult Edit(Guid? id, CustomerType collection)
        {
            if (!ModelState.IsValid)
            {
                return View(collection);
            }

            _iCustomerTypeService.Save(id, collection);
            _unitOfWork.Commit();

            return RedirectToAction("Index");
        }
Exemplo n.º 28
0
 public Customer(string fName, string mName, string lName, long egn, string address, string mPhone, string email, CustomerType type)
 {
     this.FName = fName;
        this.MName = mName;
        this.LName = lName;
        this.EGN = egn;
        this.Address = address;
        this.MPhone = mPhone;
        this.Email = email;
        this.Type = type;
        this.payments = new List<IPayment>();
 }
 private bool ClientIsEligableForInterest(CustomerType type, int months)
 {
     switch (type)
     {
         case CustomerType.Individual:
             return months - 3 > 0;
         case CustomerType.Company:
             return months - 2 > 0;
         default:
             throw new ArgumentException("Something went terribly wrong with the months!");
     }
 }
Exemplo n.º 30
0
 public ICustomer CreateCustomer(CustomerType type)
 {
     switch (type)
     {
         case CustomerType.Company:
             return new CompanyCustomer();
         case CustomerType.Individual:
             return new IndividualCustomer();
         default:
             throw new ArgumentException("Customer type not supported");
     }
 }
Exemplo n.º 31
0
        public void DisplayByCustType(CustomerType customerType)
        {
            List <Greetings> listOfGreetings = _greetingsRepo.GetCustomerGreetingsList();

            listOfGreetings.Sort(delegate(Greetings x, Greetings y)
            {
                return(x.LastName.CompareTo(y.LastName));
            });
            List <string> headings = new List <string> {
                "First Name", "Last Name", "Type"
            };

            Console.Clear();
            Console.WriteLine($"\n{headings[0],-12} {headings[1],-12} {headings[2],-10}");
            foreach (Greetings greeting in listOfGreetings)
            {
                if (greeting.TypeOfCustomer == customerType)
                {
                    Console.WriteLine($"{greeting.FirstName,-12} {greeting.LastName,-12} {greeting.TypeOfCustomer,-10}");
                }
            }
        }
Exemplo n.º 32
0
        private void AddNewCustomer()
        {
            Console.WriteLine("What is the customer's first name?");
            string fName = Console.ReadLine();

            Console.WriteLine("What is the customer's last name?");
            string lName = Console.ReadLine();

            Console.WriteLine($"\nWhat type of customer is {fName} {lName}?\n" +
                              "1. Current customer\n" +
                              "2. Past customer\n" +
                              "3. Potential customer\n" +
                              "Please enter 1, 2, or 3");
            string       newCustInput = Console.ReadLine();
            CustomerType newType      = CustomerType.Potential;

            switch (newCustInput)
            {
            case "1":
                newType = CustomerType.Current;
                break;

            case "2":
                newType = CustomerType.Past;
                break;

            case "3":
                newType = CustomerType.Potential;
                break;

            default:
                Console.WriteLine("Please enter a valid number");
                break;
            }
            Greetings newGreetings = new Greetings(fName, lName, newType);

            _greetingsRepo.AddCustomerGreeting(newGreetings);
            Console.WriteLine($"{fName} {lName}, a {newType} customer, has been added to the email list.");
        }
        public void Calculate_Totals(CustomerType customerType, double total, double discount, double shippingCost)
        {
            Cart cart = GenerateCart(customerType);
            var  shippingCalculator = Substitute.For <IShippingCalculator>();

            shippingCalculator.CalculateShippingCost(cart).Returns(10);
            var config = new MapperConfiguration(cfg => {
                cfg.AddProfile <MappingProfile>();
            });
            var mapper = config.CreateMapper();

            var sut = new CheckOutEngine(shippingCalculator, mapper);

            var result = sut.CalculateTotals(cart);

            result.Total.Should().Be(total);
            result.CustomerDiscount.Should().Be(discount);
            result.ShippingCost.Should().Be(shippingCost);
            result.ShoppingCart.Items.Should().NotContainNulls();
            result.ShoppingCart.CustomerType.Should().Be(customerType);
            result.ShoppingCart.ShippingMethod.Should().Be(ShippingMethod.Expedited);
        }
Exemplo n.º 34
0
        private void AddACustomer()
        {
            Console.WriteLine("What is the customers ID number?");
            int customerID = int.Parse(Console.ReadLine());

            Console.WriteLine("What is the customers first name?");
            string firstName = Console.ReadLine();

            Console.WriteLine("What is the customers last name?");
            string lastName = Console.ReadLine();

            Console.WriteLine("What number best describes the customer?\n" +
                              "1: Potential\n" +
                              "2: Current\n" +
                              "3: Past");
            int          customer     = int.Parse(Console.ReadLine());
            CustomerType customerType = (CustomerType)customer;

            Crud newCustomer = new Crud(customerID, firstName, lastName, customerType);

            _customerRepo.AddCustomerToEmailList(newCustomer);
        }
Exemplo n.º 35
0
        public Customer Clone()
        {
            string         newFirstName    = this.FirstName;
            string         newMiddleName   = this.MiddleName;
            string         newLastName     = this.LastName;
            int            newId           = this.id;
            string         newAddress      = this.address;
            string         newEmail        = this.email;
            string         newMobilePhone  = this.mobilePhone;
            CustomerType   newCustomerType = this.customerType;
            List <Payment> newPayment      = new List <Payment>();

            foreach (var item in this.payment)
            {
                newPayment.Add(item);
            }

            Customer customer = new Customer(newFirstName, newMiddleName, newLastName, newId,
                                             newAddress, newMobilePhone, newEmail, newPayment, newCustomerType);

            return(customer);
        }
        public int SaveCustomerType(CustomerType CustomerType)
        {
            try
            {
                if (CustomerType.Id == 0)
                {
                    databaseContext.CustomerType.Add(CustomerType);
                }
                else
                {
                    databaseContext.CustomerType.Update(CustomerType);
                }
                databaseContext.SaveChanges();

                return(1);
            }
            catch (Exception Ex)
            {
                //throw Ex;
                return(0);
            }
        }
Exemplo n.º 37
0
        // GET: CustomerTypes/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            try
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                CustomerType customerType = await db.CustomerType.FindAsync(id);

                if (customerType == null)
                {
                    return(HttpNotFound());
                }
                return(View(customerType));
            }
            catch (Exception ex)
            {
                log4Net.Error(ex.Message, ex);
                throw;
            }
        }
Exemplo n.º 38
0
        public bool UpdateCustomerType(CustomerType customerType)
        {
            SqlCommand cmd = new SqlCommand();

            try
            {
                con.Open();
                cmd.Connection  = con;
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "spUpdateCostumerType";
                cmd.Parameters.AddWithValue("@CostumerTypeId", customerType.CustomerTypeId);
                cmd.Parameters.AddWithValue("@CostumerType", customerType.Type);
                cmd.ExecuteNonQuery();
                con.Close();
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(false);
            }
        }
Exemplo n.º 39
0
        private static void InitiateSale(ServiceProvider serviceProvider)
        {
            try
            {
                var salesProvider = serviceProvider.GetService <ISalesProvider>();

                string calculateShoppingBillAmount;
                do
                {
                    Console.WriteLine("Customer Types: 1. Regular 2. Premium");
                    Console.Write("Please select one (1 or 2): ");
                    CustomerType customerType = (CustomerType)Enum.Parse(typeof(CustomerType), Console.ReadLine());

                    Console.Write($"{Environment.NewLine}Enter the purchase amount: ");
                    var purchaseAmount = decimal.Parse(Console.ReadLine());

                    var sales      = salesProvider.GetSales(customerType, purchaseAmount);
                    var billAmount = sales.GetBillAmount();

                    Console.WriteLine($"{Environment.NewLine}The final bill amount={billAmount.ToString("C", CultureInfo.CurrentCulture)}");

                    Console.Write($"{Environment.NewLine}Do you want me to calculate shopping card bill amount again? Yes (y) or No (n): ");
                    calculateShoppingBillAmount = Console.ReadLine()?.ToLower();

                    Console.WriteLine();

                    if (calculateShoppingBillAmount == "n")
                    {
                        break;
                    }
                } while (true);
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("Unable to calculate the bill amount.");
                Console.Error.WriteLine($"Exception: {ex}");
            }
        }
Exemplo n.º 40
0
        internal static AzureBackupContainerType GetContainerType(string customerType)
        {
            CustomerType type = (CustomerType)Enum.Parse(typeof(CustomerType), customerType);

            AzureBackupContainerType containerType = 0;

            switch (type)
            {
            case CustomerType.DPM:
                containerType = AzureBackupContainerType.SCDPM;
                break;

            case CustomerType.InMage:
                break;

            case CustomerType.Invalid:
                break;

            case CustomerType.ManagedContainer:
                break;

            case CustomerType.OBS:
                containerType = AzureBackupContainerType.Windows;
                break;

            case CustomerType.SBS:
                containerType = AzureBackupContainerType.Windows;
                break;

            case CustomerType.SqlPaaS:
                break;

            default:
                break;
            }

            return(containerType);
        }
Exemplo n.º 41
0
 private void btndeletecustomertype_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtboxcostumertype.Text.ToString() == "")
         {
             RadMessageBox.Show("Please Enter Text In Costumer Type", "Error Empty Field");
             return;
         }
         CustomerType customertype = new CustomerType()
         {
             CustomerTypeId = Convert.ToInt32(txtboxctid.Text.ToString()),
         };
         var confirm = RadMessageBox.Show("Are You Sure You want to Delete?", "Confirmation", MessageBoxButtons.YesNo);
         if (confirm == DialogResult.Yes)
         {
             if (new CustomerTypeBusiness().DeleteCostumerType(customertype))
             {
                 RadMessageBox.Show("Deleted");
                 txtboxcostumertype.Clear();
                 btnupdatecustomertype.Enabled = false;
                 btndeletecustomertype.Enabled = false;
                 InitializeComboBox();
                 InitializeGridviews();
             }
             else
             {
                 MessageBox.Show("Failed");
             }
         }
         else
         {
         }
     }
     catch (Exception exception)
     {
     }
 }
Exemplo n.º 42
0
        public HotelType FindCheapestHotel(string startDate, string endDate, CustomerType type)
        {
            Hotel LakeWood   = new Hotel(HotelType.LAKEWOOD, type);
            Hotel BridgeWood = new Hotel(HotelType.BRIDGEWOOD, type);
            Hotel RidgeWood  = new Hotel(HotelType.RIDGEWOOD, type);
            //Calculating Rate of Each Hotel Between the given dates
            double LakeWoodRate   = LakeWood.FindTotalCost(startDate, endDate);
            double BridgeWoodRate = BridgeWood.FindTotalCost(startDate, endDate);
            double RidgeWoodRate  = RidgeWood.FindTotalCost(startDate, endDate);

            double MinRate = Math.Min(LakeWoodRate, Math.Min(BridgeWoodRate, RidgeWoodRate));

            if (MinRate == LakeWoodRate && MinRate == BridgeWoodRate && MinRate == RidgeWoodRate)
            {
                return(HotelType.RIDGEWOOD);
            }
            if (MinRate == LakeWoodRate && MinRate == BridgeWoodRate)
            {
                return(HotelType.BRIDGEWOOD);
            }
            if (MinRate == BridgeWoodRate && MinRate == RidgeWoodRate)
            {
                return(HotelType.RIDGEWOOD);
            }
            if (MinRate == LakeWoodRate && MinRate == BridgeWoodRate)
            {
                return(HotelType.RIDGEWOOD);
            }
            if (MinRate == LakeWoodRate)
            {
                return(HotelType.LAKEWOOD);
            }
            if (MinRate == BridgeWoodRate)
            {
                return(HotelType.BRIDGEWOOD);
            }
            return(HotelType.RIDGEWOOD);
        }
Exemplo n.º 43
0
        private void addCustomerType()
        {
            CustomerTypeTable customerType = new CustomerTypeTable();

            customerType.name = this.textBoxCustomerGroupName.Text.ToString();
            customerType.desc = this.textBoxCustomerGroupDesc.Text.ToString();

            if (customerType.name.Length == 0)
            {
                MessageBoxExtend.messageWarning("组名称不能为空,请重新填写!");
                return;
            }

            CustomerType.getInctance().insert(customerType);


            // 客户组织结构
            CustomerOrgStructTable customerOrgInfo = new CustomerOrgStructTable();

            customerOrgInfo.parentPkey = CustomerOrgStruct.getInctance().getPkeyFromValue(m_customerGroupPkey);
            customerOrgInfo.value      = CustomerType.getInctance().getMaxPkey();
            CustomerOrgStruct.getInctance().insert(customerOrgInfo);
        }
Exemplo n.º 44
0
        private void Process(string phoneNumber)
        {
            if (CustomerType != null)
            {
                var popupName = GetSettings().PopupName;
                if (string.IsNullOrWhiteSpace(popupName)) popupName = Name;
                var sr = _entityService.SearchEntities(CustomerType, phoneNumber, "");
                if (sr.Count == 1)
                {
                    var entity = sr.First();
                    InteractionService.UserIntraction.DisplayPopup(popupName, CustomerType.GetFormattedDisplayName(entity.Name, entity),
                        entity.Name + " " + Resources.Calling + ".\r" +
                        entity.SearchString + "\r", "DarkRed", OnClick, phoneNumber);
                }
                else
                    InteractionService.UserIntraction.DisplayPopup(popupName, phoneNumber,
                        phoneNumber + " " + Resources.Calling + "...", "DarkRed",
                        OnClick, phoneNumber);
            }

            _applicationState.NotifyEvent(RuleEventNames.DeviceEventGenerated,
                new { DeviceName = Name, EventName = "CID_Event", EventData = phoneNumber });
        }
Exemplo n.º 45
0
 //UC2 - UC4           
 public static void FindCheapest(HotelReservation hotelReservation, CustomerType ct)
 {
     Console.WriteLine("Cheapest Hotel");
     Console.Write("Enter the date range : ");
     var input = Console.ReadLine();
     string[] dates = input.Split(',');
     try
     {
         var startDate = Convert.ToDateTime(dates[0]);
         var endDate = Convert.ToDateTime(dates[1]);
         var cheapestHotel = hotelReservation.FindCheapestHotels(startDate, endDate, ct);
         foreach (Hotel h in cheapestHotel)
         {
             var cost = hotelReservation.CalculateTotalCost(h, startDate, endDate, ct);
             Console.WriteLine("Hotel : {0}, Total Cost : {1}", h.name, cost);
         }
     }
     catch
     {
         Console.Write("Enter the correct date range \n");
         FindCheapest(hotelReservation, ct);
     }
 }
Exemplo n.º 46
0
        public ActionResult UpdateCustomerType(CustomerType customerType)
        {
            AjaxResult result = new AjaxResult();

            try
            {
                if (new CustomerTypeRule().UpdateCustomerType(customerType))
                {
                    result.Success = true;
                    result.Message = "更新成功";
                }
                else
                {
                    throw new Exception("更新失败");
                }
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Message = ex.Message;
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 47
0
        /// <summary>
        /// Method to add the data to the multiple customer types
        /// </summary>
        /// <param name="customerType"></param>
        public static void DefiningAdditionRepository(CustomerType customerType)
        {
            switch (customerType)
            {
            /// Adding the detail for the regular customer type
            case CustomerType.REGULAR:
                AddHotelRecords("Lakewood", 110, 90, 3, 1);
                AddHotelRecords("Bridgewood", 150, 50, 4, 1);
                AddHotelRecords("Ridgewood", 220, 150, 5, 1);
                break;

            /// Adding the detail for the rewarded customer type
            case CustomerType.REWARD:
                AddHotelRecords("Lakewood", 80, 80, 3, 2);
                AddHotelRecords("Bridgewood", 110, 50, 4, 2);
                AddHotelRecords("Ridgewood", 100, 40, 5, 2);
                break;

            /// Catching the exception for the invalid customer type
            default:
                throw new HotelReservationCustomException(HotelReservationCustomException.ExceptionType.INVALID_CUSTOMER_TYPE, "Does not support this customer type");
            }
        }
Exemplo n.º 48
0
        /// <summary>
        /// Option 3 from menu: creates 5 employess
        /// Then displays them ordered by employee status field
        /// </summary>
        private static void ShowExistedEmployees()
        {
            //create random employees
            Employee[] employees = new Employee[5];
            Random     rnd       = new Random();

            //just filling 3 employees with a little random data
            for (int i = 0; i < employees.Length - 2; i++)
            {
                CustomerType rndCustomer = (CustomerType)rnd.Next(0, 2);
                employees[i] = new Employee("Mr " + (i + 1), 50 - i, Employee.EmployeeStatus.Worker, rndCustomer);
            }
            // an et par of them manually
            employees[3] = new Employee("Mira Money", 2000, Employee.EmployeeStatus.AccountManager, CustomerType.middle);
            employees[4] = new Employee("Jocker", 10000, Employee.EmployeeStatus.Boss, CustomerType.big);

            //sort them efter status n display info
            Array.Sort(employees);
            foreach (Employee employee in employees)
            {
                Console.WriteLine(employee);
            }
        }
Exemplo n.º 49
0
        /// <summary>
        /// 获取所有客户类型
        /// </summary>
        /// <param name="param"></param>
        /// <param name="cType"></param>
        /// <param name="itemCount"></param>
        /// <returns></returns>
        public List <dynamic> GetAllCustomerType(EasyUIGridParamModel param, CustomerType cType, out int itemCount)
        {
            List <SqlParameter> paramList = new List <SqlParameter>();
            StringBuilder       strSql    = new StringBuilder();

            strSql.Append("select id,name from t_customerType ");
            strSql.Append("where 1=1 ");
            Dictionary <string, object> paramDic = new Dictionary <string, object>();

            if (!string.IsNullOrEmpty(cType.Name))
            {
                strSql.Append("and name like @name ");
                paramDic.Add("name", string.Format("%{0}%", cType.Name));
            }
            int pageIndex = Convert.ToInt32(param.page) - 1;
            int pageSize  = Convert.ToInt32(param.rows);

            using (DBHelper db = DBHelper.Create())
            {
                itemCount = db.GetListCount(strSql.ToString(), paramDic);
                return(db.GetDynaminObjectList(strSql.ToString(), pageIndex, pageSize, "name", paramDic));
            }
        }
Exemplo n.º 50
0
        private void UpdateCustomer()
        {
            Console.Write("Enter the existing first name of the customer to update: ");
            string existingFirst = Console.ReadLine();

            Console.Write("Enter the existing last name of the customer to update: ");
            string existingLast = Console.ReadLine();

            Console.Write("Enter the customer's updated first name: ");
            string updateFirst = Console.ReadLine();

            Console.Write("Enter the customer's updated last name: ");
            string updateLast = Console.ReadLine();

            Console.Write("Enter the customer's updated type (1 - current, 2 - past, 3 - potential): ");
            int          updatedType         = int.Parse(Console.ReadLine());
            CustomerType updatedCustomerType = (CustomerType)updatedType;
            Customer     customer            = new Customer(updateFirst, updateLast, updatedCustomerType);

            _customerList.UpdateCustomer(existingFirst, existingLast, customer);
            Console.WriteLine("Customer updated\n" +
                              "Press any key to continue");
        }
        public ActionResult NewCustomerType([FromBody] CustomerType[] customerTypes)
        {
            if (_context.CustomerType.Where(d => d.Defenition == customerTypes[0].Defenition).Count() > 0)
            {
                return(Json("Bu müştəri tipi mövcuddur"));
            }
            string result = "Sistem xətası";

            try
            {
                CustomerType customerType = new CustomerType();
                customerType.Defenition = customerTypes[0].Defenition;
                _context.Add(customerType);
                _context.SaveChanges();
                result = "Əməliyyat uğurla tamamlandı!";
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }

            return(Json(result));
        }
Exemplo n.º 52
0
        /// <summary>
        /// Creating method for Find Best Hotel.
        /// </summary>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        /// <returns></returns>
        public List <Hotel> FindBestHotels(DateTime startDate, DateTime endDate, CustomerType customerType)
        {
            if (startDate > endDate)
            {
                Console.WriteLine("Start date cannot be greater than end date");
                return(null);
            }
            var cost       = 0;
            var BestHotels = new List <Hotel>();

            foreach (var hotel in hotelRecords)
            {
                cost = Math.Max(cost, CalculateCost(hotel.Value, startDate, endDate, customerType));
            }
            foreach (var hotel in hotelRecords)
            {
                if (CalculateCost(hotel.Value, startDate, endDate, customerType) == cost)
                {
                    BestHotels.Add(hotel.Value);
                }
            }
            return(BestHotels);
        }
Exemplo n.º 53
0
    public Result SaveCustomerTypeDetails(CustomerType custType, string BankCode, string Password)
    {
        Result result = new Result();

        try
        {
            if (custType.IsValid(BankCode, Password))
            {
                result = bll.SaveCustomerTypeDetails(custType, BankCode);
            }
            else
            {
                result.StatusCode = custType.StatusCode;
                result.StatusDesc = custType.StatusDesc;
            }
        }
        catch (Exception ex)
        {
            result.StatusCode = "100";
            result.StatusDesc = "FAILED: " + ex.Message;
        }
        return(result);
    }
        public List <Hotel> FindCheapestHotels(DateTime startDate, DateTime endDate, CustomerType customerType = 0)
        {
            if (startDate > endDate)
            {
                throw new HotelReservationException(ExceptionType.INVALID_DATES, "Dates Entered are Invalid");
            }
            var cost           = Int32.MaxValue;
            var cheapestHotels = new List <Hotel>();

            foreach (var hotel in hotels)
            {
                var temp = cost;
                cost = Math.Min(cost, CalculateTotalCost(hotel.Value, startDate, endDate, customerType));
            }
            foreach (var hotel in hotels)
            {
                if (CalculateTotalCost(hotel.Value, startDate, endDate, customerType) == cost)
                {
                    cheapestHotels.Add(hotel.Value);
                }
            }
            return(cheapestHotels);
        }
Exemplo n.º 55
0
    protected void btnApprove_Click(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(hdCustomerTypeID.Value))
        {
            CustomerType    oCustomerType    = new CustomerType(hdCustomerTypeID.Value);
            CustomerTypeDAL oCustomerTypeDAL = new CustomerTypeDAL();
            oCustomerType.UserDetails = ucUserDet.UserDetail;

            Result oResult = (Result)oCustomerTypeDAL.Approve(oCustomerType);
            if (oResult.Status)
            {
                ucMessage.OpenMessage(Constants.MSG_SUCCESS_APPROVE, Constants.MSG_TYPE_SUCCESS);
            }
            else
            {
                ucMessage.OpenMessage(Constants.MSG_ERROR_APPROVE, Constants.MSG_TYPE_ERROR);
            }
        }
        else
        {
            ucMessage.OpenMessage(Constants.MSG_ERROR_APPROVE, Constants.MSG_TYPE_ERROR);
        }
    }
Exemplo n.º 56
0
        public ActionResult CalculateLoanAmountDue(CustomerType customerType, decimal loanAmount, int tenure)
        {
            if (!ModelState.IsValid || !Enum.IsDefined(typeof(CustomerType), customerType))
            {
                return(BadRequest("something went wrong. \n please check your input."));
            }

            try
            {
                var amountDue = _loanCalculatorService.CalculateLoanAmountDue(customerType, loanAmount, tenure);
                if (amountDue == 0)
                {
                    return(BadRequest("something went wrong"));
                }

                return(Ok(new { amountDue, interest = (amountDue - loanAmount) }));
            }
            catch (ArgumentOutOfRangeException e)
            {
                Debug.WriteLine(e);
                return(StatusCode(StatusCodes.Status500InternalServerError, e));
            }
        }
Exemplo n.º 57
0
        public async Task <IEnumerable <CustomerModel> > Search(string searchQuery,
                                                                CustomerType customerType = CustomerType.None)
        {
            return(await Task.Run(() =>
            {
                searchQuery = searchQuery.ToLower();

                switch (customerType)
                {
                case CustomerType.Company:
                    return
                    MockData.Instance.Customers.OfType <CompanyModel>()
                    .Where(c => c.Name != null && c.Name.ToLower().Contains(searchQuery));

                case CustomerType.Person:
                    return
                    MockData.Instance.Customers.OfType <PersonModel>()
                    .Where(
                        p =>
                        p.FirstName.ToLower().Contains(searchQuery) ||
                        p.LastName.ToLower().Contains(searchQuery));

                default:
                    var persons =
                        MockData.Instance.Customers.OfType <PersonModel>()
                        .Where(
                            p =>
                            p.FirstName.ToLower().Contains(searchQuery) ||
                            p.LastName.ToLower().Contains(searchQuery));
                    var companies =
                        MockData.Instance.Customers.OfType <CompanyModel>()
                        .Where(c => c.Name != null && c.Name.ToLower().Contains(searchQuery));

                    return persons.Concat <CustomerModel>(companies);
                }
            }));
        }
Exemplo n.º 58
0
        public Discount GetBigSpenderDiscount(AccountHistory customerAccount, CustomerType customerAccountCustomerType)
        {
            switch (customerAccountCustomerType)
            {
            case CustomerType.Bronze:
                if (customerAccount.YearlySpend > 3000)
                {
                    return new Discount {
                               DiscountType = DiscountType.BigSpenderDiscount, DiscountValue = 1
                    }
                }
                ;
                break;

            case CustomerType.Silver:
                if (customerAccount.YearlySpend > 2000)
                {
                    return new Discount {
                               DiscountType = DiscountType.BigSpenderDiscount, DiscountValue = 2
                    }
                }
                ;
                break;

            case CustomerType.Gold:
                if (customerAccount.YearlySpend > 1000)
                {
                    return new Discount {
                               DiscountType = DiscountType.BigSpenderDiscount, DiscountValue = 2
                    }
                }
                ;
                break;
            }

            return(GetBigSpenderDiscount(customerAccount));
        }
Exemplo n.º 59
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to the Hotel Reservation System.");
            Hotel hotel = new Hotel();

            try
            {
                HotelService customerService = new HotelService();
                Console.WriteLine("Choose your customer type \nNORMAL \nREWARD");
                CustomerType customerType = customerService.Validate(Console.ReadLine());
                Console.WriteLine("Enter start date of your stay in YYYY/MM/DD format");
                string startDate = Console.ReadLine();
                Console.WriteLine("Enter end date of your stay in YYYY/MM/DD format");
                string endDate = Console.ReadLine();
                Console.WriteLine("Select your criteria of choice \n1. According to rates \n2. According to ratings");
                int choice = Convert.ToInt32(Console.ReadLine());
                switch (choice)
                {
                case 1:
                    hotel.type = customerService.FindCheapestHotel(startDate, endDate, customerType);
                    customerService.PrintHotelType(hotel.type);
                    break;

                case 2:
                    hotel.type = customerService.FindBestRatedHotel(startDate, endDate, customerType);
                    customerService.PrintHotelType(hotel.type);
                    break;

                default:
                    throw new HotelReservationException(HotelReservationException.ExceptionType.INVALID_CHOICE, "Invalid choice");
                }
            }
            catch (HotelReservationException exception)
            {
                Console.WriteLine(exception.Message + "\nTry Again");
            }
        }
Exemplo n.º 60
0
        public IActionResult Checkout(CustomerType customerType)
        {
            Checkout checkout = new Checkout {
                ProductList = checkoutProductList
            };

            var total = 0.0;

            switch (customerType)
            {
            case CustomerType.Regular:
            {
                foreach (var product in checkoutProductList)
                {
                    total += Calculate.CalculateRegularDiscount(product.ProductPrice);
                }

                checkout.GrandTotal = total;
                break;
            }

            case CustomerType.Premium:
            {
                foreach (var product in checkoutProductList)
                {
                    total += Calculate.CalculatePremiumDiscount(product.ProductPrice);
                }

                checkout.GrandTotal = total;
                break;
            }
            }

            checkoutProductList.Clear();

            return(View(checkout));
        }