private String GetComments(Salary salary) { String comment = ""; if (salary.Title != null && salary.Title.Length > 1) { comment += "Title: " + salary.Title; } // If leave is not equal to 'N/A' if (salary.LeaveTypeId > 1) { if (comment.Length > 0) { // New line after comments. comment += Environment.NewLine; } comment += "Leave status: " + salary.LeaveType.Name; } if (salary.PromotionAmount > 0) { if (comment.Length > 0) { // New line after comments. comment += Environment.NewLine; } comment += "Promotion: " + salary.PromotionAmount.ToString("C0", CultureInfo.CurrentCulture); } if (salary.Person.Employments.Count > 1) { if (comment.Length > 0) { // New line after comments. comment += Environment.NewLine; } comment += "Split-funded:"; foreach (var department in salary.Person.Employments.Select(e => e.Department)) { comment += Environment.NewLine; comment += "-" + department.Name; } } if (salary.MeritAdjustmentTypeId > 2) { if (comment.Length > 0) { // New line after comments. comment += Environment.NewLine; } comment += "Merit Adjustment:"; comment += Environment.NewLine; comment += salary.MeritAdjustmentType.Name; } if (salary.MeritAdjustmentNote != null && salary.MeritAdjustmentNote.Length > 0) { if (comment.Length > 0) { // New line after merit comments. comment += Environment.NewLine; } comment += "Merit Adjustment Comment:"; comment += Environment.NewLine; comment += salary.MeritAdjustmentNote; } if (salary.SpecialIncrease > 0) { if (comment.Length > 0) { // New line after merit comments. comment += Environment.NewLine; } comment += "Special Adjustment:"; comment += Environment.NewLine; foreach (var adjustment in salary.SpecialSalaryAdjustments) { comment += "-" + adjustment.SpecialAdjustmentType.Name; comment += Environment.NewLine; } comment += "Special Adjustment Comment:"; comment += Environment.NewLine; comment += salary.SpecialAdjustmentNote; } return comment; }
private bool IsAuthorizedToCreateSalary(Salary salary) { if (HttpContext.Current.User.IsInRole("manage-all")) { return true; } return false; }
private bool IsAuthorizedToUpdateSalary(Salary salary) { var departments = DbContext.Employments .Where(e => e.PersonId == salary.PersonId) .Select(e => e.Department); foreach (var dept in departments) { if (HttpContext.Current.User.IsInRole("manage-all") || HttpContext.Current.User.IsInRole("update-" + dept.Id)) { return true; } } return false; }
private double GetMeritPercentageIncrease(Salary salary) { double totalAmount = salary.BaseAmount + salary.AdminAmount + salary.EminentAmount + salary.PromotionAmount; double percentage = (double)salary.MeritIncrease / (totalAmount); return percentage; }