示例#1
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")));
            }
        }
示例#2
0
        // GET: Admin/Medical/ViewPrescription
        public ActionResult ViewPrescription(string id = "")
        {
            try
            {
                int _id;
                MedicalPrescriptionInfo _prescription = null;

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

                    return(View(_prescription));
                }

                using (MedicalPrescriptionRepository Repo = new MedicalPrescriptionRepository())
                {
                    _prescription = Repo.GetMedicalPrescriptionById(_id);

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

                        return(View(_prescription));
                    }
                }

                return(View(_prescription));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Medical", "ViewPrescription")));
            }
        }
示例#3
0
        public ActionResult DownloadPrescription(string id = "")
        {
            try
            {
                int _id;
                MedicalPrescriptionInfo _prescription = null;

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

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

                using (MedicalPrescriptionRepository Repo = new MedicalPrescriptionRepository())
                {
                    _prescription = Repo.GetMedicalPrescriptionById(_id);

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

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

                var prescriptionPath = Server.MapPath(_prescription.PrescriptionPath);
                return(File(prescriptionPath, MimeMapping.GetMimeMapping(prescriptionPath), _prescription.FileName));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Medical", "DownloadPrescription")));
            }
        }
示例#4
0
        // GET: EmployeeReg/Account/ResetPassword
        public ActionResult ResetPassword()
        {
            try
            {
                AuthenticatedUser _authUser;

                using (AuthRepository Repo = new AuthRepository())
                {
                    _authUser = Repo.GetAuthenticatedUserById(CurrentUser.EmployeeInfoId);
                }

                if (_authUser.IsFirstTimeLogin == false)
                {
                    return(RedirectToAction("PersonalInfo", "Profile"));
                }

                return(View());
            }

            catch (Exception ex)
            {
                TempData["Msg"] = AlertMessageProvider.FailureMessage(ex.ToString());

                return(View());
            }
        }
示例#5
0
        public ActionResult Details(string TaxYear = "")
        {
            try
            {
                int _temp;

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

                    return(View());
                }

                var _paySlipList = new List <PaySlipInfo>();

                using (PaySlipRepository Repo = new PaySlipRepository())
                {
                    ViewBag.TaxYear = new SelectList(Repo.GetSalaryYearList(CurrentUser.EmployeeInfoId));

                    _paySlipList = Repo.GetPayslipListByEmployeeId(CurrentUser.EmployeeInfoId, TaxYear);
                }

                return(View(_paySlipList));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Tax", "Details")));
            }
        }
示例#6
0
        // GET: EmployeeReg/Family/Update
        public ActionResult Update(string id = "")
        {
            int _id;
            FamilyMemberInfo _familyMember = null;

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

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

            using (FamilyMemberRepository Repo = new FamilyMemberRepository())
            {
                _familyMember = Repo.GetFamilyMemberById(int.Parse(id));
            }

            if (_familyMember == null || _familyMember.EmployeeInfoId != CurrentUser.EmployeeInfoId)
            {
                TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong, please try again later.");

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

            return(View(_familyMember));
        }
示例#7
0
        public ActionResult Details(string SalaryDateYear = "", string id = "")
        {
            try
            {
                ViewBag.EmployeeId = GetEmployeeFullNameList();
                int _id;
                int _salaryDateYear;

                var _empSalariesModel = new EmployeeSalariesViewModel();
                _empSalariesModel.PaySlipInfoList = new List <PaySlipInfo>();

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

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

                using (PaySlipRepository Repo = new PaySlipRepository())
                {
                    ViewBag.SalaryDateYear = new SelectList(Repo.GetSalaryYearList(_id));

                    _empSalariesModel.PaySlipInfoList = Repo.GetPayslipListByEmployeeId(_id, SalaryDateYear);
                }

                _empSalariesModel.Id = _id;

                return(View(_empSalariesModel));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Salary", "Details")));
            }
        }
示例#8
0
        // GET: Admin/Family/Update
        public ActionResult Update(string id = "")
        {
            try
            {
                int _id;
                FamilyMemberInfo _familyMember = null;

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

                    return(RedirectToAction("Manage", "Profile"));
                }

                using (FamilyMemberRepository Repo = new FamilyMemberRepository())
                {
                    _familyMember = Repo.GetFamilyMemberById(int.Parse(id));
                }

                if (_familyMember == null)
                {
                    TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong, please try again later.");

                    return(RedirectToAction("Manage", "Profile"));
                }

                return(View(_familyMember));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Family", "Update")));
            }
        }
