Ejemplo n.º 1
0
        // GET: Admin/Medical/UpdateAllowance
        public ActionResult UpdateAllowance(string id = "")
        {
            try
            {
                int _id;
                MedicalAllowanceInfo _medicalAllowance = null;

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

                using (MedicalAllowanceRepository Repo = new MedicalAllowanceRepository())
                {
                    _medicalAllowance = Repo.GetMedicalAllowanceById(_id);
                }

                if (_medicalAllowance == null)
                {
                    return(RedirectToAction("Allowance", "Medical"));
                }

                return(View(_medicalAllowance));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Medical", "UpdateAllowance")));
            }
        }
Ejemplo n.º 2
0
        public ActionResult UpdateAllowance(MedicalAllowanceInfo medicalAllowanceInfo)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View());
                }

                using (MedicalAllowanceRepository Repo = new MedicalAllowanceRepository())
                {
                    medicalAllowanceInfo.Category = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(medicalAllowanceInfo.Category.ToLower());

                    Repo.UpdateMedicalAllowance(medicalAllowanceInfo);

                    TempData["Msg"] = AlertMessageProvider.SuccessMessage("Allowance updated successfully.");

                    return(RedirectToAction("Allowance", "Medical"));
                }
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Medical", "UpdateAllowance")));
            }
        }
Ejemplo n.º 3
0
        // GET: Admin/Medical/Manage
        public ActionResult Manage(string id = "")
        {
            try
            {
                ViewBag.EmployeeId = GetEmployeeFullNameList();

                int    empId;
                var    _checkout     = new MedicalCheckoutInfo();
                var    _employeeInfo = new EmployeeInfo();
                string _medicalYear  = DateTime.Now.Year.ToString();

                if (!int.TryParse(id, out empId))
                {
                    _checkout = null;

                    return(View(_checkout));
                }

                using (MedicalCheckoutRepository Repo = new MedicalCheckoutRepository())
                {
                    ViewBag.MedicalYear = new SelectList(Repo.GetMedicalYearsList(empId));

                    _checkout.AvailedMedicalsList = Repo.GetAvailedMedicalCheckoutsListByEmployeeIdYearwise(empId, _medicalYear);
                }

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

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

                _checkout.EmployeeInfoId = int.Parse(id);

                return(View(_checkout));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Medical", "Manage")));
            }
        }
Ejemplo n.º 4
0
        public ActionResult DeleteAllowance(int id)
        {
            try
            {
                using (MedicalAllowanceRepository Repo = new MedicalAllowanceRepository())
                {
                    Repo.DeleteMedicalAllowance(id);

                    TempData["Msg"] = AlertMessageProvider.SuccessMessage("Allowance deleted successfully.");

                    return(RedirectToAction("Allowance", "Medical"));
                }
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Medical", "DeleteAllowance")));
            }
        }
Ejemplo n.º 5
0
        // GET: Admin/Medical/Allowance
        public ActionResult Allowance()
        {
            try
            {
                var _medicalAllowanceList = new List <MedicalAllowanceInfo>();

                using (MedicalAllowanceRepository Repo = new MedicalAllowanceRepository())
                {
                    _medicalAllowanceList = Repo.GetMedicalAllowancesList();
                }

                return(View(_medicalAllowanceList));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Medical", "Allowance")));
            }
        }
