public void AddEnrollmentActivity(int enrollmentId, string activityText, int hrUserId, string currentUser) { EnrollmentActivity activity = new EnrollmentActivity() { Action = activityText, EnrollmentId = enrollmentId, CurrentUser = currentUser }; this._context.Enrollment_Activity.Add(activity); this._context.SaveChanges(); }
public void UpdateVendorChecklistItem(int checklistId, bool isChecked, string type, string value, string tagHelper, string enrollmentId, string currentUser, string userName) { string completed = isChecked ? "Y" : "N"; if (tagHelper == "V") { VendorChecklist item = this._context.Vendor_Checklist.Where(r => r.VendorChecklistId == checklistId).First(); if (item != null) { item.IndCompleted = completed; item.CurrentUser = currentUser; if (type == "Text" || type == "Date") { item.CommentValue = value; } else { item.CommentValue = null; } } this._context.Vendor_Checklist.Attach(item); if (!string.IsNullOrEmpty(enrollmentId)) { int eid = Convert.ToInt32(enrollmentId); string status = isChecked ? "checked" : "unchecked"; string text = "Vendor tasklist item " + item.Text + " is " + status + " by " + userName; EnrollmentActivity activity = new EnrollmentActivity() { Action = text, EnrollmentId = eid, CurrentUser = currentUser }; this._context.Enrollment_Activity.Add(activity); } this._context.SaveChanges(); } else { this.UpdateEnrollmentChecklistItem(checklistId, isChecked, type, value, enrollmentId, currentUser, userName, true); } }
public void AddComment(CommentViewModel comment) { //var comments = this._context // .Enrollment_Comment // .Where(r => r.EnrollmentId == comment.EnrollmentId); EnrollmentComment theComment = new EnrollmentComment(); theComment.EnrollmentId = comment.CommentEnrollmentId; theComment.Comment = comment.Comment; theComment.CurrentUser = comment.CurrentUser; this._context.Enrollment_Comment.Add(theComment); EnrollmentActivity activity = new EnrollmentActivity() { Action = "Comment made on candidate", EnrollmentId = comment.CommentEnrollmentId }; this._context.Enrollment_Activity.Add(activity); this._context.SaveChanges(); }
public void AddCandidate(AddCandidateViewModel model, int productOwnerId) { var owner = this._context.Product_Owner.Where(r => r.ProductOwnerId == productOwnerId).First(); //Add a Candidate Candidate candidate = new Candidate { FirstName = model.FirstName, LastName = model.LastName, //Gender = model.Gender.ToString(), Gender = "M", Email = model.Email, AddressLine1 = model.Address, City = model.City, State = model.State, Zip = model.Zip, ProductOwnerId = productOwnerId, ProductOwner = owner }; if (!string.IsNullOrEmpty(model.SSN)) { candidate.SSN = model.SSN.Replace("-", ""); } if (!string.IsNullOrEmpty(model.Phone)) { candidate.Phone = model.Phone.Replace("-", "").Replace("(", "").Replace(")", ""); } this._context.Candidate.Add(candidate); int years = Convert.ToInt32(model.Duration.Split('-')[0]); int months = Convert.ToInt32(model.Duration.Split('-')[1]); Enrollment enrollment = new Enrollment() { Internal = model.Internal, JobTitle = model.JobTitle, DurationYears = years, DurationMonths = months, PayRate = Convert.ToDecimal(model.PayRate), //StartDate = model.StartDate, //EndDate = model.EndDate, OnboardedIndicator = "N", ActiveIndicator = "Y", EmploymentTypeCode = "1", TaxStatusCode = model.TaxStatus, ClientId = Convert.ToInt32(model.Client), ClientContactId = Convert.ToInt32(model.ClientContact), //VendorContactId = Convert.ToInt32(model.VendorContact) }; if (!string.IsNullOrEmpty(model.BillRate) && model.Internal != "Internal") { enrollment.BillRate = Convert.ToDecimal(model.BillRate); } if (!string.IsNullOrEmpty(model.PortfolioManager) && model.Internal != "Internal") { enrollment.ProtfolioManagerId = Convert.ToInt32(model.PortfolioManager); } if (!string.IsNullOrEmpty(model.EndClient) && model.Internal != "Internal") { enrollment.EndClientId = Convert.ToInt32(model.EndClient); } if (!string.IsNullOrEmpty(model.Vendor) && model.Internal != "Internal") { if (model.TaxStatus != "W2" && model.TaxStatus != "1099") { enrollment.VendorId = Convert.ToInt32(model.Vendor); } } enrollment.Candidate = candidate; //enrollment.EmploymentType = candidate; //enrollment.TaxStatus = candidate; //enrollment.Client = candidate; //enrollment.ClientContact = candidate; //enrollment.EndClient = candidate; //enrollment.Vendor = candidate; //enrollment.VendorContact = candidate; this._context.Enrollment.Add(enrollment); EnrollmentActivity activity = new EnrollmentActivity() { Action = "Candidate Created", Enrollment = enrollment }; this._context.Enrollment_Activity.Add(activity); //Add Enrollment Checklist var enrollmentChecklist = this._context.Ref_Checklist.Where(r => r.EmploymentType == model.TaxStatus).Select(r => new { r.Text, r.CommentType, r.IsActive }); foreach (var taskItem in enrollmentChecklist) { Checklist item = new Checklist { Text = taskItem.Text, IndCompleted = "N", IsActive = taskItem.IsActive, CommentType = taskItem.CommentType, Enrollment = enrollment }; this._context.Checklist.Add(item); } //Add Vendor Checklist if (enrollment.VendorId != 0) { var vendorChecklist = this._context.Ref_Checklist.Where(r => r.EmploymentType == "C2C").Select(r => new { r.Text, r.CommentType, r.IsActive }); foreach (var taskItem in vendorChecklist) { Checklist item = new Checklist { Text = taskItem.Text, IndCompleted = "N", IsActive = taskItem.IsActive, CommentType = taskItem.CommentType, Enrollment = enrollment }; this._context.Checklist.Add(item); } int vendorCount = this._context.Vendor_Checklist.Where(r => r.VendorId == enrollment.VendorId).Count(); if (vendorCount == 0) { var vendorLookup = this._context.Ref_Checklist.Where(r => r.EmploymentType == "V").Select(r => new { r.Text, r.CommentType, r.IsActive }); foreach (var taskItem in vendorLookup) { VendorChecklist item = new VendorChecklist { Text = taskItem.Text, IndCompleted = "N", IsActive = taskItem.IsActive, CommentType = taskItem.CommentType, VendorId = Convert.ToInt32(model.Vendor) }; this._context.Vendor_Checklist.Add(item); } } } //Add Client Checklist if (enrollment.ClientId != 0) { var clientChecklist = this._context.Ref_Checklist.Where(r => r.ClientId == enrollment.ClientId).Select(r => new { r.Text, r.CommentType, r.IsActive }); foreach (var taskItem in clientChecklist) { ClientChecklist item = new ClientChecklist { Text = taskItem.Text, IndCompleted = "N", IsActive = taskItem.IsActive, CommentType = taskItem.CommentType, Enrollment = enrollment }; this._context.Client_Checklist.Add(item); } } this._context.SaveChanges(); }
public void UpdateCandidateDetails(OnboardingDetails detail) { var enrollment = this._context .Enrollment.Include(r => r.Candidate).Include(r => r.Vendor).Include(r => r.VendorContact) .Where(r => r.EnrollmentId == detail.EnrollmentId).First(); enrollment.Candidate.Email = detail.Email; enrollment.Candidate.AddressLine1 = detail.AddressLine1; enrollment.Candidate.AddressLine2 = detail.AddressLine2; enrollment.Candidate.City = detail.City; enrollment.Candidate.State = detail.State; enrollment.Candidate.Zip = detail.Zip; enrollment.Candidate.Phone = detail.Phone; enrollment.JobTitle = detail.Position; enrollment.BillRate = Convert.ToDecimal(detail.BillRate); enrollment.PayRate = Convert.ToDecimal(detail.PayRate); enrollment.StartDate = Convert.ToDateTime(detail.StartDate); enrollment.EndDate = Convert.ToDateTime(detail.EndDate); enrollment.CurrentUser = detail.CurrentUser; if (enrollment.Vendor != null) { enrollment.Vendor.CompanyName = detail.VendorName; enrollment.Vendor.AddressLine1 = detail.VendorAddressLine1; enrollment.Vendor.AddressLine2 = detail.VendorAddressLine2; enrollment.Vendor.City = detail.VendorCity; enrollment.Vendor.State = detail.VendorState; enrollment.Vendor.Zip = detail.VendorZip; enrollment.Vendor.TaxId = detail.FederalId; } if (enrollment.VendorContact != null) { enrollment.VendorContact.Name = detail.ContactFirstName; enrollment.VendorContact.Email = detail.ContactEmail; } else if (!string.IsNullOrEmpty(detail.ContactFirstName) && enrollment.Vendor != null) { VendorContact theContact = new VendorContact { Name = detail.ContactFirstName, Email = detail.ContactEmail, VendorId = enrollment.Vendor.VendorId }; this._context.Vendor_Contact.Add(theContact); enrollment.VendorContact = theContact; } this._context.Attach(enrollment); EnrollmentActivity activity = new EnrollmentActivity() { Action = "Candidate information altered", EnrollmentId = enrollment.EnrollmentId, Enrollment = enrollment }; this._context.Enrollment_Activity.Add(activity); this._context.SaveChanges(); }