Esempio n. 1
0
 //check job description and set rate accordingly
 private static double setRate(WageCalculator m, double rate)
 {
     switch (m.rate)
     {
         case "Engineer":
             rate = 10;
             break;
         case "Senior Engineer":
             rate = 12;
             break;
         case "Technical Engineer":
             rate = 25;
             break;
         default:
             rate = 30;
             break;
     }
     return rate;
 }
Esempio n. 2
0
        public ActionResult WageCalculator(WageCalculator m)
        {
            double rate = 10;
            var overtimeHours = 0;
            double overtimeRate = 0;
            double overtimePay = 0;

            if(ModelState.IsValid)
            {
                calculateWage(m, ref rate, ref overtimeHours, ref overtimeRate, ref overtimePay);

                return RedirectToAction("Wage",m);
            }

            return View();
        }
Esempio n. 3
0
        //calculate wage and return value
        private static void calculateWage(WageCalculator m, ref double rate, ref int overtimeHours, ref double overtimeRate, ref double overtimePay)
        {
            rate = setRate(m, rate);
            if (m.Beng == true)
                rate = rate + (rate * 0.1);

            if (m.hours > 40)
            {
                overtimeHours = (int)m.hours - 40;
                m.hours = 40;
                overtimeRate = rate * 1.5;
                overtimePay = overtimeHours * overtimeRate;
            }

            m.wage = m.hours * rate;

            if (overtimeHours > 0)
                m.wage = m.wage + overtimePay;
            //added to reset value
            m.hours += overtimeHours;
        }
Esempio n. 4
0
        /// <summary>
        /// returns calculated wage if model is valid else redirects to wage calculator action
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        public ActionResult Wage(WageCalculator m)
        {
            ViewBag.Header = "Calculated Wage";

            if(ModelState.IsValid)
            {

                return View(m);
            }

            return RedirectToAction("WageCalculator");
        }