Ejemplo n.º 6
0
        public ActionResult ProcessRequest(string CheckoutId = "", string ProcessBtn = "")
        {
            try
            {
                int _id;
                MedicalCheckoutInfo  _checkout         = null;
                EmployeeInfo         _employeeInfo     = null;
                MedicalAllowanceInfo _medicalAllowance = null;

                if (!int.TryParse(CheckoutId, out _id))
                {
                    TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong, please try again later.");

                    return(RedirectToAction("Requests", "Medical"));
                }

                using (MedicalCheckoutRepository CheckoutRepo = new MedicalCheckoutRepository())
                {
                    _checkout = CheckoutRepo.GetMedicalCheckoutById(_id);

                    if (_checkout == null)
                    {
                        TempData["Msg"] = AlertMessageProvider.FailureMessage("Checkout not found.");

                        return(RedirectToAction("Requests", "Medical"));
                    }

                    if (ProcessBtn != "Approve" && ProcessBtn != "Reject")
                    {
                        TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong, please try again later.");

                        return(RedirectToAction("RequestDetails", "Medical", new { id = _checkout.Id }));
                    }

                    if (ProcessBtn == "Approve")
                    {
                        using (EmployeeRepository EmployeeRepo = new EmployeeRepository())
                        {
                            _employeeInfo = EmployeeRepo.GetEmployeeInfoById(_checkout.EmployeeInfoId);
                        }

                        using (MedicalAllowanceRepository AllowanceRepo = new MedicalAllowanceRepository())
                        {
                            if (_employeeInfo.MaritalStatus == "Single")
                            {
                                _medicalAllowance = AllowanceRepo.GetMedicalAllowanceByCategory("Single");
                            }
                            else
                            {
                                _medicalAllowance = AllowanceRepo.GetMedicalAllowanceByCategory("Married");
                            }
                        }

                        var _availedMedical = CheckoutRepo.GetAvailedMedicalCheckoutsListByEmployeeIdYearwise(_checkout.EmployeeInfoId, DateTime.Now.ToString("yyyy"));

                        var remainingMedicalAmount = _medicalAllowance.Amount - _availedMedical.Sum(x => x.Amount);

                        if (_checkout.Amount > remainingMedicalAmount)
                        {
                            TempData["Msg"] = AlertMessageProvider.FailureMessage("This request cannot be process, employee has insufficient medical amount.");

                            return(RedirectToAction("RequestDetails", "Medical", new { id = _checkout.EmployeeInfoId }));
                        }

                        _checkout.Status = "Approved";

                        TempData["Msg"] = AlertMessageProvider.SuccessMessage("Medical request approved successfully.");
                    }
                    else
                    {
                        _checkout.Status = "Incomplete";

                        TempData["Msg"] = AlertMessageProvider.SuccessMessage("Medical request rejected successfully.");
                    }

                    CheckoutRepo.UpdateMedicalCheckout(_checkout);
                }

                return(RedirectToAction("RequestDetails", "Medical", new { id = _checkout.EmployeeInfoId }));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Medical", "ProcessRequest")));
            }
        }
Ejemplo n.º 7
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")));
            }
        }
Ejemplo n.º 8
0
        public ActionResult SaveCheckout(MedicalCheckoutInfo medicalCheckoutInfo)
        {
            try
            {
                int                  _medicalCheckoutId = 0;
                EmployeeInfo         _employeeInfo      = null;
                MedicalAllowanceInfo _medicalAllowance  = null;

                if (!ModelState.IsValid)
                {
                    TempData["Msg"] = AlertMessageProvider.FailureMessage("Invalid data.");

                    return(RedirectToAction("Details", "Medical"));
                }

                if (medicalCheckoutInfo.TreatmentDate > DateTime.Now.Date)
                {
                    TempData["Msg"] = AlertMessageProvider.FailureMessage("Treatment date cannot be earlier than today.");

                    return(RedirectToAction("Details", "Medical"));
                }

                using (FamilyMemberRepository Repo = new FamilyMemberRepository())
                {
                    FamilyMemberInfo _familyMember = null;

                    _familyMember = Repo.GetFamilyMemberById(medicalCheckoutInfo.FamilyMemberId);

                    if (_familyMember == null || _familyMember.EmployeeInfoId != CurrentUser.EmployeeInfoId)
                    {
                        TempData["Msg"] = AlertMessageProvider.FailureMessage("Invalid patient name.");

                        return(RedirectToAction("Details", "Medical"));
                    }
                }

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

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

                using (MedicalCheckoutRepository Repo = new MedicalCheckoutRepository())
                {
                    var _availedMedical = Repo.GetAvailedMedicalCheckoutsListByEmployeeIdYearwise(CurrentUser.EmployeeInfoId, DateTime.Now.ToString("yyyy"));

                    var remainingMedicalAmount = _medicalAllowance.Amount - _availedMedical.Sum(x => x.Amount);

                    if (medicalCheckoutInfo.Amount > remainingMedicalAmount)
                    {
                        TempData["Msg"] = AlertMessageProvider.FailureMessage("Selected amount cannot be greater than remaining medical amount.");

                        return(RedirectToAction("Details", "Medical"));
                    }

                    medicalCheckoutInfo.EmployeeInfoId = CurrentUser.EmployeeInfoId;
                    medicalCheckoutInfo.Status         = "Incomplete";

                    _medicalCheckoutId = Repo.SaveMedicalCheckout(medicalCheckoutInfo);
                }

                return(RedirectToAction("Apply", "Medical", new { id = _medicalCheckoutId }));
            }

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