示例#9
0
        public ActionResult DownloadDocument(string DocumentId = "")
        {
            try
            {
                int          _id;
                DocumentInfo _document = null;

                if (!int.TryParse(DocumentId, out _id))
                {
                    TempData["Msg"] = AlertMessageProvider.FailureMessage("Invalid document id, please provide valid document id.");

                    return(RedirectToAction("Manage", "Profile"));
                }

                using (DocumentRepository Repo = new DocumentRepository())
                {
                    _document = Repo.GetDocumentById(_id);
                }

                if (_document == null)
                {
                    TempData["Msg"] = AlertMessageProvider.FailureMessage("Document does not exist.");

                    return(RedirectToAction("Manage", "Profile"));
                }

                var filepath = Server.MapPath(_document.DocumentPath);
                return(File(filepath, MimeMapping.GetMimeMapping(filepath), _document.FileName));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Profile", "DownloadDocument")));
            }
        }
示例#10
0
        // GET: EmployeeReg/File/Preview
        public ActionResult ReviewInfo()
        {
            try
            {
                var _registrationViewModel = new RegistrationViewModel();
                _registrationViewModel.documentInfoList = new List <DocumentInfo>();

                using (EmployeeRepository Repo = new EmployeeRepository())
                {
                    _registrationViewModel.employeeRegistrationInfo = Repo.GetRegisterEmployeeInfoById(CurrentUser.EmployeeInfoId);
                }

                using (DocumentRepository Repo = new DocumentRepository())
                {
                    _registrationViewModel.documentInfoList = Repo.GetDocumentListByEmployeeId(CurrentUser.EmployeeInfoId);
                }

                if (_registrationViewModel.employeeRegistrationInfo.MaritalStatus == "Married")
                {
                    using (FamilyMemberRepository Repo = new FamilyMemberRepository())
                    {
                        _registrationViewModel.familyMembersList = Repo.GetFamilyMembersListByEmployeeId(CurrentUser.EmployeeInfoId);
                    }
                }

                return(PartialView("_ReviewInfo", _registrationViewModel));
            }

            catch (Exception ex)
            {
                TempData["Msg"] = AlertMessageProvider.FailureMessage(ex.ToString());

                return(View());
            }
        }
示例#11
0
        public ActionResult Delete(string LeaveId = "", string EmployeeInfoId = "")
        {
            try
            {
                int _leaveId;
                int _employeeInfoId;
                LeaveRequestInfo _leave = null;

                if (!int.TryParse(LeaveId, out _leaveId) || !int.TryParse(EmployeeInfoId, out _employeeInfoId))
                {
                    return(RedirectToAction("Manage", "Leave"));
                }

                using (LeaveRequestRepository Repo = new LeaveRequestRepository())
                {
                    _leave = Repo.GetLeaveRequestById(_leaveId);

                    if (_leave == null)
                    {
                        return(RedirectToAction("Manage", "Leave"));
                    }

                    Repo.DeleteLeaveRequest(_leaveId);
                }

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

                return(RedirectToAction("Manage", "Leave", new { id = EmployeeInfoId }));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Leave", "Delete")));
            }
        }
