示例#1
0
        // GET: Admin/Medical/RequestDetails
        public ActionResult RequestDetails(string id = "")
        {
            try
            {
                int _id;
                var _pendingRequestList = new List <MedicalCheckoutInfo>();

                if (!int.TryParse(id, out _id))
                {
                    return(RedirectToAction("Requests", "Medical"));
                }

                using (MedicalCheckoutRepository Repo = new MedicalCheckoutRepository())
                {
                    _pendingRequestList = Repo.GetPendingMedicalCheckoutsListByEmployeeId(_id);
                }

                if (_pendingRequestList.Count() == 0)
                {
                    return(RedirectToAction("Requests", "Medical"));
                }

                using (MedicalPrescriptionRepository Repo = new MedicalPrescriptionRepository())
                {
                    foreach (var item in _pendingRequestList)
                    {
                        item.MedicalPrescriptions = Repo.GetMedicalPrescriptionsListByMedicalCheckoutId(item.Id);
                    }
                }

                return(View(_pendingRequestList));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Medical", "RequestDetails")));
            }
        }
示例#2
0
        // GET: Employee/Medical/Details
        public ActionResult Details()
        {
            try
            {
                var _employeeInfo    = new EmployeeInfo();
                var _medicalCheckout = new MedicalCheckoutInfo();
                _medicalCheckout.AvailedMedicalsList = new List <MedicalCheckoutInfo>();
                _medicalCheckout.PendingMedicalsList = new List <MedicalCheckoutInfo>();
                _medicalCheckout.MedicalAllowance    = new MedicalAllowanceInfo();
                var    _incompleteMedicalChekouts = new List <MedicalCheckoutInfo>();
                string _medicalYear = DateTime.Now.Year.ToString();

                using (FamilyMemberRepository Repo = new FamilyMemberRepository())
                {
                    TempData["FamilyMembersList"] = new SelectList(Repo.GetAllFamilyMembersListByEmployeeId(CurrentUser.EmployeeInfoId), "Id", "Name");
                }

                using (var transaction = new System.Transactions.TransactionScope())
                {
                    using (MedicalCheckoutRepository Repo = new MedicalCheckoutRepository())
                    {
                        ViewBag.MedicalYear = new SelectList(Repo.GetMedicalYearsList(CurrentUser.EmployeeInfoId));

                        _incompleteMedicalChekouts = Repo.GetIncompleteMedicalCheckoutsListByEmployeeId(CurrentUser.EmployeeInfoId);

                        if (_incompleteMedicalChekouts.Count() > 0)
                        {
                            using (MedicalPrescriptionRepository PrescriptionRepo = new MedicalPrescriptionRepository())
                            {
                                foreach (var checkout in _incompleteMedicalChekouts)
                                {
                                    var _prescriptionsList = PrescriptionRepo.GetMedicalPrescriptionsListByMedicalCheckoutId(checkout.Id);

                                    foreach (var prescription in _prescriptionsList)
                                    {
                                        string fullPath = Request.MapPath(prescription.PrescriptionPath);

                                        if (System.IO.File.Exists(fullPath))
                                        {
                                            System.IO.File.Delete(fullPath);
                                        }

                                        PrescriptionRepo.DeleteMedicalPrescription(prescription.Id);
                                    }

                                    Repo.DeleteMedicalCheckout(checkout.Id);
                                }
                            }
                        }

                        _medicalCheckout.PendingMedicalsList = Repo.GetPendingMedicalCheckoutsListByEmployeeId(CurrentUser.EmployeeInfoId);
                        _medicalCheckout.AvailedMedicalsList = Repo.GetAvailedMedicalCheckoutsListByEmployeeIdYearwise(CurrentUser.EmployeeInfoId, _medicalYear);
                    }

                    transaction.Complete();
                }

                using (EmployeeRepository Repo = new EmployeeRepository())
                {
                    _employeeInfo = Repo.GetEmployeeInfoById(CurrentUser.EmployeeInfoId);
                }

                using (MedicalAllowanceRepository Repo = new MedicalAllowanceRepository())
                {
                    if (_employeeInfo.MaritalStatus == "Single")
                    {
                        _medicalCheckout.MedicalAllowance = Repo.GetMedicalAllowanceByCategory("Single");
                    }
                    else
                    {
                        _medicalCheckout.MedicalAllowance = Repo.GetMedicalAllowanceByCategory("Married");
                    }
                }

                return(View(_medicalCheckout));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Medical", "Details")));
            }
        }