public static async Task <EmployeeInfo> FromStoreAsync(string tenant, int employeeId) { var details = await Employees.GetEmployeeViewAsync(tenant, employeeId).ConfigureAwait(false); var experiences = await EmployeeExperiences.GetEmployeeExperiencesAsync(tenant, employeeId).ConfigureAwait(false); var identifications = await EmployeeIdentificationDetails.GetEmployeeIdentificationsAsync(tenant, employeeId).ConfigureAwait(false); var qualifications = await EmployeeQualifications.GetQualificationsAsync(tenant, employeeId).ConfigureAwait(false); var socialNetworks = await EmployeeSocialNetworks.GetSocialNetworksAsync(tenant, employeeId).ConfigureAwait(false); return(new EmployeeInfo { EmployeeId = employeeId, Details = details, Experiences = experiences, IdentificationDetails = identifications, Qualifications = qualifications, SocialNetworks = socialNetworks }); }
public bool CanSendMail(int EmployeeID) { List <EmployeeQualifications> finalObj = new List <EmployeeQualifications>(); var AllDetails = (from qual in dbContext.tbl_PM_EmployeeQualificationMatrix where qual.EmployeeID == EmployeeID orderby qual.PassoutYear descending select qual).ToList(); if (AllDetails != null) { foreach (var obj in AllDetails) { var histroy = (from his in dbContext.tbl_PM_EmployeeQualificationMatrix_History where his.EmployeeQualificationID == obj.EmployeeQualificationID orderby his.EmployeeQualificationHistoryId descending select his).FirstOrDefault(); if (obj != null) { if (histroy != null) { if (histroy.Status != 2 && histroy.Status != 3) { EmployeeQualifications current = new EmployeeQualifications(); current.CanSendMail = Convert.ToString(histroy.SendMail); finalObj.Add(current); } } } } } if (finalObj.Any(x => x.CanSendMail == "True")) { return(true); } return(false); }
public bool SaveEmployeeQualification(EmployeeQualifications model, bool IsLoggedInEmployee, int?SelectedQualificationID, int?SelectedDegreeID, int?SelectedYearID, int?SelectedTypeID, int?EmployeeId) { bool isAdded = false; tbl_PM_EmployeeQualificationMatrix emp = dbContext.tbl_PM_EmployeeQualificationMatrix.Where(ed => ed.EmployeeQualificationID == model.EmployeeQualificationID).FirstOrDefault(); if (emp == null || emp.EmployeeQualificationID <= 0) { tbl_PM_EmployeeQualificationMatrix employeeQualifications = new tbl_PM_EmployeeQualificationMatrix(); employeeQualifications.EmployeeQualificationID = model.EmployeeQualificationID; employeeQualifications.EmployeeID = EmployeeId; employeeQualifications.QualificationID = SelectedQualificationID; employeeQualifications.QualificationGroupID = SelectedDegreeID; if (model.Specialization != null && model.Specialization != "") { employeeQualifications.Specialization = model.Specialization.Trim(); } else { employeeQualifications.Specialization = model.Specialization; } if (model.Institute != null && model.Institute != "") { employeeQualifications.Institute = model.Institute.Trim(); } else { employeeQualifications.Institute = model.Institute; } if (model.University != null && model.University != "") { employeeQualifications.University = model.University.Trim(); } else { employeeQualifications.University = model.University; } //Courses = model.NewEmployeeQualification.Course; employeeQualifications.PassoutYear = SelectedYearID; employeeQualifications.QualificationTypeID = SelectedTypeID; if (model.Percentage != null && model.Percentage != "") { employeeQualifications.Class = model.Percentage.Trim(); } else { employeeQualifications.Class = model.Percentage; } dbContext.tbl_PM_EmployeeQualificationMatrix.AddObject(employeeQualifications); dbContext.SaveChanges(); if (IsLoggedInEmployee == true) { tbl_PM_EmployeeQualificationMatrix_History Qualifications = new tbl_PM_EmployeeQualificationMatrix_History(); Qualifications.EmployeeQualificationID = employeeQualifications.EmployeeQualificationID; Qualifications.EmployeeID = EmployeeId; Qualifications.QualificationID = SelectedQualificationID; Qualifications.QualificationGroupID = SelectedDegreeID; if (model.Specialization != null && model.Specialization != "") { Qualifications.Specialization = model.Specialization.Trim(); } else { Qualifications.Specialization = model.Specialization; } if (model.Institute != null && model.Institute != "") { Qualifications.Institute = model.Institute.Trim(); } else { Qualifications.Institute = model.Institute; } if (model.University != null && model.University != "") { Qualifications.University = model.University.Trim(); } else { Qualifications.University = model.University; } //Courses = model.NewEmployeeQualification.Course; Qualifications.PassoutYear = SelectedYearID; Qualifications.QualificationTypeID = SelectedTypeID; if (model.Percentage != null && model.Percentage != "") { Qualifications.Class = model.Percentage.Trim(); } else { Qualifications.Class = model.Percentage; } Qualifications.ActionType = "Add"; Qualifications.CreatedBy = EmployeeId.ToString(); Qualifications.CreatedDate = DateTime.Now; Qualifications.SendMail = true; dbContext.tbl_PM_EmployeeQualificationMatrix_History.AddObject(Qualifications); dbContext.SaveChanges(); } } //for edit else { if ( emp.EmployeeID != EmployeeId || //emp.Courses != model.NewEmployeeQualification.Course || emp.Institute != model.Institute || emp.PassoutYear != SelectedYearID || //column percentage from db was not allowing to edit nvarchar values properly so using class column to store percentage as well grades emp.Class != model.Percentage || emp.Specialization != model.Specialization || emp.QualificationTypeID != SelectedTypeID || emp.QualificationID != SelectedQualificationID || emp.QualificationGroupID != SelectedDegreeID || emp.University != model.University ) { if (IsLoggedInEmployee == true) { tbl_PM_EmployeeQualificationMatrix_History Qualifications = new tbl_PM_EmployeeQualificationMatrix_History(); Qualifications.EmployeeQualificationID = model.EmployeeQualificationID; Qualifications.EmployeeID = emp.EmployeeID; Qualifications.QualificationID = emp.QualificationID; Qualifications.QualificationGroupID = emp.QualificationGroupID; if (emp.Specialization != null && emp.Specialization != "") { Qualifications.Specialization = emp.Specialization.Trim(); } else { Qualifications.Specialization = emp.Specialization; } if (emp.Institute != null && emp.Institute != "") { Qualifications.Institute = emp.Institute.Trim(); } else { Qualifications.Institute = emp.Institute; } if (emp.University != null && emp.University != "") { Qualifications.University = emp.University.Trim(); } else { Qualifications.University = emp.University; } Qualifications.Courses = emp.Courses; Qualifications.PassoutYear = emp.PassoutYear; Qualifications.QualificationTypeID = emp.QualificationTypeID; if (emp.Class != null && emp.Class != "") { Qualifications.Class = emp.Class.Trim(); } else { Qualifications.Class = emp.Class; } Qualifications.ActionType = "Edit"; Qualifications.ModifiedBy = EmployeeId.ToString(); Qualifications.ModifiedDate = DateTime.Now; Qualifications.SendMail = true; dbContext.tbl_PM_EmployeeQualificationMatrix_History.AddObject(Qualifications); dbContext.SaveChanges(); } emp.EmployeeID = EmployeeId; //emp.Courses = model.NewEmployeeQualification.Course; if (model.Institute != null && model.Institute != "") { emp.Institute = model.Institute.Trim(); } else { emp.Institute = model.Institute; } emp.PassoutYear = SelectedYearID; //column percentage from db was not allowing to edit nvarchar values properly so using class column to store percentage as well grades if (model.Percentage != null && model.Percentage != "") { emp.Class = model.Percentage.Trim(); } else { emp.Class = model.Percentage; } if (model.Specialization != null && model.Specialization != "") { emp.Specialization = model.Specialization.Trim(); } else { emp.Specialization = model.Specialization; } emp.QualificationTypeID = SelectedTypeID; emp.QualificationID = SelectedQualificationID; emp.QualificationGroupID = SelectedDegreeID; if (model.University != null && model.University != "") { emp.University = model.University.Trim(); } else { emp.University = model.University; } } } dbContext.SaveChanges(); isAdded = true; return(isAdded); }
public List <EmployeeQualifications> GetEmployeeQualificationsOtherDetails(int page, int rows, int EmployeeID, out int totalCount) { List <EmployeeQualifications> finalObj = new List <EmployeeQualifications>(); try { var AllDetails = (from qual in dbContext.tbl_PM_EmployeeQualificationMatrix where qual.EmployeeID == EmployeeID orderby qual.PassoutYear descending select qual).ToList(); if (AllDetails != null) { foreach (var obj in AllDetails) { var histroy = (from his in dbContext.tbl_PM_EmployeeQualificationMatrix_History where his.EmployeeQualificationID == obj.EmployeeQualificationID orderby his.EmployeeQualificationHistoryId descending select his).FirstOrDefault(); if (obj != null) { EmployeeQualifications current = new EmployeeQualifications(); current.EmployeeQualificationID = obj.EmployeeQualificationID; current.EmployeeID = obj.EmployeeID; current.Specialization = obj.Specialization; current.Institute = obj.Institute; current.University = obj.University; //current.Course = obj.Courses; current.Year = obj.PassoutYear; current.Percentage = obj.Class; if (obj.QualificationGroupID != null) { current.Degree = obj.HRMS_tbl_PM_QualificationGroupMaster.QualificationGroupName; } current.DegreeID = obj.QualificationGroupID; if (obj.QualificationID != null) { current.Qualification = obj.HRMS_tbl_PM_Qualifications.QualificationName; } current.QualificationID = obj.QualificationID; if (obj.QualificationTypeID != null) { current.Type = obj.tbl_PM_QualificationType.QualificationTypeName; } current.TypeID = obj.QualificationTypeID; if (histroy != null) { current.ApprovalOrRejectionStatus = GetStatusMessage(histroy.ActionType, histroy.Status, false); if (histroy.Status == 2 || histroy.Status == 3) { if ((DateTime.Now - Convert.ToDateTime(histroy.ModifiedDate)).TotalHours < 72) { //show message current.ApprovalStatusFlag = "1"; } else { //hide message current.ApprovalStatusFlag = "0"; } } current.ActionType = histroy.ActionType; } finalObj.Add(current); } } } totalCount = dbContext.tbl_PM_EmployeeQualificationMatrix.Where(x => x.EmployeeID == EmployeeID).Count(); return(finalObj.Skip((page - 1) * rows).Take(rows).ToList()); } catch (Exception) { throw; } }
public ActionResult Edit([Bind(Include = "ID,ContactID,EmployeeID,QualificationsID,Name,Password,Position,StaffType,EmailAddress,BranchName,Qualifications")] Employee employee, EmployeeContacts employeeContact, EmergencyContact emergencyContact, EmployeeQualifications qualify, string[] Qualifications, string id) { if (ModelState.IsValid) { for (int i = 0; i < Qualifications.Length; i++) { string results = Qualifications[i]; qualify.Qualifications = results; qualify.EmployeeID = id; db.EmployeeQualifications.Add(qualify); db.SaveChanges(); } employeeContact.EmployeeID = id; emergencyContact.EmployeeID = id; db.Entry(employee).State = EntityState.Modified; db.Entry(employeeContact).State = EntityState.Modified; db.Entry(emergencyContact).State = EntityState.Modified; db.Entry(qualify).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { //Safely ignore this exception } catch (Exception e) { //Something else has occurred } return(RedirectToAction("Index")); } //return View(employee); return(View(employee)); }
public ActionResult Create([Bind(Include = "ID,ContactID,EmployeeID,QualificationsID,Name,Password,Position,StaffType,EmailAddress,BranchName,ContactInformation,EmergencyContact")] Employee employee, EmployeeContacts employeeContact, EmergencyContact emergencyContact, EmployeeQualifications qualify, Schedules schedule, string[] Qualifications, string ID, string Name) { if (ModelState.IsValid) { for (int i = 0; i < Qualifications.Length; i++) { string results = Qualifications[i]; qualify.Qualifications = results; qualify.EmployeeID = ID; db.EmployeeQualifications.Add(qualify); db.SaveChanges(); } employeeContact.EmployeeID = ID; emergencyContact.EmployeeID = ID; //schedule.EmpId = Convert.ToInt32(ID); db.SaveChanges(); db.Employees.Add(employee); db.EmployeeContacts.Add(employeeContact); db.EmergencyContact.Add(emergencyContact); db.SaveChanges(); return(RedirectToAction("Index")); } return(View()); }