示例#12
0
        public ActionResult DeletePhoto(string PhotoId = "", string AlbumId = "")
        {
            try
            {
                int       _photoId;
                int       _albumId;
                PhotoInfo _photoInfo = null;
                AlbumInfo _albumInfo = null;

                if (!int.TryParse(PhotoId, out _photoId) || !int.TryParse(AlbumId, out _albumId))
                {
                    TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong, please try again later.");

                    return(RedirectToAction("Manage", "Gallery"));
                }

                using (AlbumRepository Repo = new AlbumRepository())
                {
                    _albumInfo = Repo.GetAlbumById(_albumId);
                }

                if (_albumInfo == null)
                {
                    TempData["Msg"] = AlertMessageProvider.FailureMessage("Album does not exist.");

                    return(RedirectToAction("Manage", "Gallery"));
                }

                using (PhotoRepository Repo = new PhotoRepository())
                {
                    _photoInfo = Repo.GetPhotoById(_photoId);

                    if (_photoInfo == null)
                    {
                        TempData["Msg"] = AlertMessageProvider.FailureMessage("Photo does not exist.");

                        return(RedirectToAction("Manage", "Gallery"));
                    }

                    string fullPath = Request.MapPath(_photoInfo.Path);

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

                    Repo.DeletePhoto(_photoId);

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

                    return(RedirectToAction("UploadPhotos", "Gallery", new { id = AlbumId }));
                }
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Gallery", "DeletePhoto")));
            }
        }
示例#13
0
        public ActionResult DownloadPrescriptions(string CheckoutId = "")
        {
            try
            {
                int id;
                var _prescriptionsList        = new List <MedicalPrescriptionInfo>();
                MedicalCheckoutInfo _checkout = null;
                var outputStream = new MemoryStream();

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

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

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

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

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

                var _zipName = _checkout.PatientName + "_Prescriptions_" + _checkout.TreatmentDate.Value.ToString("dd-MM-yyyy");

                using (MedicalPrescriptionRepository PrescriptionRepo = new MedicalPrescriptionRepository())
                {
                    _prescriptionsList = PrescriptionRepo.GetMedicalPrescriptionsListByMedicalCheckoutId(id);

                    using (var zip = new ZipFile())
                    {
                        foreach (var item in _prescriptionsList)
                        {
                            zip.AddFile(Server.MapPath(item.PrescriptionPath), string.Empty).FileName = item.FileName;
                        }

                        zip.Save(outputStream);
                    }
                }

                outputStream.Position = 0;

                return(File(outputStream, "application/zip", _zipName));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Medical", "DownloadPrescriptions")));
            }
        }
