示例#1
0
        public ActionResult ViewAdjustmentDetails(string voucherId, string choice)
        {
            AdjustmentVoucherEF voucher = stockService.FindAdjustmentVoucherById(voucherId);
            List <AdjustmentVoucherDetailsEF>  voucherDetailsList = stockService.FindAdjustmentDetailsById(voucherId);
            List <AdjustmentVoucherDetailsDTO> convertedList      = stockService.ConvertAdjVoucherDetailsToDTO(voucherDetailsList);

            StaffEF staff = staffService.GetStaff();

            bool needsManagerAuthority = stockService.VoucherExceedsSetValue(voucherDetailsList);

            ViewData["needsManagerAuthority"] = needsManagerAuthority;
            ViewData["adjustmentVoucher"]     = voucher;
            ViewData["voucherDetailsList"]    = convertedList;
            ViewData["staffRole"]             = staff.Role.Description;
            ViewData["staffId"] = staff.StaffId;

            if (choice != null && (voucher.Status == "Pending Approval" || voucher.Status == "Pending Manager Approval"))
            {
                if (choice == "Edit")
                {
                    return(RedirectToAction("CreateAdjustmentVoucher", "ManageAdjustmentVoucher", new { voucherId = voucherId }));
                }
                if (choice == "Approve" || choice == "Reject")
                {
                    stockService.UpdateAdjustmentVoucherStatus(staff, voucherId, choice);
                    SendEmailToStaffOnDecision(voucher.Requester, voucher);
                }
            }
            return(View());
        }