public bool SaveApplicantData(TMSApplicantViewModel datamodel, List <TMSApplicantCommentViewModel> listComment, List <TMSApplicantDocumentViewModel> listDocument, int UserId) { var data = _db.TMS_Applicant.Where(x => x.Email == datamodel.Email && x.Id != datamodel.Id && x.VacancyID != datamodel.VacancyID && x.Archived == false).ToList(); List <TMS_Applicant_Documents> tmsDoc = new List <TMS_Applicant_Documents> (); if (data.Count < 0) { return(false); } else { DateTime StDate = new DateTime(); if (datamodel.DateOfBirth != "" && datamodel.DateOfBirth != null) { var startDateToString = DateTime.ParseExact(datamodel.DateOfBirth, inputFormat, CultureInfo.InvariantCulture); StDate = Convert.ToDateTime(startDateToString.ToString(outputFormat)); } if (datamodel.Id == 0) { TMS_Applicant save = new TMS_Applicant(); save.VacancyID = datamodel.VacancyID; save.FirstName = datamodel.FirstName; save.LastName = datamodel.LastName; save.Email = datamodel.Email; save.GenderID = datamodel.GenderID; save.DateOfBirth = StDate; save.PostalCode = datamodel.PostalCode; save.Address = datamodel.Address; save.OtherContactDetails = datamodel.OtherContactDetails; save.StatusID = datamodel.StatusID; save.CoverLetterPath = datamodel.CoverLetterPath; save.CoverLetterPathOriginal = datamodel.CoverLetterPathOriginal; save.DownloadApplicationFormLink = datamodel.DownloadApplicationFormLink; save.UploadApplicationFormPathOriginal = datamodel.UploadApplicationFormPathOriginal; save.UploadApplicationFormPath = datamodel.UploadApplicationFormPath; save.ResumePathOriginal = datamodel.ResumePathOriginal; save.ResumePath = datamodel.ResumePath; save.Question1Answer = datamodel.Question1Answer; save.Question2Answer = datamodel.Question2Answer; save.Question3Answer = datamodel.Question3Answer; save.Question4Answer = datamodel.Question4Answer; save.Question5Answer = datamodel.Question5Answer; save.SourceID = datamodel.SourceID; save.CompatencyJSV = datamodel.CompatencyJSV; save.CommentJSV = datamodel.CommentJSV; save.DocumentJSV = datamodel.DocumentJSV; save.GeneralSkillsJSV = datamodel.GeneralSkillsJSV; save.TechnicalSkillsJSV = datamodel.TechnicalSkillsJSV; save.Cost = datamodel.Cost; save.CreatedDate = DateTime.Now; save.Archived = false; save.UserIDCreatedBy = UserId; save.UserIDLastModifiedBy = UserId; save.LastModified = DateTime.Now; save.IsReadHiringLead = false; if (datamodel.RejectReasonId != 0 && datamodel.RejectReasonId != null) { save.RejectReasonId = datamodel.RejectReasonId; save.RejectReasonComment = datamodel.RejectReasonComment; } _db.TMS_Applicant.Add(save); _db.SaveChanges(); foreach (var item in _db.TMS_Applicant_Comments.Where(x => x.ApplicantID == save.Id).ToList()) { _db.TMS_Applicant_Comments.Remove(item); _db.SaveChanges(); } foreach (var item in listComment) { TMS_Applicant_Comments mm = new TMS_Applicant_Comments(); mm.ApplicantID = save.Id; mm.Description = item.comment; mm.CreatedName = item.commentBy; mm.CreatedDateTime = item.commentTime; mm.Archived = false; mm.UserIDCreatedBy = UserId; mm.CreatedDate = DateTime.Now; mm.UserIDLastModifiedBy = UserId; mm.LastModified = DateTime.Now; _db.TMS_Applicant_Comments.Add(mm); _db.SaveChanges(); } foreach (var item in _db.TMS_Applicant_Documents.Where(x => x.ApplicantID == save.Id).ToList()) { _db.TMS_Applicant_Documents.Remove(item); _db.SaveChanges(); } foreach (var item in listDocument) { TMS_Applicant_Documents Document = new TMS_Applicant_Documents(); Document.ApplicantID = save.Id; Document.NewName = item.newName; Document.OriginalName = item.originalName; Document.Description = item.description; Document.Archived = false; Document.UserIDCreatedBy = UserId; Document.CreatedDate = DateTime.Now; Document.UserIDLastModifiedBy = UserId; Document.LastModified = DateTime.Now; _db.TMS_Applicant_Documents.Add(Document); _db.SaveChanges(); } return(true); } else { TMS_Applicant update = new TMS_Applicant(); update = _db.TMS_Applicant.Where(x => x.Id == datamodel.Id).FirstOrDefault(); update.VacancyID = datamodel.VacancyID; update.FirstName = datamodel.FirstName; update.LastName = datamodel.LastName; update.Email = datamodel.Email; update.GenderID = datamodel.GenderID; update.DateOfBirth = StDate; update.PostalCode = datamodel.PostalCode; update.Address = datamodel.Address; update.OtherContactDetails = datamodel.OtherContactDetails; update.StatusID = datamodel.StatusID; update.CoverLetterPath = datamodel.CoverLetterPath; update.DownloadApplicationFormLink = datamodel.DownloadApplicationFormLink; update.UploadApplicationFormPath = datamodel.UploadApplicationFormPath; update.ResumePath = datamodel.ResumePath; update.Question1Answer = datamodel.Question1Answer; update.Question2Answer = datamodel.Question2Answer; update.Question3Answer = datamodel.Question3Answer; update.Question4Answer = datamodel.Question4Answer; update.Question5Answer = datamodel.Question5Answer; update.SourceID = datamodel.SourceID; update.CompatencyJSV = datamodel.CompatencyJSV; update.CommentJSV = datamodel.CommentJSV; update.DocumentJSV = datamodel.DocumentJSV; update.GeneralSkillsJSV = datamodel.GeneralSkillsJSV; update.TechnicalSkillsJSV = datamodel.TechnicalSkillsJSV; update.Cost = datamodel.Cost; update.UserIDLastModifiedBy = UserId; update.IsReadHiringLead = false; update.LastModified = DateTime.Now; _db.SaveChanges(); foreach (var item in listComment) { var tmsCommnts = _db.TMS_Applicant_Comments.Where(x => x.ApplicantID == update.Id).ToList(); TMS_Applicant_Comments mm = new TMS_Applicant_Comments(); mm.ApplicantID = update.Id; mm.Description = item.comment; mm.CreatedName = item.commentBy; mm.CreatedDateTime = item.commentTime; mm.Archived = false; mm.UserIDCreatedBy = UserId; mm.CreatedDate = DateTime.Now; mm.UserIDLastModifiedBy = UserId; mm.LastModified = DateTime.Now; _db.TMS_Applicant_Comments.Add(mm); _db.SaveChanges(); } if (listDocument.Count == 0) { var ddata = _db.TMS_Applicant_Documents.Where(x => x.ApplicantID == update.Id).ToList(); if (ddata != null) { foreach (var item in ddata) { TMS_Applicant_Documents Document = new TMS_Applicant_Documents(); Document.ApplicantID = update.Id; Document.Archived = true; Document.UserIDCreatedBy = UserId; Document.CreatedDate = DateTime.Now; Document.UserIDLastModifiedBy = UserId; Document.LastModified = DateTime.Now; tmsDoc.Add(Document); } _db.SaveChanges(); } } else { foreach (var item in listDocument) { var ddata = _db.TMS_Applicant_Documents.Where(x => x.ApplicantID == update.Id).ToList(); //foreach (var docitem in _db.TMS_Applicant_Documents.Where(x => x.ApplicantID == update.Id).ToList()) //{ // _db.TMS_Applicant_Documents.Remove(docitem); // _db.SaveChanges(); //} //foreach (var dd in ddata) //{ // TMS_Applicant_Documents Document = new TMS_Applicant_Documents(); // if (item.Id==dd.Id) // { // Document.ApplicantID = update.Id; // Document.NewName = item.newName; // Document.OriginalName = item.originalName; // Document.Description = item.description; // Document.Archived = false; // Document.UserIDCreatedBy = UserId; // Document.CreatedDate = DateTime.Now; // Document.UserIDLastModifiedBy = UserId; // Document.LastModified = DateTime.Now; // tmsDoc.Add(Document); // //_db.TMS_Applicant_Documents.Add(Document); // } // else // { // Document.ApplicantID = update.Id; // Document.NewName = item.newName; // Document.OriginalName = item.originalName; // Document.Description = item.description; // Document.Archived = true; // Document.UserIDCreatedBy = UserId; // Document.CreatedDate = DateTime.Now; // Document.UserIDLastModifiedBy = UserId; // Document.LastModified = DateTime.Now; // tmsDoc.Add(Document); // } // _db.SaveChanges(); //} } } return(true); } } }
public PartialViewResult GetNotificationDetailsByKey(int EmployeeID, string Header, int?DetailsId) { NotificationMethod _NotificationMethod = new NotificationMethod(); NotificationDetail _NotificationDetail = new NotificationDetail(); if (Header == "TimeSheet Request") { var data = _NotificationMethod.GetTimeSheetNotificationByKey(EmployeeID, DetailsId).FirstOrDefault(); if (data != null) { _NotificationDetail.EmployeeId = data.EmployeeId; _NotificationDetail.HeaderType = data.HeaderType; _NotificationDetail.Hours = data.Hours; _NotificationDetail.ProjectName = data.ProjectName; _NotificationDetail.Day = data.Day; _NotificationDetail.Date = data.Date; _NotificationDetail.CustomerName = data.CustomerName; _NotificationDetail.CostCode = data.CostCode; _NotificationDetail.AssetName = data.AssetName; var reportTodata = _db.EmployeeRelations.Where(x => x.IsActive == true && x.UserID == EmployeeID).FirstOrDefault(); var aspnetUserDetails = _db.AspNetUsers.Where(x => x.Archived == false && x.Id == EmployeeID).FirstOrDefault(); Employee_TimeSheet_Detail TimeSheetDetails = new Employee_TimeSheet_Detail(); TimeSheetDetails = _db.Employee_TimeSheet_Detail.Find(DetailsId); if (TimeSheetDetails != null && TimeSheetDetails.ApprovalStatus == "Pending") { _NotificationDetail.AppStatus = TimeSheetDetails.ApprovalStatus; } if (aspnetUserDetails != null && TimeSheetDetails != null) { if (aspnetUserDetails.HRResponsible == SessionProxy.UserId && aspnetUserDetails.HRResponsible != null) { TimeSheetDetails.IsReadHR = true; } if (aspnetUserDetails.AdditionalReportsto == SessionProxy.UserId) { TimeSheetDetails.IsReadAddRep = true; } if (TimeSheetDetails != null && reportTodata.Reportsto == SessionProxy.UserId) { TimeSheetDetails.IsRead = true; } _db.Entry(TimeSheetDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } } } if (Header == "Training Request Worker") { var data = _NotificationMethod.getEmployeeTrainingById(Convert.ToInt32(DetailsId)).FirstOrDefault(); if (data != null) { _NotificationDetail.EmployeeId = data.EmployeeId; _NotificationDetail.HeaderType = "Training Request Worker"; _NotificationDetail.StartDate = Convert.ToString(data.StartDate); _NotificationDetail.EndDate = Convert.ToString(data.EndDate); _NotificationDetail.TrainingDescription = data.Description; EmployeeTraining trainingDetails = new EmployeeTraining(); trainingDetails = _db.EmployeeTrainings.Find(DetailsId); trainingDetails.IsReadWorker = true; _db.Entry(trainingDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } } else if (Header == "Skill Added") { var data = _NotificationMethod.getEmployeeSkillById(Convert.ToInt32(DetailsId)).FirstOrDefault(); if (data != null) { _NotificationDetail.EmployeeId = data.EmployeeId; _NotificationDetail.HeaderType = "Skill Added"; if (data.GeneralSkillsName != "" && data.GeneralSkillsName != null) { int GenralSkillName = Convert.ToInt32(data.GeneralSkillsName); _NotificationDetail.generalSkill = _db.SkillSets.Where(x => x.Id == GenralSkillName).FirstOrDefault().Name; } else { _NotificationDetail.generalSkill = null; } if (data.TechnicalSkillsName != "" && data.TechnicalSkillsName != null) { int TechnSkillName = Convert.ToInt32(data.TechnicalSkillsName); _NotificationDetail.technicalskill = _db.SkillSets.Where(x => x.Id == TechnSkillName).FirstOrDefault().Name; } else { _NotificationDetail.technicalskill = null; } _NotificationDetail.StartDate = Convert.ToString(data.CreatedDate); Employee_Skills EmpSkillDetails = new Employee_Skills(); EmpSkillDetails = _db.Employee_Skills.Find(DetailsId); EmpSkillDetails.IsRead = true; _db.Entry(EmpSkillDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } } else if (Header == "Scheduling Request") { var data = _NotificationMethod.GetScheduleNotificationByKey(EmployeeID, DetailsId).FirstOrDefault(); if (data != null) { _NotificationDetail.EmployeeId = data.EmployeeId; _NotificationDetail.HeaderType = data.HeaderType; _NotificationDetail.Hours = data.Hours; _NotificationDetail.ProjectName = data.Project; _NotificationDetail.CustomerName = data.Customer; _NotificationDetail.CostCode = data.AssetName; _NotificationDetail.StartDate = data.StartDate; _NotificationDetail.EndDate = data.EndDate; _NotificationDetail.Duration = data.duration; _NotificationDetail.AssetName = data.AssetName; var reportTodata = _db.EmployeeRelations.Where(x => x.IsActive == true && x.UserID == EmployeeID).FirstOrDefault(); var aspnetUserDetails = _db.AspNetUsers.Where(x => x.Archived == false && x.Id == EmployeeID).FirstOrDefault(); Employee_ProjectPlanner_Scheduling SchedulingDetails = new Employee_ProjectPlanner_Scheduling(); SchedulingDetails = _db.Employee_ProjectPlanner_Scheduling.Find(DetailsId); if (SchedulingDetails != null && SchedulingDetails.ApprovalStatus == "Pending") { _NotificationDetail.AppStatus = SchedulingDetails.ApprovalStatus; } if (aspnetUserDetails != null && SchedulingDetails != null) { if (aspnetUserDetails.HRResponsible == SessionProxy.UserId && aspnetUserDetails.HRResponsible != null) { SchedulingDetails.IsReadHR = true; } if (aspnetUserDetails.AdditionalReportsto == SessionProxy.UserId) { SchedulingDetails.IsReadAddRes = true; } if (SchedulingDetails != null && reportTodata.Reportsto == SessionProxy.UserId) { SchedulingDetails.IsRead = true; } _db.Entry(SchedulingDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } } } else if (Header == "Travel Request") { var data = _NotificationMethod.GetTravelNotificationByKey(EmployeeID, DetailsId).FirstOrDefault(); if (data != null) { _NotificationDetail.EmployeeId = data.EmployeeId; _NotificationDetail.HeaderType = data.HeaderType; _NotificationDetail.TravelType = data.Type; _NotificationDetail.FromCountry = data.FromCountry; _NotificationDetail.FromTown = data.FromCity; _NotificationDetail.FromPlace = data.FromPlace; _NotificationDetail.ToCountry = data.ToCountry; _NotificationDetail.ToTown = data.ToCity; _NotificationDetail.Toplace = data.ToPlace; _NotificationDetail.StartDate = data.StartDate; _NotificationDetail.EndDate = data.EndDate; _NotificationDetail.Duration = data.Duration; _NotificationDetail.Hours = data.Hour; _NotificationDetail.CustomerName = data.CustomerName; _NotificationDetail.ProjectName = data.ProjectName; _NotificationDetail.CostCode = data.CostCode; _NotificationDetail.Function = ""; _NotificationDetail.Link = ""; var reportTodata = _db.EmployeeRelations.Where(x => x.IsActive == true && x.UserID == EmployeeID).FirstOrDefault(); var aspnetUserDetails = _db.AspNetUsers.Where(x => x.Archived == false && x.Id == EmployeeID).FirstOrDefault(); Employee_TravelLeave TravelLeaveDetails = new Employee_TravelLeave(); TravelLeaveDetails = _db.Employee_TravelLeave.Find(DetailsId); if (TravelLeaveDetails != null && TravelLeaveDetails.ApprovalStatus == "Pending") { _NotificationDetail.AppStatus = TravelLeaveDetails.ApprovalStatus; } if (aspnetUserDetails != null && TravelLeaveDetails != null) { if (aspnetUserDetails.HRResponsible == SessionProxy.UserId && aspnetUserDetails.HRResponsible != null) { TravelLeaveDetails.IsReadHR = true; } if (aspnetUserDetails.AdditionalReportsto == SessionProxy.UserId) { TravelLeaveDetails.IsReadAddReport = true; } if (TravelLeaveDetails != null && reportTodata.Reportsto == SessionProxy.UserId) { TravelLeaveDetails.IsRead = true; } _db.Entry(TravelLeaveDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } } } else if (Header == "Annual Leave Request") { var data = _NotificationMethod.GetAnnualLeaveNotificationByKey(EmployeeID, DetailsId).FirstOrDefault(); if (data != null) { _NotificationDetail.EmployeeId = data.EmployeeId; _NotificationDetail.StartDate = data.StartDate; _NotificationDetail.EndDate = data.EndDate; _NotificationDetail.HeaderType = "Annual Leave Request"; _NotificationDetail.Duration = data.Duration; var reportTodata = _db.EmployeeRelations.Where(x => x.IsActive == true && x.UserID == EmployeeID).FirstOrDefault(); var aspnetUserDetails = _db.AspNetUsers.Where(x => x.Archived == false && x.Id == EmployeeID).FirstOrDefault(); Employee_AnualLeave AnualLeaveDetails = new Employee_AnualLeave(); AnualLeaveDetails = _db.Employee_AnualLeave.Find(DetailsId); if (AnualLeaveDetails != null && AnualLeaveDetails.ApprovalStatus == "Pending") { _NotificationDetail.AppStatus = AnualLeaveDetails.ApprovalStatus; } if (aspnetUserDetails != null && AnualLeaveDetails != null) { if (aspnetUserDetails.HRResponsible == SessionProxy.UserId && aspnetUserDetails.HRResponsible != null) { AnualLeaveDetails.IsReadHR = true; } if (aspnetUserDetails.AdditionalReportsto == SessionProxy.UserId) { AnualLeaveDetails.IsReadAddRep = true; } if (AnualLeaveDetails != null && reportTodata.Reportsto == SessionProxy.UserId) { AnualLeaveDetails.IsRead = true; } _db.Entry(AnualLeaveDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } } } else if (Header == "Other Leave Request") { var data = _NotificationMethod.GetOtherLeaveNotificationByKey(EmployeeID, DetailsId).FirstOrDefault(); if (data != null) { _NotificationDetail.EmployeeId = data.EmployeeId; _NotificationDetail.HeaderType = data.HeaderType; _NotificationDetail.StartDate = data.StartDate; _NotificationDetail.EndDate = data.EndDate; _NotificationDetail.Duration = data.Duration; _NotificationDetail.Reason = data.Reason; var reportTodata = _db.EmployeeRelations.Where(x => x.IsActive == true && x.UserID == EmployeeID).FirstOrDefault(); var aspnetUserDetails = _db.AspNetUsers.Where(x => x.Archived == false && x.Id == EmployeeID).FirstOrDefault(); Employee_OtherLeave OtherLeaveDetails = new Employee_OtherLeave(); OtherLeaveDetails = _db.Employee_OtherLeave.Find(DetailsId); if (OtherLeaveDetails != null && OtherLeaveDetails.ApprovalStatus == "Pending") { _NotificationDetail.AppStatus = OtherLeaveDetails.ApprovalStatus; } if (aspnetUserDetails != null && OtherLeaveDetails != null) { if (aspnetUserDetails.HRResponsible == SessionProxy.UserId && aspnetUserDetails.HRResponsible != null) { OtherLeaveDetails.IsReadHR = true; } if (aspnetUserDetails.AdditionalReportsto == SessionProxy.UserId) { OtherLeaveDetails.IsReadAddRep = true; } if (OtherLeaveDetails != null && reportTodata.Reportsto == SessionProxy.UserId) { OtherLeaveDetails.IsRead = true; } _db.Entry(OtherLeaveDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } } } else if (Header == "Maternity/Paternity Leave") { var data = _NotificationMethod.GetMaternityPatLeaveByKey(Convert.ToInt32(DetailsId)).FirstOrDefault(); if (data != null) { _NotificationDetail.EmployeeId = data.EmployeeID; _NotificationDetail.HeaderType = "Maternity/Paternity Leave"; _NotificationDetail.StartDate = Convert.ToString(data.ActualStartDate); _NotificationDetail.EndDate = Convert.ToString(data.ActualEndDate); _NotificationDetail.dueDate = Convert.ToString(data.DueDate); _NotificationDetail.Link = data.Link; var reportTodata = _db.EmployeeRelations.Where(x => x.IsActive == true && x.UserID == EmployeeID).FirstOrDefault(); var aspnetUserDetails = _db.AspNetUsers.Where(x => x.Archived == false && x.Id == EmployeeID).FirstOrDefault(); Employee_MaternityOrPaternityLeaves MatPatLeaveDetails = new Employee_MaternityOrPaternityLeaves(); MatPatLeaveDetails = _db.Employee_MaternityOrPaternityLeaves.Find(DetailsId); if (MatPatLeaveDetails != null && MatPatLeaveDetails.ApprovalStatus == "Pending") { _NotificationDetail.AppStatus = MatPatLeaveDetails.ApprovalStatus; } if (aspnetUserDetails != null && MatPatLeaveDetails != null) { if (aspnetUserDetails.HRResponsible == SessionProxy.UserId && aspnetUserDetails.HRResponsible != null) { MatPatLeaveDetails.IsReadHR = true; } if (aspnetUserDetails.AdditionalReportsto == SessionProxy.UserId) { MatPatLeaveDetails.IsReadAddRes = true; } if (MatPatLeaveDetails != null && reportTodata.Reportsto == SessionProxy.UserId) { MatPatLeaveDetails.IsRead = true; } _db.Entry(MatPatLeaveDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } } } else if (Header == "Sick Leave") { var data = _NotificationMethod.getSickLeaveByKey(Convert.ToInt32(DetailsId)).FirstOrDefault(); if (data != null) { _NotificationDetail.EmployeeId = data.EmployeeId; _NotificationDetail.HeaderType = "Sick Leave Request"; _NotificationDetail.StartDate = Convert.ToString(data.StartDate); _NotificationDetail.EndDate = Convert.ToString(data.EndDate); _NotificationDetail.Duration = Convert.ToDecimal(data.DurationDays); _NotificationDetail.DoctConsulted = data.DoctorConsulted; _NotificationDetail.Paid = data.IsPaid; var reportTodata = _db.EmployeeRelations.Where(x => x.IsActive == true && x.UserID == EmployeeID).FirstOrDefault(); Employee_SickLeaves SickLeaveDetails = new Employee_SickLeaves(); SickLeaveDetails = _db.Employee_SickLeaves.Find(DetailsId); if (SickLeaveDetails != null && SickLeaveDetails.ApprovalStatus == "Pending") { _NotificationDetail.AppStatus = SickLeaveDetails.ApprovalStatus; } var aspnetUserDetails = _db.AspNetUsers.Where(x => x.Archived == false && x.Id == EmployeeID).FirstOrDefault(); if (aspnetUserDetails != null && SickLeaveDetails != null) { if (aspnetUserDetails.HRResponsible == SessionProxy.UserId && aspnetUserDetails.HRResponsible != null) { SickLeaveDetails.IsReadHR = true; } if (aspnetUserDetails.AdditionalReportsto == SessionProxy.UserId) { SickLeaveDetails.IsReadAddRep = true; } if (SickLeaveDetails != null && reportTodata.Reportsto == SessionProxy.UserId) { SickLeaveDetails.IsRead = true; } _db.Entry(SickLeaveDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } } } else if (Header == "Training Request") { var data = _NotificationMethod.GetTrainingNotificationByKey(EmployeeID, DetailsId).FirstOrDefault(); if (data != null) { _NotificationDetail.EmployeeId = data.EmployeeId; _NotificationDetail.StartDate = data.StartDate; _NotificationDetail.EndDate = data.EndDate; _NotificationDetail.TrainingName = data.TrainingName; _NotificationDetail.Provider = data.Provider; if (data.Importance == 1) { _NotificationDetail.Importance = "Mandatory"; } else { _NotificationDetail.Importance = "Optional"; } _NotificationDetail.Cost = data.Cost; _NotificationDetail.Day = Convert.ToString(data.Days); _NotificationDetail.HeaderType = "Training Request"; EmployeeTraining EmployeeTraining = new EmployeeTraining(); EmployeeTraining = _db.EmployeeTrainings.Find(DetailsId); EmployeeTraining.IsRead = true; _db.Entry(EmployeeTraining).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } } else if (Header == "New Vacancy") { var data = _NotificationMethod.GetNewVacancyNotificationByKey(EmployeeID, DetailsId).FirstOrDefault(); if (data != null) { _NotificationDetail.EmployeeId = null; _NotificationDetail.HeaderType = "New Vacancy"; _NotificationDetail.Vacancy = data.Title; _NotificationDetail.ClosingDate = data.ClosingDate; _NotificationDetail.RecruitementProcess = data.RecruitmentProcesses; _NotificationDetail.SalaryRange = data.Salary; _NotificationDetail.Location = data.Location; _NotificationDetail.Business = data.Business; _NotificationDetail.Division = data.Division; _NotificationDetail.Pool = data.Pool; _NotificationDetail.Function = data.Functions; Vacancy VacancyDetails = new Vacancy(); VacancyDetails = _db.Vacancies.Find(DetailsId); VacancyDetails.IsRead = true; _db.Entry(VacancyDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } } else if (Header == "Uplift Submission") { var data = _NotificationMethod.GetUpLiftNotificationByKey(EmployeeID, DetailsId).FirstOrDefault(); if (data != null) { _NotificationDetail.EmployeeId = data.EmployeeId; _NotificationDetail.HeaderType = data.HeaderType; _NotificationDetail.Day = data.day; _NotificationDetail.Date = data.Date; _NotificationDetail.UpliftPosition = data.UpliftPostionId; _NotificationDetail.Hours = data.Hours; _NotificationDetail.ProjectName = data.Project; _NotificationDetail.CustomerName = data.Customer; _NotificationDetail.ChangeInWorkRate = data.WorkerRate; _NotificationDetail.ChangeInCustomerRate = data.CustomerRate; Employee_ProjectPlanner_Uplift_Detail UpliftDetails = new Employee_ProjectPlanner_Uplift_Detail(); var reportTodata = _db.EmployeeRelations.Where(x => x.IsActive == true && x.UserID == EmployeeID).FirstOrDefault(); UpliftDetails = _db.Employee_ProjectPlanner_Uplift_Detail.Find(DetailsId); var aspnetUserDetails = _db.AspNetUsers.Where(x => x.Id == EmployeeID && x.Archived == false).FirstOrDefault(); if (UpliftDetails != null && UpliftDetails.ApprovalStatus == "Pending") { _NotificationDetail.AppStatus = UpliftDetails.ApprovalStatus; } if (aspnetUserDetails != null && UpliftDetails != null) { if (aspnetUserDetails.HRResponsible == SessionProxy.UserId && aspnetUserDetails.HRResponsible != null) { UpliftDetails.IsReadHR = true; } if (aspnetUserDetails.AdditionalReportsto == SessionProxy.UserId) { UpliftDetails.IsReadAddRep = true; } if (UpliftDetails != null && reportTodata.Reportsto == SessionProxy.UserId) { UpliftDetails.IsRead = true; } _db.Entry(UpliftDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } } } else if (Header == "Skill Endorsement") { Employee_AddEndrosementSkills EndrosementSkillseDetails = new Employee_AddEndrosementSkills(); EndrosementSkillseDetails = _db.Employee_AddEndrosementSkills.Find(DetailsId); EndrosementSkillseDetails.IsRead = true; _db.Entry(EndrosementSkillseDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } else if (Header == "New Resource") { var data = _NotificationMethod.getNewResourceDetails(EmployeeID); if (data != null) { _NotificationDetail.EmployeeId = data.Id; _NotificationDetail.HeaderType = "New Resource"; _NotificationDetail.StartDate = Convert.ToString(data.StartDate); _NotificationDetail.email = Convert.ToString(data.UserName); AspNetUser aspDetails = new AspNetUser(); var reportTodata = _db.EmployeeRelations.Where(x => x.IsActive == true && x.UserID == EmployeeID).FirstOrDefault(); aspDetails = _db.AspNetUsers.Find(EmployeeID); if (aspDetails.HRResponsible == SessionProxy.UserId) { aspDetails.IsReadHRRespo = true; } if (aspDetails.AdditionalReportsto == SessionProxy.UserId) { aspDetails.IsReadAddReport = true; } if (reportTodata != null && reportTodata.Reportsto == SessionProxy.UserId) { aspDetails.IsReadNewResource = true; } _db.Entry(aspDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } } else if (Header == "Delete employee") { var data = _NotificationMethod.getDeleteResourceDetails(EmployeeID); if (data != null) { _NotificationDetail.EmployeeId = data.Id; _NotificationDetail.HeaderType = "Delete employee"; _NotificationDetail.EmployeeName = data.FirstName + " " + data.LastName; _NotificationDetail.StartDate = Convert.ToString(data.StartDate); _NotificationDetail.email = Convert.ToString(data.UserName); AspNetUser aspDetails = new AspNetUser(); aspDetails = _db.AspNetUsers.Find(EmployeeID); aspDetails.IsReadArchived = true; _db.Entry(aspDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } } else if (Header == "New Document") { var data = _NotificationMethod.getEmployeeDocumentByKey(Convert.ToInt32(DetailsId)); _NotificationDetail.EmployeeId = data.Id; _NotificationDetail.HeaderType = "New Document"; _NotificationDetail.DocumentName = data.DocumentPath; _NotificationDetail.Description = data.Description; _NotificationDetail.DocLink = data.LinkURL; Employee_Document aspDetails = new Employee_Document(); aspDetails = _db.Employee_Document.Find(DetailsId); aspDetails.IsRead = true; _db.Entry(aspDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } else if (Header == "Document Signature") { var data = _NotificationMethod.getEmployeeDocumentForSignatureByKey(Convert.ToInt32(DetailsId)); _NotificationDetail.EmployeeId = data.Id; _NotificationDetail.HeaderType = "Document Signature"; _NotificationDetail.DocumentName = data.DocumentPath; _NotificationDetail.Description = data.Description; _NotificationDetail.DocLink = data.LinkURL; Employee_Document aspDetails = new Employee_Document(); aspDetails = _db.Employee_Document.Find(DetailsId); aspDetails.IsReadSignature = true; _db.Entry(aspDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } else if (Header == "New Vacancy Posted") { var data = _NotificationMethod.getVacancyByKey(Convert.ToInt32(DetailsId)); _NotificationDetail.EmployeeId = data.Id; _NotificationDetail.HeaderType = "New Vacancy Posted"; Vacancy vacDetails = new Vacancy(); vacDetails = _db.Vacancies.Find(DetailsId); vacDetails.IsReadVacancy = true; _db.Entry(vacDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } else if (Header == "New Applicant") { var data = _NotificationMethod.getTMSApplicantDetailByKey(Convert.ToInt32(EmployeeID)); _NotificationDetail.EmployeeId = data.Id; _NotificationDetail.HeaderType = "New Applicant"; TMS_Applicant aspDetails = new TMS_Applicant(); aspDetails = _db.TMS_Applicant.Find(EmployeeID); aspDetails.IsReadHiringLead = true; _db.Entry(aspDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } return(PartialView("_GetNotificationDetails", _NotificationDetail)); }