示例#14
0
        public ActionResult UpdateCheckout(MedicalCheckoutInfo medicalCheckoutInfo)
        {
            try
            {
                int _id;
                MedicalCheckoutInfo _medicalCheckout = null;

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

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

                if (!int.TryParse(medicalCheckoutInfo.Id.ToString(), out _id))
                {
                    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 (MedicalCheckoutRepository Repo = new MedicalCheckoutRepository())
                {
                    _medicalCheckout = Repo.GetMedicalCheckoutById(_id);

                    if (_medicalCheckout == null || _medicalCheckout.EmployeeInfoId != CurrentUser.EmployeeInfoId || _medicalCheckout.Status == "Approved")
                    {
                        TempData["Msg"] = AlertMessageProvider.FailureMessage("Checkout not found.");

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

                    Repo.UpdateMedicalCheckout(medicalCheckoutInfo);
                }

                return(RedirectToAction("Apply", "Medical", new { id = medicalCheckoutInfo.Id }));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Medical", "UpdateCheckout")));
            }
        }
示例#15
0
        // GET: EmployeeReg/File/UploadPicture
        public ActionResult UploadPicture()
        {
            try
            {
                AuthenticatedUser _authUser;
                var _registration = new RegistrationViewModel();

                using (AuthRepository Repo = new AuthRepository())
                {
                    _authUser = Repo.GetAuthenticatedUserById(CurrentUser.EmployeeInfoId);
                }

                if (_authUser.IsCheckListCompleted == true)
                {
                    return(RedirectToAction("Logout", "Auth", new { area = "" }));
                }

                using (EmployeeRepository Repo = new EmployeeRepository())
                {
                    _registration.employeeRegistrationInfo = Repo.GetRegisterEmployeeInfoById(CurrentUser.EmployeeInfoId);
                }

                using (AccountCheckListRepository Repo = new AccountCheckListRepository())
                {
                    _registration.accountCheckListInfo = Repo.GetAccountCheckListByUserId(CurrentUser.AccountId);
                }

                if (_registration.accountCheckListInfo.IsDocumentsUploaded == false)
                {
                    return(RedirectToAction("UploadDocuments", "File"));
                }

                if (_registration.employeeRegistrationInfo.MaritalStatus == "Married")
                {
                    using (FamilyMemberRepository FamilyRepo = new FamilyMemberRepository())
                    {
                        _registration.familyMembersList = FamilyRepo.GetFamilyMembersListByEmployeeId(CurrentUser.EmployeeInfoId);

                        if (_registration.familyMembersList.Count() <= 0)
                        {
                            return(RedirectToAction("Details", "Family"));
                        }
                    }
                }

                return(View(_registration));
            }

            catch (Exception ex)
            {
                TempData["Msg"] = AlertMessageProvider.FailureMessage(ex.ToString());

                return(View());
            }
        }
示例#16
0
        public ActionResult ApplyMedical(string id = "")
        {
            try
            {
                int _id;
                MedicalCheckoutInfo _medicalCheckout = null;

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

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

                using (MedicalPrescriptionRepository Repo = new MedicalPrescriptionRepository())
                {
                    var _prescriptions = Repo.GetMedicalPrescriptionsListByMedicalCheckoutId(_id);

                    if (_prescriptions.Count() == 0)
                    {
                        TempData["Msg"] = AlertMessageProvider.FailureMessage("Please upload prescription(s).");

                        return(RedirectToAction("Details", "Medical", new { id = _id }));
                    }
                }

                using (MedicalCheckoutRepository Repo = new MedicalCheckoutRepository())
                {
                    _medicalCheckout = Repo.GetMedicalCheckoutById(_id);

                    if (_medicalCheckout == null || _medicalCheckout.EmployeeInfoId != CurrentUser.EmployeeInfoId || _medicalCheckout.Status == "Approved")
                    {
                        TempData["Msg"] = AlertMessageProvider.FailureMessage("Checkout not found.");

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

                    _medicalCheckout.RequestDate      = DateTime.Now;
                    _medicalCheckout.IsCreatedByAdmin = false;
                    _medicalCheckout.Status           = "Pending";

                    Repo.UpdateMedicalCheckout(_medicalCheckout);

                    TempData["Msg"] = AlertMessageProvider.SuccessMessage("You have applied for medical successfully.");
                }

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

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Medical", "ApplyMedical")));
            }
        }
示例#17
0
        public ActionResult ResetPassword(ResetNewPasswordViewModel _passwordInfo)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View());
                }

                AuthenticatedUser _authUser;

                using (AuthRepository Repo = new AuthRepository())
                {
                    _authUser = Repo.GetAuthenticatedUserById(CurrentUser.EmployeeInfoId);
                }

                if (_authUser.IsFirstTimeLogin == false)
                {
                    return(RedirectToAction("GeneralInfo", "Profile"));
                }

                if (RijndaelCrypt.DecryptPassword(_authUser.PasswordHash, _authUser.Salt) == _passwordInfo.NewPassword)
                {
                    TempData["Msg"] = AlertMessageProvider.FailureMessage("New password should not be same as current password.");

                    return(View());
                }

                var _accountInfo = new AccountInfo();
                _accountInfo.Id               = CurrentUser.AccountId;
                _accountInfo.Salt             = RandomPassword.Generate(18, 20);
                _accountInfo.PasswordHash     = RijndaelCrypt.EncryptPassword(_passwordInfo.NewPassword, _accountInfo.Salt);
                _accountInfo.IsFirstTimeLogin = false;

                using (AccountRepository Repo = new AccountRepository())
                {
                    Repo.ChangeNewPassword(_accountInfo);
                }

                var ctx         = Request.GetOwinContext();
                var authManager = ctx.Authentication;
                authManager.SignOut("ApplicationCookie");

                TempData["Msg"] = "<span style='color:green; text-align:center;'>Password has been reset successfully.</span>";
                return(RedirectToAction("Login", "Auth", new { area = "" }));
            }

            catch (Exception ex)
            {
                TempData["Msg"] = AlertMessageProvider.FailureMessage(ex.ToString());

                return(View());
            }
        }
