Example #1
0
        public ActionResult EditDeduction(AddDeductionViewModel fromModel)
        {
            AssignedEmployeeDeductionBL assingedEmployeeBL = new AssignedEmployeeDeductionBL();
            DeductionBL           bL        = new DeductionBL();
            AddDeductionViewModel toModel   = new AddDeductionViewModel();
            Deduction             deduction = new Deduction();

            toModel.Deductions = new SelectList(bL.GetActiveDeductions(), "DeductionId", "DeductionName", 1);
            toModel.UserPersonalInformationId = fromModel.UserPersonalInformationId;
            toModel.DeductionId = fromModel.DeductionId;
            toModel.Name        = fromModel.Name;
            //toModel.SelectedCustomAmount = fromModel.SelectedCustomAmount;

            deduction = bL.GetDeductionById(fromModel.DeductionId);
            if (deduction != null)
            {
                toModel.SelectedDeductionAmount = 0.0M;
                toModel.SelectedDeductionName   = deduction.DeductionName;
            }
            else
            {
                toModel.SelectedDeductionAmount = fromModel.SelectedDeductionAmount;
                toModel.SelectedDeductionName   = fromModel.SelectedDeductionName;
            }



            AssignedEmployeeDeduction toDB = new AssignedEmployeeDeduction();


            if (ModelState.IsValid)
            {
                if (fromModel.DeductionId > 0)
                {
                    toDB.UserPersonalInformationID = toModel.UserPersonalInformationId;
                    //toDB.CustomAmount = toModel.SelectedCustomAmount;
                    toDB.DeductionAmount = toModel.SelectedDeductionAmount;
                    toDB.DeductionId     = toModel.DeductionId;

                    assingedEmployeeBL.UpdateEmployeeDeduction(toDB);
                }
                else
                {
                    ModelState.AddModelError("", "Please select a Deduction.");
                    return(View(toModel));
                }
            }
            else
            {
                ModelState.AddModelError("", "Error.");
                return(View(toModel));
            }
            return(RedirectToAction("AssignDeduction", "Home", new { id = fromModel.UserPersonalInformationId }));
        }
Example #2
0
        public ActionResult AddDeduction(int id)
        {
            DeductionBL           bL         = new DeductionBL();
            AddDeductionViewModel viewModels = new AddDeductionViewModel();

            viewModels.Deductions = new SelectList(bL.GetActiveDeductions(), "DeductionId", "DeductionName", 1);
            viewModels.UserPersonalInformationId = id;


            return(View(viewModels));
        }
Example #3
0
        public ActionResult EditDeduction(int id, int deductionId)
        {
            AssignedEmployeeDeductionBL assingedEmployeeBL = new AssignedEmployeeDeductionBL();
            Deduction             deduction  = new Deduction();
            DeductionBL           bL         = new DeductionBL();
            AddDeductionViewModel viewModels = new AddDeductionViewModel();

            viewModels.UserPersonalInformationId = id;
            deduction = bL.GetDeductionById(deductionId);
            //viewModels.SelectedCustomAmount = assingedEmployeeBL.GetAssignedEmployeeDeductionsByDeductionId(id, deductionId);
            if (deduction != null)
            {
                //viewModels.SelectedDeductionAmount = deduction.DeductionValue;
                viewModels.SelectedDeductionName = deduction.DeductionName;
            }

            ViewBag.Name = employeeBL.GetEmployeeById(id);
            return(View(viewModels));
        }