// GET: Employee/Medical/Apply public ActionResult Apply(string id = "") { try { int _id; MedicalCheckoutInfo _medicalCheckout = null; if (!int.TryParse(id, out _id)) { 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")); } using (MedicalPrescriptionRepository Repo = new MedicalPrescriptionRepository()) { _medicalCheckout.MedicalPrescriptions = new List <MedicalPrescriptionInfo>(); _medicalCheckout.MedicalPrescriptions = Repo.GetMedicalPrescriptionsListByMedicalCheckoutId(_id); } return(View(_medicalCheckout)); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "Medical", "Apply"))); } }
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"))); } }
// GET: Employee/Medical/UpdateCheckout public ActionResult UpdateCheckout(string id = "") { try { int _id; MedicalCheckoutInfo _medicalCheckout = null; if (!int.TryParse(id, out _id)) { 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")); } using (FamilyMemberRepository Repo = new FamilyMemberRepository()) { TempData["FamilyMembersList"] = new SelectList(Repo.GetAllFamilyMembersListByEmployeeId(CurrentUser.EmployeeInfoId), "Id", "Name"); } return(View(_medicalCheckout)); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "Medical", "UpdateCheckout"))); } }
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()); } }
// 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"))); } }
public ActionResult DeleteDocument(string id) { try { int n; AuthenticatedUser _authUser; bool isNumeric = int.TryParse(id, out n); if (!isNumeric) { return(RedirectToAction("UploadDocuments", "File")); } using (AuthRepository Repo = new AuthRepository()) { _authUser = Repo.GetAuthenticatedUserById(CurrentUser.EmployeeInfoId); } if (_authUser.IsCheckListCompleted == true) { return(RedirectToAction("Logout", "Auth", new { area = "" })); } using (DocumentRepository Repo = new DocumentRepository()) { var _docInfo = new DocumentInfo(); _docInfo = Repo.GetDocumentById(int.Parse(id)); if (_docInfo == null) { return(RedirectToAction("UploadDocuments", "File")); } if (_docInfo.EmployeeInfoId != CurrentUser.EmployeeInfoId) { return(RedirectToAction("UploadDocuments", "File")); } string _docPath = Request.MapPath(_docInfo.DocumentPath); if (System.IO.File.Exists(_docPath)) { System.IO.File.Delete(_docPath); Repo.DeleteDocument(_docInfo.Id); } else { TempData["Msg"] = AlertMessageProvider.FailureMessage("Document does not exist physically."); return(RedirectToAction("UploadDocuments", "File")); } } TempData["Msg"] = AlertMessageProvider.SuccessMessage("Document deleted successfully."); return(RedirectToAction("UploadDocuments", "File")); } catch (Exception ex) { TempData["Msg"] = AlertMessageProvider.FailureMessage(ex.ToString()); return(View()); } }
public ActionResult UpdateMyInfo(HttpPostedFileBase file, AdminInfoViewModel _adminInfoModel) { try { if (!ModelState.IsValid) { return(View()); } if (CurrentUser.Role != "SuperAdmin") { return(RedirectToAction("Dashboard", "Home")); } bool isImgSelected = false; if (file != null) { if (file.ContentType.Contains("image")) { if (file.ContentLength < 2 * 1024 * 1024) { if (file.FileName.Contains(".jpeg") || file.FileName.Contains(".jpg")) { isImgSelected = true; } else { TempData["Msg"] = AlertMessageProvider.FailureMessage("Please select jpeg, jpg format only."); return(View()); } } else { TempData["Msg"] = AlertMessageProvider.FailureMessage("Please select size upto 2 MB or smaller."); return(View()); } } else { TempData["Msg"] = AlertMessageProvider.FailureMessage("Invalid content type, please select image only."); return(View()); } } _adminInfoModel.EmployeeInfoId = CurrentUser.EmployeeInfoId; _adminInfoModel.ModifiedDate = DateTime.Now; _adminInfoModel.ModifiedByAccountId = CurrentUser.AccountId; using (EmployeeRepository Repo = new EmployeeRepository()) { Repo.UpdateAdminIfo(_adminInfoModel); TempData["Msg"] = AlertMessageProvider.SuccessMessage("Information updated successfully."); } if (isImgSelected == true) { string imgPath = Server.MapPath(Url.Content("~/Content/Employee_pictures/" + CurrentUser.AccountId + ".jpg")); file.SaveAs(imgPath); } return(RedirectToAction("UpdateMyInfo", "Profile")); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "Profile", "UpdateMyInfo"))); } }
public ActionResult CreateAlbum(HttpPostedFileBase file, AlbumInfo albumInfo) { try { if (!ModelState.IsValid) { return(RedirectToAction("Manage", "Gallery")); } albumInfo.Title = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(albumInfo.Title.ToLower()); albumInfo.CreatedByAccountId = CurrentUser.AccountId; albumInfo.CreatedOn = DateTime.Now; if (file != null) { if (file.ContentType.Contains("image")) { if (file.ContentLength < 2 * 1024 * 1024) { if (file.FileName.Contains(".jpeg") || file.FileName.Contains(".jpg")) { if (string.IsNullOrEmpty(albumInfo.Title)) { albumInfo.Title = "Untitled Album"; } if (string.IsNullOrEmpty(albumInfo.Description)) { albumInfo.Description = ""; } string _dirPath = Server.MapPath(Url.Content("~/Content/Album_coverphotos")); bool _isDirectoryExists = System.IO.Directory.Exists(_dirPath); if (!_isDirectoryExists) { System.IO.Directory.CreateDirectory(Server.MapPath(Url.Content("~/Content/Album_coverphotos"))); } albumInfo.CoverPhotoPath = Url.Content("~/Content/Album_coverphotos/" + Guid.NewGuid() + "_" + file.FileName); string imgPath = Server.MapPath(albumInfo.CoverPhotoPath); file.SaveAs(imgPath); } else { TempData["Msg"] = AlertMessageProvider.FailureMessage("Please select jpeg, jpg format only."); return(View()); } } else { TempData["Msg"] = AlertMessageProvider.FailureMessage("Please select size upto 2 MB or smaller."); return(View()); } } else { TempData["Msg"] = AlertMessageProvider.FailureMessage("Invalid content type, please select image only."); return(View()); } } else { if (string.IsNullOrEmpty(albumInfo.Title)) { albumInfo.Title = "Untitled Album"; } if (string.IsNullOrEmpty(albumInfo.Description)) { albumInfo.Description = ""; } albumInfo.CoverPhotoPath = Url.Content("~/Content/default-album-cover.jpg"); } using (AlbumRepository Repo = new AlbumRepository()) { Repo.SaveAlbum(albumInfo); } return(RedirectToAction("Manage", "Gallery")); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "Gallery", "CreateAlbum"))); } }
public ActionResult DeleteAlbum(string AlbumId = "") { try { var _photos = new List <PhotoInfo>(); int _albumId; AlbumInfo _albumInfo = null; if (!int.TryParse(AlbumId, out _albumId)) { TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong, please try again later."); return(RedirectToAction("Manage", "Gallery")); } using (var transaction = new System.Transactions.TransactionScope()) { using (AlbumRepository AlbumRepo = new AlbumRepository()) { _albumInfo = AlbumRepo.GetAlbumById(_albumId); if (_albumInfo == null) { TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong, please try again later."); return(RedirectToAction("Manage", "Gallery")); } using (PhotoRepository PhotoRepo = new PhotoRepository()) { _photos = PhotoRepo.GetPhotoListByAlbumId(_albumId); foreach (var item in _photos) { string fullPath = Request.MapPath(item.Path); if (System.IO.File.Exists(fullPath)) { System.IO.File.Delete(fullPath); } PhotoRepo.DeletePhoto(item.Id); } } string _imgPath = Server.MapPath(_albumInfo.CoverPhotoPath); if (!_imgPath.Contains("default-album-cover.jpg")) { if (System.IO.File.Exists(_imgPath)) { System.IO.File.Delete(_imgPath); } } AlbumRepo.DeleteAlbum(_albumId); } transaction.Complete(); } TempData["Msg"] = AlertMessageProvider.SuccessMessage("Album deleted successfully."); return(RedirectToAction("Manage", "Gallery")); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "Gallery", "DeleteAlbum"))); } }
public ActionResult RequestDetails(LeaveRequestInfo leaveRequestInfo, string ProceedBtn = "") { try { if (!ModelState.IsValid) { return(RedirectToAction("RequestDetails", "Leave", new { id = leaveRequestInfo.Id })); } using (LeaveRequestRepository Repo = new LeaveRequestRepository()) { LeaveRequestInfo leaveRequest = null; leaveRequest = Repo.GetLeaveRequestById(leaveRequestInfo.Id); if (leaveRequest == null) { TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong! please try again later."); return(RedirectToAction("Requests", "Leave")); } leaveRequest.Remark = leaveRequestInfo.Remark; leaveRequest.RequestProcessByAccountId = CurrentUser.AccountId; leaveRequest.RequestProcessDate = DateTime.Now; bool isApproved = false; if (ProceedBtn == "Approve") { leaveRequest.Status = "Approved"; Repo.ApproveLeaveRequest(leaveRequest); isApproved = true; } else if (ProceedBtn == "Reject") { leaveRequest.Status = "Disapproved"; Repo.DeleteLeaveRequest(leaveRequest.Id); } else { TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong! please try again later."); return(RedirectToAction("RequestDetails", "Leave", new { id = leaveRequest.Id })); } string Subject = "Leave(s) Request Response"; string Body = "<b>Status: </b>" + leaveRequest.Status + ".<br/><br/>" + "<b>Remark: </b>" + leaveRequest.Remark + ".<br/><br/>" + "Thanks.<br/>"; var To = new List <string>() { leaveRequest.EmployeeCompanyEmail }; var status = EmailSender.Send(Subject, Body, To); if (isApproved == true) { TempData["Msg"] = AlertMessageProvider.SuccessMessage("Leave request approved successfully."); } else { TempData["Msg"] = AlertMessageProvider.SuccessMessage("Leave request rejected successfully."); } return(RedirectToAction("Requests", "Leave")); } } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "Leave", "RequestDetails"))); } }
public ActionResult UploadPrescription(HttpPostedFileBase file, MedicalCheckoutInfo medicalCheckoutInfo) { try { int id; MedicalCheckoutInfo _medicalCheckout = null; var _prescription = new MedicalPrescriptionInfo(); if (!int.TryParse(medicalCheckoutInfo.Id.ToString(), out id)) { TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong please try again later."); 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")); } if (string.IsNullOrEmpty(medicalCheckoutInfo.PrescriptionName)) { TempData["Msg"] = AlertMessageProvider.FailureMessage("Prescription name is required."); return(RedirectToAction("Details", "Medical")); } if (file != null) { if (file.ContentType.Contains("image")) { if (file.ContentLength < 2 * 1024 * 1024) { if (file.FileName.Contains(".jpeg") || file.FileName.Contains(".jpg")) { _prescription.FileName = medicalCheckoutInfo.PrescriptionName + Path.GetExtension(file.FileName); _prescription.UploadDate = DateTime.Now; _prescription.MedicalCheckoutId = medicalCheckoutInfo.Id; string _dirPath = Server.MapPath(Url.Content("~/Content/Employee_medical_documents/" + _medicalCheckout.EmployeeName + _medicalCheckout.EmployeeInfoId + " Prescriptions")); bool _isDirectoryExists = System.IO.Directory.Exists(_dirPath); if (!_isDirectoryExists) { System.IO.Directory.CreateDirectory(Server.MapPath(Url.Content("~/Content/Employee_medical_documents/" + _medicalCheckout.EmployeeName + _medicalCheckout.EmployeeInfoId + " Prescriptions"))); } Guid guid = Guid.NewGuid(); _prescription.PrescriptionPath = Url.Content("~/Content/Employee_medical_documents/" + _medicalCheckout.EmployeeName + _medicalCheckout.EmployeeInfoId + " Prescriptions/" + _medicalCheckout.EmployeeInfoId + "-" + guid + "-" + _prescription.FileName); string _prescriptionPath = Server.MapPath(_prescription.PrescriptionPath); using (MedicalPrescriptionRepository Repo = new MedicalPrescriptionRepository()) { file.SaveAs(_prescriptionPath); Repo.SaveMedicalPrescription(_prescription); } } else { TempData["Msg"] = AlertMessageProvider.FailureMessage("Please select 'jpeg, jpg' format only."); return(RedirectToAction("Apply", "Medical", new { id = _medicalCheckout.Id })); } } else { TempData["Msg"] = AlertMessageProvider.FailureMessage("Please select size upto 2 MB or smaller."); return(RedirectToAction("Apply", "Medical", new { id = _medicalCheckout.Id })); } } else { TempData["Msg"] = AlertMessageProvider.FailureMessage("Invalid content type, please select image only."); return(RedirectToAction("Apply", "Medical", new { id = _medicalCheckout.Id })); } } else { TempData["Msg"] = AlertMessageProvider.FailureMessage("Please select prescription."); return(RedirectToAction("Apply", "Medical", new { id = _medicalCheckout.Id })); } TempData["Msg"] = AlertMessageProvider.SuccessMessage("Prescription uploaded successfully."); return(RedirectToAction("Apply", "Medical", new { id = _medicalCheckout.Id })); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "Medical", "UploadPrescription"))); } }
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"))); } }
public ActionResult UploadDocuments(HttpPostedFileBase file, DocumentInfo documentInfo) { try { AuthenticatedUser _authUser; string _fileName = string.Empty; using (AuthRepository Repo = new AuthRepository()) { _authUser = Repo.GetAuthenticatedUserById(CurrentUser.EmployeeInfoId); } if (_authUser.IsCheckListCompleted == true) { return(RedirectToAction("Logout", "Auth", new { area = "" })); } if (documentInfo.DocumentType != "CV" && documentInfo.DocumentType != "CNICFront" && documentInfo.DocumentType != "CNICBack" && documentInfo.DocumentType != "Other") { TempData["Msg"] = AlertMessageProvider.FailureMessage("Invalid document type."); return(RedirectToAction("UploadDocuments", "File")); } if (documentInfo.DocumentType == "Other") { if (string.IsNullOrEmpty(documentInfo.FileName)) { TempData["Msg"] = AlertMessageProvider.FailureMessage("Document name is required."); return(RedirectToAction("UploadDocuments", "File")); } _fileName = documentInfo.FileName; } using (DocumentRepository Repo = new DocumentRepository()) { var _docList = Repo.GetDocumentListByEmployeeId(CurrentUser.EmployeeInfoId); if (documentInfo.DocumentType == "CV") { _fileName = "CV"; int _cvCount = (from x in _docList where x.DocumentType == "CV" select x).ToList().Count(); if (_cvCount > 0) { TempData["Msg"] = AlertMessageProvider.FailureMessage("CV has already uploaded."); return(RedirectToAction("UploadDocuments")); } } else if (documentInfo.DocumentType == "CNICFront" || documentInfo.DocumentType == "CNICBack") { _fileName = documentInfo.DocumentType == "CNICFront" ? "CNIC Front" : "CNIC Back"; int _cnicCount = (from x in _docList where x.DocumentType == "CNICFront" || x.DocumentType == "CNICBack" select x).ToList().Count(); if (_cnicCount == 2) { TempData["Msg"] = AlertMessageProvider.FailureMessage("CNIC has already uploaded."); return(RedirectToAction("UploadDocuments")); } } } if (file != null) { if (file.ContentType.Contains("image") || file.ContentType.Contains("application/pdf")) { if (file.ContentLength < 2 * 1024 * 1024) { if (file.FileName.Contains(".jpeg") || file.FileName.Contains(".jpg") || file.FileName.Contains(".pdf") || file.FileName.Contains("*.pdf")) { documentInfo.FileName = _fileName + Path.GetExtension(file.FileName);; documentInfo.UploadDate = DateTime.Now; documentInfo.EmployeeInfoId = CurrentUser.EmployeeInfoId; string _dirPath = Server.MapPath(Url.Content("~/Content/Employee_documents")); bool _isDirectoryExists = System.IO.Directory.Exists(_dirPath); if (!_isDirectoryExists) { System.IO.Directory.CreateDirectory(Server.MapPath(Url.Content("~/Content/Employee_documents"))); } Guid guid = Guid.NewGuid(); documentInfo.DocumentPath = Url.Content("~/Content/Employee_documents/" + documentInfo.EmployeeInfoId + "-" + guid + "-" + documentInfo.FileName); string _docPath = Server.MapPath(documentInfo.DocumentPath); using (var transaction = new System.Transactions.TransactionScope()) { file.SaveAs(_docPath); var _documentList = new List <DocumentInfo>(); using (DocumentRepository Repo = new DocumentRepository()) { Repo.SaveDocument(documentInfo); _documentList = Repo.GetRequiredDocumentListByEmployeeId(CurrentUser.EmployeeInfoId); } if (_documentList.Count() >= 3) { using (AccountCheckListRepository Repo = new AccountCheckListRepository()) { AccountCheckListInfo accountCheckListInfo = new AccountCheckListInfo(); accountCheckListInfo.IsDocumentsUploaded = true; accountCheckListInfo.AccountId = CurrentUser.AccountId; Repo.UpdateIsDocumentsUploaded(accountCheckListInfo); } } transaction.Complete(); } } else { TempData["Msg"] = AlertMessageProvider.FailureMessage("Please select jpeg, jpg, pdf format only."); return(RedirectToAction("UploadDocuments", "File")); } } else { TempData["Msg"] = AlertMessageProvider.FailureMessage("Please select size upto 2 MB or smaller."); return(RedirectToAction("UploadDocuments", "File")); } } else { TempData["Msg"] = AlertMessageProvider.FailureMessage("Invalid content type, please select image and pdf only."); return(RedirectToAction("UploadDocuments", "File")); } } else { TempData["Msg"] = AlertMessageProvider.FailureMessage("Please select document."); return(RedirectToAction("UploadDocuments", "File")); } TempData["Msg"] = AlertMessageProvider.SuccessMessage("Document uploaded successfully."); return(RedirectToAction("UploadDocuments", "File")); } catch (Exception ex) { TempData["Msg"] = AlertMessageProvider.FailureMessage(ex.ToString()); return(View()); } }
public ActionResult CheckListCompleted() { try { AuthenticatedUser _authUser; AccountCheckListInfo _accountCheckList; var _employeeRegInfo = new EmployeeRegistrationInfo(); using (AuthRepository Repo = new AuthRepository()) { _authUser = Repo.GetAuthenticatedUserById(CurrentUser.EmployeeInfoId); } if (_authUser.IsCheckListCompleted == true) { return(RedirectToAction("Logout", "Auth", new { area = "" })); } using (AccountCheckListRepository Repo = new AccountCheckListRepository()) { _accountCheckList = Repo.GetAccountCheckListByUserId(CurrentUser.AccountId); } if (_accountCheckList.IsPictureUploaded == false) { return(RedirectToAction("UploadPicture", "File")); } using (EmployeeRepository Repo = new EmployeeRepository()) { _employeeRegInfo = Repo.GetRegisterEmployeeInfoById(CurrentUser.EmployeeInfoId); _employeeRegInfo.DateOfJoin = DateTime.Now; Repo.RegisterEmployee(_employeeRegInfo); } using (AccountRepository Repo = new AccountRepository()) { Repo.CheckListCompleted(CurrentUser.AccountId); } using (AuthRepository Repo = new AuthRepository()) { _authUser = Repo.GetAuthenticatedUserById(CurrentUser.EmployeeInfoId); } var _authManager = HttpContext.GetOwinContext().Authentication; var _identity = new ClaimsIdentity(User.Identity); _identity.RemoveClaim(_identity.FindFirst(ClaimTypes.Role)); _identity.AddClaim(new Claim(ClaimTypes.Role, _authUser.Role)); _identity.RemoveClaim(_identity.FindFirst(ClaimTypes.Name)); _identity.AddClaim(new Claim(ClaimTypes.Name, _authUser.FirstName + " " + _authUser.LastName)); //_identity.RemoveClaim(_identity.FindFirst("AccountNo")); //_identity.AddClaim(new Claim("AccountNo", "12345")); _authManager.AuthenticationResponseGrant = new AuthenticationResponseGrant( new ClaimsPrincipal(_identity), new AuthenticationProperties { ExpiresUtc = DateTime.UtcNow.AddMinutes(30), AllowRefresh = true, IsPersistent = false } ); return(RedirectToAction("Dashboard", "Home", new { Area = "Employee" })); } catch (Exception ex) { TempData["Msg"] = AlertMessageProvider.FailureMessage(ex.ToString()); return(View()); } }
public ActionResult UploadPicture(HttpPostedFileBase file) { 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 = "" })); } if (file != null) { if (file.ContentType.Contains("image")) { if (file.ContentLength < 2 * 1024 * 1024) { if (file.FileName.Contains(".jpeg") || file.FileName.Contains(".jpg")) { string _dirPath = Server.MapPath(Url.Content("~/Content/Employee_pictures")); bool _isDirectoryExists = System.IO.Directory.Exists(_dirPath); if (!_isDirectoryExists) { System.IO.Directory.CreateDirectory(Server.MapPath(Url.Content("~/Content/Employee_pictures"))); } string _imgPath = Server.MapPath(Url.Content("~/Content/Employee_pictures/" + CurrentUser.AccountId + ".jpg")); file.SaveAs(_imgPath); using (AccountCheckListRepository Repo = new AccountCheckListRepository()) { var _accountCheckList = new AccountCheckListInfo(); _accountCheckList.IsPictureUploaded = true; _accountCheckList.AccountId = CurrentUser.AccountId; Repo.UpdateIsPictureUploaded(_accountCheckList); } } else { TempData["Msg"] = AlertMessageProvider.FailureMessage("Please select jpeg, jpg format only."); return(RedirectToAction("UploadPicture", "File")); } } else { TempData["Msg"] = AlertMessageProvider.FailureMessage("Please select size upto 2 MB or smaller."); return(RedirectToAction("UploadPicture", "File")); } } else { TempData["Msg"] = AlertMessageProvider.FailureMessage("Invalid content type, please select image only."); return(RedirectToAction("UploadPicture", "File")); } } else { TempData["Msg"] = AlertMessageProvider.FailureMessage("Please select picture."); return(RedirectToAction("UploadPicture", "File")); } TempData["Msg"] = AlertMessageProvider.SuccessMessage("Picture uploaded successfully."); return(RedirectToAction("UploadPicture", "File")); } catch (Exception ex) { TempData["Msg"] = AlertMessageProvider.FailureMessage(ex.ToString()); return(View()); } }
public ActionResult Add(LeaveRequestInfo leaveRequestInfo, string LeaveDate = "") { try { string[] _dateRange = LeaveDate.Split(new string[] { " - " }, StringSplitOptions.None); DateTime _leaveStartDate; DateTime _leaveEndDate; if (!DateTime.TryParse(_dateRange[0], out _leaveStartDate) || !DateTime.TryParse(_dateRange[1], out _leaveEndDate)) { TempData["Msg"] = AlertMessageProvider.FailureMessage("Invalid leave date, please select valid date."); return(RedirectToAction("Add", "Leave", new { id = leaveRequestInfo.EmployeeInfoId })); } if (leaveRequestInfo.LeaveType != "Annual" && leaveRequestInfo.LeaveType != "Casual") { TempData["Msg"] = AlertMessageProvider.FailureMessage("Invalid leave type, please select valid leave type."); return(RedirectToAction("Add", "Leave", new { id = leaveRequestInfo.EmployeeInfoId })); } //if (_leaveStartDate.Date < DateTime.Now.Date) //{ // TempData["Msg"] = AlertMessageProvider.FailureMessage("Start date cannot be later than today."); // return RedirectToAction("Add", "Leave", new { id = leaveRequestInfo.EmployeeInfoId }); //} if (_leaveEndDate.Date < _leaveStartDate.Date) { TempData["Msg"] = AlertMessageProvider.FailureMessage("Start date cannot be later than end date."); return(RedirectToAction("Add", "Leave", new { id = leaveRequestInfo.EmployeeInfoId })); } int _totalSelectedLeaves = LeavesCounter.CountLeavesWithoutWeekend(_leaveStartDate, _leaveEndDate); if (_totalSelectedLeaves == 0) { TempData["Msg"] = AlertMessageProvider.FailureMessage("Leave cannot add to saturday and sunday."); return(RedirectToAction("Add", "Leave", new { id = leaveRequestInfo.EmployeeInfoId })); } leaveRequestInfo.RequestDate = DateTime.Now; leaveRequestInfo.StartDate = _leaveStartDate; leaveRequestInfo.EndDate = _leaveEndDate; leaveRequestInfo.Reason = "N/A"; leaveRequestInfo.Status = "Approved"; leaveRequestInfo.IsCreatedByAdmin = true; leaveRequestInfo.RequestProcessDate = DateTime.Now; leaveRequestInfo.RequestProcessByAccountId = CurrentUser.AccountId; using (LeaveRequestRepository Repo = new LeaveRequestRepository()) { Repo.SaveLeaveRequest(leaveRequestInfo); } TempData["Msg"] = AlertMessageProvider.SuccessMessage("Leave(s) add successfully."); return(RedirectToAction("Manage", "Leave", new { id = leaveRequestInfo.EmployeeInfoId })); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "Leave", "Add"))); } }
public ActionResult Reset(LeaveAllowedInfo leaveAllowedInfo) { try { //if (CurrentUser.Role != "SuperAdmin") //{ // TempData["Msg"] = AlertMessageProvider.FailureMessage("You don't have permission to access this feature."); // return RedirectToAction("Manage", "Leave"); //} if (!ModelState.IsValid) { return(View()); //return RedirectToAction("Reset", "Leave", new { id = leaveAllowedInfo.EmployeeInfoId }); } LeaveAllowedInfo leavesAllowed = null; using (LeaveAllowedRepository Repo = new LeaveAllowedRepository()) { leavesAllowed = Repo.GetLeaveAllowedByEmployeeId(leaveAllowedInfo.EmployeeInfoId); if (leavesAllowed == null) { TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong, please try again later."); return(RedirectToAction("Manage", "Leave")); } if (leaveAllowedInfo.Casual > 5) { TempData["Msg"] = AlertMessageProvider.FailureMessage("Maximum 15 casual leaves allowed."); return(RedirectToAction("Reset", "Leave", new { id = leaveAllowedInfo.EmployeeInfoId })); } if (leaveAllowedInfo.Annual > 15) { TempData["Msg"] = AlertMessageProvider.FailureMessage("Maximum 30 annual leaves allowed."); return(RedirectToAction("Reset", "Leave", new { id = leaveAllowedInfo.EmployeeInfoId })); } leaveAllowedInfo.Id = leavesAllowed.Id; leaveAllowedInfo.ModifiedDate = DateTime.Now; leaveAllowedInfo.ModifiedByAccountId = CurrentUser.AccountId; Repo.UpdateLeaveAllowed(leaveAllowedInfo); } TempData["Msg"] = AlertMessageProvider.SuccessMessage("Leave(s) has been reset successfully."); return(RedirectToAction("Manage", "Leave", new { id = leaveAllowedInfo.EmployeeInfoId })); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "Leave", "Update"))); } }
public ActionResult CreateSalariesHistory(string employeesIdList = "", string SalaryDate = "") { try { 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 (string.IsNullOrEmpty(employeesIdList) || string.IsNullOrEmpty(SalaryDate)) { TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong! please try again later."); return(View()); } DateTime dt; if (!DateTime.TryParse(SalaryDate, out dt)) { TempData["Msg"] = AlertMessageProvider.FailureMessage("Invalid date, please select valid date."); return(View()); } if (dt.ToString("MMMM - yyyy") != previousMonth && dt.ToString("MMMM - yyyy") != currentMonth && dt.ToString("MMMM - yyyy") != nextMonth) { TempData["Msg"] = AlertMessageProvider.FailureMessage("Salary cannot be created other than previous, current and next month."); return(View()); } var _empIdsList = employeesIdList.Split(',').Select(int.Parse).ToList(); var _paySlipInfo = new PaySlipInfo(); bool isSucceed = false; _paySlipInfo.CreatedDate = DateTime.Now; _paySlipInfo.SalaryDate = dt; _paySlipInfo.NumberOfDaysWorked = DateTime.DaysInMonth(dt.Year, dt.Month); _paySlipInfo.CreatedByAccountId = CurrentUser.AccountId; using (var transaction = new System.Transactions.TransactionScope()) { using (SalaryRepository SalaryRepo = new SalaryRepository()) { using (PaySlipRepository PaySlipRepo = new PaySlipRepository()) { foreach (var empId in _empIdsList) { SalaryInfo salary = null; salary = SalaryRepo.GetSalaryByEmployeeId(empId); if (salary != null) { if (PaySlipRepo.IsPayslipCreated((int)salary.EmployeeInfoId, SalaryDate) == true) { TempData["Msg"] = AlertMessageProvider.FailureMessage("Selected employee(s) salary of selected month has already created."); return(RedirectToAction("Manage", "Salary")); } if (salary.TotalSalary > 0) { _paySlipInfo.TotalSalary = salary.TotalSalary; _paySlipInfo.BasicSalary = salary.BasicSalary; _paySlipInfo.HouseRent = salary.HouseRent; _paySlipInfo.MedicalAllowance = salary.MedicalAllowance; _paySlipInfo.IncomTax = salary.IncomTax; _paySlipInfo.LoanDeduction = salary.LoanDeduction; _paySlipInfo.OtherDeductions = salary.OtherDeductions; _paySlipInfo.EmployeeInfoId = (int)salary.EmployeeInfoId; PaySlipRepo.SavePayslip(_paySlipInfo); salary.LoanDeduction = 0; salary.OtherDeductions = 0; SalaryRepo.UpdateSalary(salary); isSucceed = true; } } } } } transaction.Complete(); } if (isSucceed == true) { TempData["Msg"] = AlertMessageProvider.SuccessMessage("Salaries created successfully."); } else { TempData["Msg"] = AlertMessageProvider.FailureMessage("Selected employee(s) salary amount is zero."); } return(RedirectToAction("Manage", "Salary")); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "Salary", "CreateSalariesHistory"))); } }
public ActionResult PersonalInfo(EmployeeRegistrationInfo _employeeRegInfo) { try { AuthenticatedUser _authUser; if (!ModelState.IsValid) { TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong, please try again later."); return(RedirectToAction("PersonalInfo", "Profile")); } 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 = "" })); } _employeeRegInfo.EmployeeInfoId = CurrentUser.EmployeeInfoId; using (var transaction = new System.Transactions.TransactionScope()) { using (FamilyMemberRepository Repo = new FamilyMemberRepository()) { var _familyMembersList = Repo.GetFamilyMembersListByEmployeeId(CurrentUser.EmployeeInfoId); if (_employeeRegInfo.MaritalStatus == "Single" && _familyMembersList.Count() > 0) { foreach (var item in _familyMembersList) { Repo.DeleteFamilyMember(item.Id); } } } using (EmployeeRepository Repo = new EmployeeRepository()) { Repo.RegisterEmployee(_employeeRegInfo); } using (AccountCheckListRepository Repo = new AccountCheckListRepository()) { var _accountCheckList = new AccountCheckListInfo(); _accountCheckList.IsPersonalInfoProvided = true; _accountCheckList.AccountId = CurrentUser.AccountId; Repo.UpdateIsPersonalInfoProvided(_accountCheckList); } transaction.Complete(); } if (_employeeRegInfo.MaritalStatus == "Married") { return(RedirectToAction("Details", "Family")); } else { return(RedirectToAction("UploadDocuments", "File")); } } catch (Exception ex) { TempData["Msg"] = AlertMessageProvider.FailureMessage(ex.ToString()); return(View()); } }
public ActionResult Update(AccountInfo accountInfo) { try { if (ModelState.IsValid) { AccountInfo _accountInfo = null; using (AccountRepository Repo = new AccountRepository()) { _accountInfo = Repo.GetEmployeeAccountById(accountInfo.Id); } if (_accountInfo == null) { TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong, please try again later."); return(RedirectToAction("Manage", "Account")); } if (CurrentUser.AccountId == accountInfo.Id) { TempData["Msg"] = AlertMessageProvider.FailureMessage("You can't update your own account."); return(RedirectToAction("Manage", "Account")); } if (CurrentUser.Role == "Administrator" && _accountInfo.RoleName == "Administrator" || _accountInfo.RoleName == "SuperAdmin") { TempData["Msg"] = AlertMessageProvider.FailureMessage("You don't have permission for this process."); return(RedirectToAction("Manage", "Account")); } if (CurrentUser.Role != "SuperAdmin") { accountInfo.RoleId = _accountInfo.RoleId; } using (var transaction = new System.Transactions.TransactionScope()) { using (EmployeeRepository Repo = new EmployeeRepository()) { var _employee = new Model.EmployeeInfo(); _employee = Repo.GetEmployeeInfoByAccountId(accountInfo.Id); if (accountInfo.IsActive == false) { _employee.DateOfLeave = DateTime.Now; } else { _employee.DateOfLeave = null; } _employee.ModifiedByAccountId = CurrentUser.AccountId; _employee.ModifiedDate = DateTime.Now; Repo.UpdateEmployeeInfo(_employee); } using (AccountRepository Repo = new AccountRepository()) { Repo.UpdateAccount(accountInfo); } transaction.Complete(); } TempData["Msg"] = AlertMessageProvider.SuccessMessage("Account updated successfully."); return(RedirectToAction("Manage", "Account")); } return(View()); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "Account", "Update"))); } }
public ActionResult UploadPhotos(IEnumerable <HttpPostedFileBase> files, AlbumInfo albumInfo) { try { int _albumId; int count = 0; var photoInfo = new PhotoInfo(); AlbumInfo _albumInfo = null; if (!int.TryParse(albumInfo.Id.ToString(), 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 not found."); return(RedirectToAction("Manage", "Gallery")); } photoInfo.UploadOn = DateTime.Now; photoInfo.UploadByAccountId = CurrentUser.AccountId; photoInfo.AlbumId = albumInfo.Id; if (files != null) { foreach (var file in files) { if (file.ContentType.Contains("image")) { if (file.ContentLength < 2 * 1024 * 1024) { if (file.FileName.Contains(".jpeg") || file.FileName.Contains(".jpg")) { photoInfo.Name = file.FileName; string _dirPath = Server.MapPath(Url.Content("~/Content/Album_photos")); bool _isDirectoryExists = System.IO.Directory.Exists(_dirPath); if (!_isDirectoryExists) { System.IO.Directory.CreateDirectory(Server.MapPath(Url.Content("~/Content/Album_photos"))); } photoInfo.Path = Url.Content("~/Content/Album_photos/" + Guid.NewGuid() + "_" + file.FileName); string imgPath = Server.MapPath(photoInfo.Path); file.SaveAs(imgPath); using (PhotoRepository Repo = new PhotoRepository()) { Repo.SavePhoto(photoInfo); } count++; } else { TempData["Msg"] = AlertMessageProvider.FailureMessage("Please select jpeg, jpg format only."); return(RedirectToAction("UploadPhotos", "Gallery", new { id = albumInfo.Id })); } } else { TempData["Msg"] = AlertMessageProvider.FailureMessage("Please select size upto 2 MB or smaller."); return(RedirectToAction("UploadPhotos", "Gallery", new { id = albumInfo.Id })); } } else { TempData["Msg"] = AlertMessageProvider.FailureMessage("Invalid content type, please select image only."); return(RedirectToAction("UploadPhotos", "Gallery", new { id = albumInfo.Id })); } } } else { TempData["Msg"] = AlertMessageProvider.FailureMessage("Please select photo(s)."); return(RedirectToAction("UploadPhotos", "Admin", new { id = albumInfo.Id })); } TempData["Msg"] = AlertMessageProvider.SuccessMessage(count + " Photos uploaded successfully."); return(RedirectToAction("UploadPhotos", "Gallery", new { id = albumInfo.Id })); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "Gallery", "UploadPhotos"))); } }
public ActionResult ResendEmail(int id) { try { AccountInfo _accountInfo = null; using (AccountRepository Repo = new AccountRepository()) { _accountInfo = Repo.GetAccountByid(id); } if (_accountInfo == null) { TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong! email not sent, please try again later."); return(RedirectToAction("Manage", "Account")); } if (_accountInfo.IsCheckListCompleted == true) { TempData["Msg"] = AlertMessageProvider.FailureMessage("This account has been already activated."); return(RedirectToAction("Manage", "Account")); } 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: <b>" + _accountInfo.CompanyEmail + "</b><br/>" + "Password: <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("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")); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "Account", "ResendEmail"))); } }
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: <b>" + accountInfo.CompanyEmail + "</b><br/>" + "Password: <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"))); } }
public ActionResult ApplyLeaves(LeaveRequestInfo leaveRequestInfo) { try { if (leaveRequestInfo.LeaveType != "Casual" && leaveRequestInfo.LeaveType != "Annual" || string.IsNullOrEmpty(leaveRequestInfo.LeaveDate)) { TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong, please try again later."); return(RedirectToAction("Status", "Leave")); } string[] _dateRange = leaveRequestInfo.LeaveDate.Split(new string[] { " - " }, StringSplitOptions.None); DateTime _leaveStartDate; DateTime _leaveEndDate; var _leaveAllowed = new LeaveAllowedInfo(); if (!DateTime.TryParse(_dateRange[0], out _leaveStartDate) || !DateTime.TryParse(_dateRange[1], out _leaveEndDate)) { TempData["Msg"] = AlertMessageProvider.FailureMessage("Invalid leave date, please select valid date."); return(RedirectToAction("Details", "Leave")); } _leaveStartDate = DateTime.Parse(_dateRange[0]); _leaveEndDate = DateTime.Parse(_dateRange[1]); int _totalSelectedLeaves = LeavesCounter.CountLeavesWithoutWeekend(_leaveStartDate, _leaveEndDate); //(_leaveStartDate - _leaveEndDate).Days + 1; if (_leaveStartDate.Date < DateTime.Now.Date) { TempData["Msg"] = AlertMessageProvider.FailureMessage("Start date cannot be later than today."); return(RedirectToAction("Details", "Leave")); } int _monthsDiff = ((_leaveStartDate.Year - DateTime.Now.Year) * 12) + _leaveStartDate.Month - DateTime.Now.Month; if (_monthsDiff > 1) { TempData["Msg"] = AlertMessageProvider.FailureMessage("You cannot apply for leaves earlier than 1 month."); return(RedirectToAction("Details", "Leave")); } if (_leaveEndDate.Date < _leaveStartDate.Date) { TempData["Msg"] = AlertMessageProvider.FailureMessage("Start date cannot be later than end date."); return(RedirectToAction("Details", "Leave")); } if (_totalSelectedLeaves == 0) { TempData["Msg"] = AlertMessageProvider.FailureMessage("You can't apply for saturday and sunday."); return(RedirectToAction("Details", "Leave")); } using (LeaveAllowedRepository Repo = new LeaveAllowedRepository()) { _leaveAllowed = Repo.GetLeaveAllowedByEmployeeId(CurrentUser.EmployeeInfoId); } using (LeaveRequestRepository Repo = new LeaveRequestRepository()) { LeaveRequestInfo _leaveRequest = null; _leaveRequest = Repo.GetLeaveRequestLastRecordByEmployeeId(CurrentUser.EmployeeInfoId); if (_leaveRequest != null) { if (_leaveRequest.EndDate.Date == _leaveStartDate.Date) { TempData["Msg"] = AlertMessageProvider.FailureMessage("You have already a leave today."); return(RedirectToAction("Details", "Leave")); } if (_leaveRequest.Status == "Pending" || _leaveRequest.Status == "Approved" && _leaveRequest.EndDate.Date > DateTime.Now.Date) { TempData["Msg"] = AlertMessageProvider.FailureMessage("You have already applied for leaves."); return(RedirectToAction("Details", "Leave")); } } if (leaveRequestInfo.LeaveType == "Casual") { var _leavesList = Repo.GetCasualLeaveRequestListByEmployeeId(CurrentUser.EmployeeInfoId); int _totalAvailedCasualLeaves = LeavesCounter.GetRemainingLeaves(_leavesList, _leaveAllowed.Casual); if (_totalSelectedLeaves > _totalAvailedCasualLeaves) { TempData["Msg"] = AlertMessageProvider.FailureMessage("Please select upto remaining casual leaves."); return(RedirectToAction("Details", "Leave")); } } else if (leaveRequestInfo.LeaveType == "Annual") { var _leavesList = Repo.GetAnnualLeaveRequestListByEmployeeId(CurrentUser.EmployeeInfoId); int _totalAvailedAnnualLeaves = LeavesCounter.GetRemainingLeaves(_leavesList, _leaveAllowed.Annual); if (_totalSelectedLeaves > _totalAvailedAnnualLeaves) { TempData["Msg"] = AlertMessageProvider.FailureMessage("Please select upto remaining annual leaves."); return(RedirectToAction("Details", "Leave")); } } } leaveRequestInfo.RequestDate = DateTime.Now; leaveRequestInfo.StartDate = _leaveStartDate; leaveRequestInfo.EndDate = _leaveEndDate; leaveRequestInfo.Status = "Pending"; leaveRequestInfo.Remark = ""; leaveRequestInfo.IsCreatedByAdmin = false; leaveRequestInfo.EmployeeInfoId = CurrentUser.EmployeeInfoId; string Subject = "Leave(s) Request"; string Body = "<b>Employee: </b>" + CurrentUser.Name + ".<br/>" + "<b>Total Leaves: </b>" + _totalSelectedLeaves + ".<br/>" + "<b>Leave Date: </b>" + leaveRequestInfo.LeaveDate + ".<br/><br/>" + "<b>Leave Reason: </b><br/>" + leaveRequestInfo.Reason + "<br/><br/>" + "Thanks.<br/>"; var status = EmailSender.Send(Subject, Body); if (status) { using (LeaveRequestRepository Repo = new LeaveRequestRepository()) { Repo.SaveLeaveRequest(leaveRequestInfo); } TempData["Msg"] = AlertMessageProvider.SuccessMessage("You have applied for leaves successfully, please wait for approval."); } else { TempData["Msg"] = AlertMessageProvider.FailureMessage("Email sending failed! please try again later."); } return(RedirectToAction("Details", "Leave")); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "Leave", "ApplyLeaves"))); } }
public ActionResult Update(HttpPostedFileBase file, EmployeeInfo employeeInfo) { try { if (!ModelState.IsValid) { return(View()); } int empId; EmployeeInfo _employee = null; if (!int.TryParse(employeeInfo.Id.ToString(), out empId)) { return(RedirectToAction("Manage", "Profile")); } using (EmployeeRepository Repo = new EmployeeRepository()) { _employee = Repo.GetEmployeeInfoById(empId); } if (_employee == null) { return(RedirectToAction("Manage", "Profile")); } if (_employee.RoleName == "SuperAdmin") { return(RedirectToAction("Manage", "Profile")); } bool isImgSelected = false; if (file != null) { if (file.ContentType.Contains("image")) { if (file.ContentLength < 2 * 1024 * 1024) { if (file.FileName.Contains(".jpg")) { isImgSelected = true; } else { TempData["Msg"] = AlertMessageProvider.FailureMessage("Please select 'jpg' format only."); return(View()); } } else { TempData["Msg"] = AlertMessageProvider.FailureMessage("Please select size upto 2 MB or smaller."); return(View()); } } else { TempData["Msg"] = AlertMessageProvider.FailureMessage("Invalid content type, please select image only."); return(View()); } } employeeInfo.ModifiedDate = DateTime.Now; employeeInfo.ModifiedByAccountId = CurrentUser.AccountId; using (EmployeeRepository Repo = new EmployeeRepository()) { Repo.UpdateEmployeeInfo(employeeInfo); TempData["Msg"] = AlertMessageProvider.SuccessMessage("Employee info updated successfully."); } if (isImgSelected == true) { string imgPath = Server.MapPath(Url.Content("~/Content/Employee_pictures/" + employeeInfo.AccountId + ".jpg")); file.SaveAs(imgPath); } return(RedirectToAction("Manage", "Profile", new { id = employeeInfo.Id })); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "Profile", "Update"))); } }
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"))); } }
public ActionResult UploadDocuments(HttpPostedFileBase file, EmployeeInfo employeeInfo, string EmployeeId = "") { try { int _id; var _document = new DocumentInfo(); EmployeeInfo _employee = null; if (!int.TryParse(EmployeeId, out _id)) { TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong, please try again later."); return(RedirectToAction("Manage", "Profile")); } using (EmployeeRepository Repo = new EmployeeRepository()) { _employee = Repo.GetEmployeeInfoById(_id); } if (_employee == null) { TempData["Msg"] = AlertMessageProvider.FailureMessage("Employee does not exist."); return(RedirectToAction("Manage", "Profile")); } if (string.IsNullOrEmpty(employeeInfo.DocumentName)) { TempData["Msg"] = AlertMessageProvider.FailureMessage("Document name is required."); return(RedirectToAction("Manage", "Profile")); } if (file != null) { if (file.ContentType.Contains("image") || file.ContentType.Contains("application/pdf")) { if (file.ContentLength < 2 * 1024 * 1024) { if (file.FileName.Contains(".jpeg") || file.FileName.Contains(".jpg") || file.FileName.Contains(".pdf") || file.FileName.Contains("*.pdf")) { _document.FileName = employeeInfo.DocumentName + Path.GetExtension(file.FileName);; _document.UploadDate = DateTime.Now; _document.DocumentType = "Other"; _document.EmployeeInfoId = _id; string _dirPath = Server.MapPath(Url.Content("~/Content/Employee_documents")); bool _isDirectoryExists = System.IO.Directory.Exists(_dirPath); if (!_isDirectoryExists) { System.IO.Directory.CreateDirectory(Server.MapPath(Url.Content("~/Content/Employee_documents"))); } Guid guid = Guid.NewGuid(); _document.DocumentPath = Url.Content("~/Content/Employee_documents/" + _document.EmployeeInfoId + "-" + guid + "-" + _document.FileName); string _docPath = Server.MapPath(_document.DocumentPath); file.SaveAs(_docPath); using (DocumentRepository Repo = new DocumentRepository()) { Repo.SaveDocument(_document); } } else { TempData["Msg"] = AlertMessageProvider.FailureMessage("Please select jpeg, jpg, pdf format only."); return(RedirectToAction("Manage", "Profile", new { id = _id })); } } else { TempData["Msg"] = AlertMessageProvider.FailureMessage("Please select size upto 2 MB or smaller."); return(RedirectToAction("Manage", "Profile", new { id = _id })); } } else { TempData["Msg"] = AlertMessageProvider.FailureMessage("Invalid content type, please select image and pdf only."); return(RedirectToAction("Manage", "Profile", new { id = _id })); } } else { TempData["Msg"] = AlertMessageProvider.FailureMessage("Please select document."); return(RedirectToAction("Manage", "Profile", new { id = _id })); } TempData["Msg"] = AlertMessageProvider.SuccessMessage("Document uploaded successfully."); return(RedirectToAction("Manage", "Profile", new { id = _id })); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "Profile", "UploadDocuments"))); } }
// GET: EmployeeReg/File/UploadDocuments public ActionResult UploadDocuments() { 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 (DocumentRepository Repo = new DocumentRepository()) { _registration.documentInfoList = Repo.GetDocumentListByEmployeeId(CurrentUser.EmployeeInfoId); } using (AccountCheckListRepository Repo = new AccountCheckListRepository()) { _registration.accountCheckListInfo = Repo.GetAccountCheckListByUserId(CurrentUser.AccountId); if (_registration.accountCheckListInfo.IsPersonalInfoProvided == false) { return(RedirectToAction("PersonalInfo", "Profile")); } 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")); } } } int count = (from x in _registration.documentInfoList where x.DocumentType == "CNICFront" || x.DocumentType == "CNICBack" || x.DocumentType == "CV" select x).ToList().Count(); if (count < 3) { var _accountCheckList = new AccountCheckListInfo(); _accountCheckList.IsDocumentsUploaded = false; _accountCheckList.AccountId = CurrentUser.AccountId; Repo.UpdateIsDocumentsUploaded(_accountCheckList); _registration.accountCheckListInfo = Repo.GetAccountCheckListByUserId(CurrentUser.AccountId); } } return(View(_registration)); } catch (Exception ex) { TempData["Msg"] = AlertMessageProvider.FailureMessage(ex.ToString()); return(View()); } }