示例#18
0
        public ActionResult Update(FamilyMemberInfo familyMemberInfo)
        {
            try
            {
                int id;
                FamilyMemberInfo _familyMember = null;

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

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

                if (!ModelState.IsValid)
                {
                    return(RedirectToAction("Details", "Family"));
                }

                if (familyMemberInfo.Relation != "Wife" && familyMemberInfo.Relation != "Son" && familyMemberInfo.Relation != "Daughter")
                {
                    TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong, please try again later.");

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

                using (FamilyMemberRepository Repo = new FamilyMemberRepository())
                {
                    _familyMember = Repo.GetFamilyMemberById(familyMemberInfo.Id);

                    if (_familyMember == null || _familyMember.EmployeeInfoId != CurrentUser.EmployeeInfoId)
                    {
                        TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong, please try again later.");

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

                    Repo.UpdateFamilyMember(familyMemberInfo);
                }

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

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

            catch (Exception ex)
            {
                TempData["Msg"] = AlertMessageProvider.FailureMessage(ex.ToString());

                return(View());
            }
        }
示例#19
0
        public ActionResult DeleteDocument(string DocumentId = "")
        {
            try
            {
                int          _id;
                DocumentInfo _document = null;

                if (!int.TryParse(DocumentId, out _id))
                {
                    TempData["Msg"] = AlertMessageProvider.FailureMessage("Invalid document id, please provide valid document id.");

                    return(RedirectToAction("Manage", "Profile"));
                }

                using (DocumentRepository Repo = new DocumentRepository())
                {
                    _document = Repo.GetDocumentById(_id);

                    if (_document == null)
                    {
                        TempData["Msg"] = AlertMessageProvider.FailureMessage("Document does not exist.");

                        return(RedirectToAction("Manage", "Profile"));
                    }

                    string _docPath = Request.MapPath(_document.DocumentPath);

                    if (System.IO.File.Exists(_docPath))
                    {
                        System.IO.File.Delete(_docPath);

                        Repo.DeleteDocument(_document.Id);
                    }
                    else
                    {
                        TempData["Msg"] = AlertMessageProvider.FailureMessage("Document does not exist.");

                        return(RedirectToAction("Manage", "Profile", new { id = _document.EmployeeInfoId }));
                    }
                }

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

                return(RedirectToAction("Manage", "Profile", new { id = _document.EmployeeInfoId }));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Profile", "DeleteDocument")));
            }
        }
示例#20
0
        // GET: EmployeeReg/Profile/PersonalInfo
        public ActionResult PersonalInfo()
        {
            try
            {
                AuthenticatedUser _authUser;
                var _registration = new RegistrationViewModel();

                using (AuthRepository Repo = new AuthRepository())
                {
                    _authUser = Repo.GetAuthenticatedUserById(CurrentUser.EmployeeInfoId);
                }

                if (_authUser.IsFirstTimeLogin == true)
                {
                    return(RedirectToAction("ResetPassword", "Account"));
                }

                if (_authUser.IsCheckListCompleted == true)
                {
                    return(RedirectToAction("Logout", "Auth", new { area = "" }));
                }

                using (EmployeeRepository Repo = new EmployeeRepository())
                {
                    _registration.employeeRegistrationInfo = Repo.GetRegisterEmployeeInfoById(CurrentUser.EmployeeInfoId);
                }

                using (AccountCheckListRepository Repo = new AccountCheckListRepository())
                {
                    _registration.accountCheckListInfo = Repo.GetAccountCheckListByUserId(CurrentUser.AccountId);
                }

                if (_registration.employeeRegistrationInfo.MaritalStatus == "Married")
                {
                    using (FamilyMemberRepository Repo = new FamilyMemberRepository())
                    {
                        _registration.familyMembersList = Repo.GetFamilyMembersListByEmployeeId(CurrentUser.EmployeeInfoId);
                    }
                }

                return(View(_registration));
            }

            catch (Exception ex)
            {
                TempData["Msg"] = AlertMessageProvider.FailureMessage(ex.ToString());

                return(View());
            }
        }
示例#21
0
        public ActionResult ChangePassword(ChangePasswordViewModel passwordInfo)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View());
                }

                var _account = new AccountInfo();

                using (AccountRepository Repo = new AccountRepository())
                {
                    _account = Repo.GetEmployeeAccountById(CurrentUser.AccountId);
                }

                string decryptedPassword = RijndaelCrypt.DecryptPassword(_account.PasswordHash, _account.Salt);

                if (decryptedPassword != passwordInfo.CurrentPassword)
                {
                    TempData["Msg"] = AlertMessageProvider.FailureMessage("Current password is invalid.");

                    return(View());
                }

                if (decryptedPassword == passwordInfo.NewPassword)
                {
                    TempData["Msg"] = AlertMessageProvider.FailureMessage("New password should not be same as current password.");

                    return(View());
                }

                _account.Salt         = RandomPassword.Generate(18, 20);
                _account.PasswordHash = RijndaelCrypt.EncryptPassword(passwordInfo.NewPassword, _account.Salt);

                using (AccountRepository Repo = new AccountRepository())
                {
                    Repo.ChangeNewPassword(_account);
                }

                TempData["Msg"] = AlertMessageProvider.SuccessMessage("Password changed successfully.");

                return(View());
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Auth", "ChangePassword")));
            }
        }
