Пример #1
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));
        }
Пример #2
0
        public void SaveFamilyMember(FamilyMemberInfo familyMemberInfo)
        {
            Data.FamilyMember familyMember = ConvertToDb(familyMemberInfo);

            _context.FamilyMembers.Add(familyMember);
            _context.SaveChanges();
        }
Пример #3
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")));
            }
        }
Пример #4
0
        internal static FamilyMemberInfoList Load(this FamilyMemberInfoList familyMemberInfoList)
        {
            foreach (var familyMember in FamilyMember.GetFamilyMemberList())
            {
                familyMemberInfoList.Add(FamilyMemberInfo.NewFamilyMemberInfo(familyMember.FamilyMemberId,
                                                                              familyMember.Name, familyMember.ParentId));
            }

            return(familyMemberInfoList);
        }
Пример #5
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")));
            }
        }
Пример #6
0
 public Data.FamilyMember ConvertToDb(FamilyMemberInfo familyMemberInfo)
 {
     return(new Data.FamilyMember
     {
         Id = familyMemberInfo.Id,
         Name = familyMemberInfo.Name,
         CNIC = familyMemberInfo.CNIC,
         Relation = familyMemberInfo.Relation,
         EmployeeInfoId = familyMemberInfo.EmployeeInfoId
     });
 }
Пример #7
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());
            }
        }
Пример #8
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")));
            }
        }
Пример #9
0
        public void UpdateFamilyMember(FamilyMemberInfo familyMemberInfo)
        {
            Data.FamilyMember familyMember = _context.FamilyMembers.Find(familyMemberInfo.Id);

            if (familyMember != null)
            {
                familyMember.Name     = familyMemberInfo.Name;
                familyMember.CNIC     = familyMemberInfo.CNIC;
                familyMember.Relation = familyMemberInfo.Relation;

                _context.SaveChanges();
            }
            else
            {
                throw new ArgumentNullException();
            }
        }
Пример #10
0
        public ActionResult Delete(string FamilyMemberId = "")
        {
            try
            {
                int id;
                FamilyMemberInfo _familyMember = null;

                if (!int.TryParse(FamilyMemberId, 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(FamilyMemberId));

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

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

                    Repo.DeleteFamilyMember(int.Parse(FamilyMemberId));
                }

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

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

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

                return(View());
            }
        }
Пример #11
0
        public ActionResult Delete(string FamilyMemberId = "")
        {
            try
            {
                int id;
                FamilyMemberInfo _familyMember = null;

                if (!int.TryParse(FamilyMemberId, 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(FamilyMemberId));

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

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

                    Repo.DeleteFamilyMember(int.Parse(FamilyMemberId));
                }

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

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

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Family", "Delete")));
            }
        }
Пример #12
0
        // GET: Admin/Family/Add
        public ActionResult Add(string id = "")
        {
            try
            {
                int _id;
                var _familyMember = new FamilyMemberInfo();

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

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

                _familyMember.EmployeeInfoId = _id;

                return(View(_familyMember));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Family", "Add")));
            }
        }
Пример #13
0
        public ActionResult Add(FamilyMemberInfo familyMemberInfo)
        {
            try
            {
                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"));
                }

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

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

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

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

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

                return(View());
            }
        }
 public FamilyMemberTreeViewModel()
 {
     DisplayName = "FamilyMemberTree";
     Model       = FamilyMemberInfo.GetFamilyMemberInfoList();
 }
Пример #15
0
        public ActionResult Create(AccountInfo accountInfo)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var _employeeInfo = new Model.EmployeeInfo();
                    _employeeInfo.CreatedByAccountId = CurrentUser.AccountId;
                    _employeeInfo.CreatedDate        = DateTime.Now;

                    int employeeInfoId;
                    int accountId;

                    string saltValue = RandomPassword.Generate(18, 20);
                    string password  = RijndaelCrypt.EncryptPassword(RandomPassword.Generate(), saltValue);

                    accountInfo.CompanyEmail     = accountInfo.CompanyEmail.ToLower();
                    accountInfo.PasswordHash     = password;
                    accountInfo.Salt             = saltValue;
                    accountInfo.LastLoginDate    = DateTime.Now;
                    accountInfo.LastLoginIp      = "";
                    accountInfo.IsActive         = true;
                    accountInfo.IsFirstTimeLogin = true;

                    using (var transaction = new System.Transactions.TransactionScope())
                    {
                        using (AccountRepository Repo = new AccountRepository())
                        {
                            if (Repo.IsEmailExist(accountInfo.CompanyEmail) == true)
                            {
                                TempData["Msg"] = AlertMessageProvider.FailureMessage("Email already exist.");

                                return(View());
                            }

                            int roleId = Repo.GetRoleIdByName("Anonymous");
                            accountInfo.RoleId = roleId;

                            accountId = Repo.CreateAccount(accountInfo);
                        }

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

                            Repo.SaveAccountCheckList(_accountCheckList);
                        }

                        using (EmployeeRepository Repo = new EmployeeRepository())
                        {
                            _employeeInfo.AccountId = accountId;

                            employeeInfoId = Repo.SaveEmployeeInfo(_employeeInfo);
                        }

                        using (LeaveAllowedRepository Repo = new LeaveAllowedRepository())
                        {
                            LeaveAllowedInfo _leaveAllowed = new LeaveAllowedInfo(0, 0, employeeInfoId, CurrentUser.AccountId);

                            Repo.SaveLeaveAllowed(_leaveAllowed);
                        }

                        using (SalaryRepository Repo = new SalaryRepository())
                        {
                            var _salaryInfo = new SalaryInfo(CurrentUser.AccountId, employeeInfoId);

                            Repo.SaveSalary(_salaryInfo);
                        }

                        using (FamilyMemberRepository Repo = new FamilyMemberRepository())
                        {
                            var _familyMember = new FamilyMemberInfo
                            {
                                Name           = "Self",
                                Relation       = "Selef",
                                EmployeeInfoId = employeeInfoId
                            };

                            Repo.SaveFamilyMember(_familyMember);
                        }

                        transaction.Complete();
                    }

                    List <string> To = new List <string>()
                    {
                        accountInfo.CompanyEmail
                    };
                    string Subject  = "LPS Online Account Information";
                    var    LoginUrl = Url.Action("Login", "Auth", new { Area = "" }, protocol: Request.Url.Scheme);

                    string Body = "Dear Employee, <br/><br/>" +
                                  "Your account has been created.<br/>" +
                                  "Please ensure to save the username and password written below:<br/><br/>" +
                                  "Username: &nbsp; <b>" + accountInfo.CompanyEmail + "</b><br/>" +
                                  "Password: &nbsp; <b>" + RijndaelCrypt.DecryptPassword(accountInfo.PasswordHash, accountInfo.Salt) + "</b><br/><br/>" +
                                  "<a href='" + LoginUrl + "' target='_blank'>" + LoginUrl + "</a><br/>" +
                                  "You can login to your account to use LPS online services.<br/><br/>" +
                                  "Thanks,<br/>" +
                                  "<b>Logic Powered Solutions</b>";

                    bool result = EmailSender.Send(Subject, Body, To);

                    if (result)
                    {
                        TempData["Msg"] = AlertMessageProvider.SuccessMessage("Account created, email has been sent to employee successfully.");
                    }
                    else
                    {
                        TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong! email not sent, please try again later.");
                    }

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

                return(View());
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Account", "Create")));
            }
        }
Пример #16
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")));
            }
        }