示例#22
0
        public ActionResult DeletePrescription(string PrescriptionId)
        {
            try
            {
                int id;
                MedicalPrescriptionInfo _prescription = null;

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

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

                using (MedicalPrescriptionRepository Repo = new MedicalPrescriptionRepository())
                {
                    _prescription = Repo.GetMedicalPrescriptionById(id);

                    if (_prescription == null || _prescription.EmployeeInfoId != CurrentUser.EmployeeInfoId || _prescription.CheckoutStatus == "Approved")
                    {
                        TempData["Msg"] = AlertMessageProvider.FailureMessage("Prescription not found.");

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

                    string _prescriptionPath = Request.MapPath(_prescription.PrescriptionPath);

                    if (System.IO.File.Exists(_prescriptionPath))
                    {
                        System.IO.File.Delete(_prescriptionPath);

                        Repo.DeleteMedicalPrescription(_prescription.Id);
                    }
                    else
                    {
                        TempData["Msg"] = AlertMessageProvider.FailureMessage("Prescription does not exist physically.");
                    }
                }

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

                return(RedirectToAction("Apply", "Medical", new { id = _prescription.MedicalCheckoutId }));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Medical", "DeletePrescription")));
            }
        }
示例#23
0
        public ActionResult DeletePayslip(string PayslipId = "")
        {
            try
            {
                int         _id;
                PaySlipInfo _paySlip      = null;
                string      previousMonth = DateTime.Now.AddMonths(-1).ToString("MMMM - yyyy");
                string      currentMonth  = DateTime.Now.ToString("MMMM - yyyy");
                string      nextMonth     = DateTime.Now.AddMonths(1).ToString("MMMM - yyyy");

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

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

                using (PaySlipRepository Repo = new PaySlipRepository())
                {
                    _paySlip = Repo.GetPayslipById(_id);

                    if (_paySlip == null)
                    {
                        TempData["Msg"] = AlertMessageProvider.FailureMessage("Payslip does not exist.");

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

                    if (_paySlip.SalaryDate.ToString("MMMM - yyyy") != previousMonth && _paySlip.SalaryDate.ToString("MMMM - yyyy") != currentMonth && _paySlip.SalaryDate.ToString("MMMM - yyyy") != nextMonth)
                    {
                        TempData["Msg"] = AlertMessageProvider.FailureMessage("Selected payslip cannot be deleted.");

                        return(RedirectToAction("Details", "Salary", new { id = _paySlip.EmployeeInfoId }));
                    }

                    Repo.DeletePayslip(_id);

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

                return(RedirectToAction("Details", "Salary", new { id = _paySlip.EmployeeInfoId }));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Salary", "DeletePayslip")));
            }
        }
示例#24
0
        public ActionResult Manage(string MedicalYear = "", string id = "")
        {
            try
            {
                ViewBag.EmployeeId = GetEmployeeFullNameList();

                int _id;
                int _medicalYear;
                var _medicalCheckout = new MedicalCheckoutInfo();
                _medicalCheckout.AvailedMedicalsList = new List <MedicalCheckoutInfo>();

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

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

                if (MedicalYear == DateTime.Now.ToString("yyyy"))
                {
                    return(RedirectToAction("Manage", "Medical"));
                }

                using (MedicalCheckoutRepository Repo = new MedicalCheckoutRepository())
                {
                    ViewBag.MedicalYear = new SelectList(Repo.GetMedicalYearsList(_id));
                    _medicalCheckout.AvailedMedicalsList = Repo.GetAvailedMedicalCheckoutsListByEmployeeIdYearwise(_id, MedicalYear);
                }

                if (_medicalCheckout.AvailedMedicalsList.Count() == 0)
                {
                    TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong, please try again later.");

                    return(RedirectToAction("Manage", "Medical", new { id = _id }));
                }

                _medicalCheckout.EmployeeInfoId   = _id;
                _medicalCheckout.MedicalAllowance = null;

                return(View(_medicalCheckout));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Medical", "Manage")));
            }
        }
示例#25
0
        public ActionResult Add(FamilyMemberInfo familyMemberInfo)
        {
            try
            {
                EmployeeInfo _employee = null;

                if (!ModelState.IsValid)
                {
                    return(RedirectToAction("Manage", "Profile"));
                }

                if (familyMemberInfo.Relation != "Wife" && familyMemberInfo.Relation != "Son" && familyMemberInfo.Relation != "Daughter")
                {
                    TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong, please try again later.");

                    return(RedirectToAction("Manage", "Profile"));
                }

                familyMemberInfo.Name = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(familyMemberInfo.Name.ToLower());

                using (EmployeeRepository Repo = new EmployeeRepository())
                {
                    _employee = Repo.GetEmployeeInfoById(familyMemberInfo.EmployeeInfoId);

                    if (_employee == null)
                    {
                        TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong, please try again later.");

                        return(RedirectToAction("Manage", "Profile"));
                    }
                }

                using (FamilyMemberRepository Repo = new FamilyMemberRepository())
                {
                    Repo.SaveFamilyMember(familyMemberInfo);
                }

                TempData["Msg"] = AlertMessageProvider.SuccessMessage("Family member added successfully.");

                return(RedirectToAction("Manage", "Profile", new { id = familyMemberInfo.EmployeeInfoId }));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Family", "Add")));
            }
        }
示例#26
0
        public ActionResult Delete(int id)
        {
            try
            {
                AccountInfo _accountInfo = null;

                using (AccountRepository Repo = new AccountRepository())
                {
                    _accountInfo = Repo.GetEmployeeAccountById(id);

                    if (_accountInfo == null)
                    {
                        TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong! please try again later.");

                        return(RedirectToAction("Manage"));
                    }

                    if (_accountInfo.IsCheckListCompleted == true)
                    {
                        TempData["Msg"] = AlertMessageProvider.FailureMessage("Unable to delete activated account.");

                        return(RedirectToAction("Manage", "Account"));
                    }

                    var result = Repo.IsDeletedUnActivatedAccount(id);

                    if (result == true)
                    {
                        TempData["Msg"] = AlertMessageProvider.SuccessMessage("Account has been deleted successfully.");
                    }
                    else
                    {
                        TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong! please try again later.");
                    }
                }

                return(RedirectToAction("Manage", "Account"));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Account", "Delete")));
            }
        }
示例#27
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")));
            }
        }
示例#28
0
        public ActionResult ChangePicture()
        {
            try
            {
                AuthenticatedUser _authUser;

                using (AuthRepository Repo = new AuthRepository())
                {
                    _authUser = Repo.GetAuthenticatedUserById(CurrentUser.EmployeeInfoId);
                }

                if (_authUser.IsCheckListCompleted == true)
                {
                    return(RedirectToAction("Logout", "Auth", new { area = "" }));
                }

                string _imgPath = Server.MapPath(Url.Content("~/Content/Employee_pictures/" + CurrentUser.AccountId + ".jpg"));

                if (System.IO.File.Exists(_imgPath))
                {
                    System.IO.File.Delete(_imgPath);

                    using (AccountCheckListRepository Repo = new AccountCheckListRepository())
                    {
                        var _accountCheckList = new AccountCheckListInfo();

                        _accountCheckList.IsPictureUploaded = false;
                        _accountCheckList.AccountId         = CurrentUser.AccountId;

                        Repo.UpdateIsPictureUploaded(_accountCheckList);
                    }
                }

                return(RedirectToAction("UploadPicture", "File"));
            }

            catch (Exception ex)
            {
                TempData["Msg"] = AlertMessageProvider.FailureMessage(ex.ToString());

                return(View());
            }
        }
示例#29
0
        public ActionResult DownloadDocument(string id = "")
        {
            try
            {
                int          _id;
                DocumentInfo _document = null;

                if (!int.TryParse(id, out _id))
                {
                    TempData["Msg"] = AlertMessageProvider.FailureMessage("Invalid document id, please provide valid document id.");

                    return(RedirectToAction("GeneralInfo", "Home"));
                }

                using (DocumentRepository Repo = new DocumentRepository())
                {
                    _document = Repo.GetDocumentById(_id);
                }

                if (_document == null)
                {
                    TempData["Msg"] = AlertMessageProvider.FailureMessage("Document does not exist.");

                    return(RedirectToAction("GeneralInfo", "Home"));
                }

                if (_document.EmployeeInfoId != CurrentUser.EmployeeInfoId)
                {
                    TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong! please try again later.");

                    return(RedirectToAction("GeneralInfo", "Home"));
                }

                var filepath = Server.MapPath(_document.DocumentPath);
                return(File(filepath, MimeMapping.GetMimeMapping(filepath), _document.FileName));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Home", "DownloadDocument")));
            }
        }
示例#30
0
        public ActionResult CancelCheckout(string CheckoutId)
        {
            try
            {
                int id;
                MedicalCheckoutInfo _checkout = null;
                var _prescriptionsList        = new List <MedicalPrescriptionInfo>();

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

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

                using (MedicalCheckoutRepository Repo = new MedicalCheckoutRepository())
                {
                    _checkout = Repo.GetMedicalCheckoutById(id);

                    if (_checkout == null || _checkout.EmployeeInfoId != CurrentUser.EmployeeInfoId || _checkout.Status == "Approved")
                    {
                        TempData["Msg"] = AlertMessageProvider.FailureMessage("Checkout not found.");

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

                    _checkout.Status = "Incomplete";

                    Repo.UpdateMedicalCheckout(_checkout);
                }

                TempData["Msg"] = AlertMessageProvider.SuccessMessage("Checkout canceled successfully.");

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

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