// GET: Employee public ActionResult Index() { EmployeeModel employee = _logic.GetByEmail(User.Identity.Name); ViewBag.employee = employee; return(View()); }
public ActionResult Index() { var employee = _employeeLogic.GetByEmail(User.Identity.Name); ViewBag.List = _logic.GetListByEmployeeId(employee.Employee_id); return(View()); }
// GET: Carrer public ActionResult Index() { EmployeeModel employee = _logic.GetByEmail(User.Identity.Name); ViewBag.employee = employee; ViewBag.Skills = _skillLogic.GetSkill(employee.Employee_id); ViewBag.ExSkills = _skillLogic.GetExculdeSkill(employee.Employee_id); return(View()); }
public ActionResult Insert(TimeOffModel model) { if (ModelState.IsValid) { EmployeeModel employee = _employeeLogic.GetByEmail(User.Identity.Name); model.TimeoffEmpId = employee.Employee_id; _logic.Create(model); return(RedirectToAction("index")); } BindingList(model.TimeoffDate.Month, model.TimeoffDate.Year); return(View("index")); }
public ActionResult Index() { EmployeeModel model = _logic.GetByEmail(User.Identity.Name); var organizationTree = _logic.GetOrganizationTree(model.Employee_id); string employeeJson = ""; List <string> employeeNames = new List <string>(); organizationTree[0].Employee_superiorName = null; foreach (EmployeeModel employee in organizationTree) { var name = employee.Employee_name.Replace(" ", "_"); employeeNames.Add(name); string employeeString = $"{name} = {{"; if (employee.Employee_superiorName != null) { employeeString += $"parent: {employee.Employee_superiorName.Replace(" ", "_")},"; } employeeString += $"text: {{"; employeeString += $"name : \"{employee.Employee_name}\","; employeeString += $"title : \"{employee.Job}\","; employeeString += $"contact : \"tel : {employee.Employee_phone}\""; employeeString += $"}},"; employeeString += $"image : \"{employee.Employee_image}\"}},"; employeeJson += employeeString; } ViewBag.employeeJson = employeeJson; ViewBag.employeeNames = string.Join(",", employeeNames); return(View()); }
public static ApplicationUserManager Create(IdentityFactoryOptions <ApplicationUserManager> options, IOwinContext context) { var manager = new ApplicationUserManager(new UserStore <ApplicationUser>(context.Get <ApplicationDbContext>())); // Configure validation logic for usernames manager.UserValidator = new UserValidator <ApplicationUser>(manager) { AllowOnlyAlphanumericUserNames = false, RequireUniqueEmail = true }; // Configure validation logic for passwords manager.PasswordValidator = new PasswordValidator { RequiredLength = 6, RequireNonLetterOrDigit = true, RequireDigit = true, RequireLowercase = true, RequireUppercase = true, }; // Configure user lockout defaults manager.UserLockoutEnabledByDefault = true; manager.DefaultAccountLockoutTimeSpan = TimeSpan.FromMinutes(5); manager.MaxFailedAccessAttemptsBeforeLockout = 5; // Register two factor authentication providers. This application uses Phone and Emails as a step of receiving a code for verifying the user // You can write your own provider and plug it in here. manager.RegisterTwoFactorProvider("Phone Code", new PhoneNumberTokenProvider <ApplicationUser> { MessageFormat = "Your security code is {0}" }); manager.RegisterTwoFactorProvider("Email Code", new EmailTokenProvider <ApplicationUser> { Subject = "Security Code", BodyFormat = "Your security code is {0}" }); manager.EmailService = new EmailService(); manager.SmsService = new SmsService(); var dataProtectionProvider = options.DataProtectionProvider; if (dataProtectionProvider != null) { manager.UserTokenProvider = new DataProtectorTokenProvider <ApplicationUser>(dataProtectionProvider.Create("ASP.NET Identity")); } // Create user for employee EmployeeLogic logic = new EmployeeLogic(); foreach (EmployeeModel employee in logic.GetList()) { if (manager.FindByEmail(employee.Employee_mail) == null) { ApplicationUser user = new ApplicationUser() { UserName = employee.Employee_mail, Email = employee.Employee_mail }; manager.Create(user, DefaultPassword); } } // create admin role var RoleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(context.Get <ApplicationDbContext>())); if (!RoleManager.RoleExists(AdminRole)) { IdentityRole role = new IdentityRole(AdminRole); RoleManager.Create(role); } // assign role for admin EmployeeModel adminEmployee = logic.GetByEmail("*****@*****.**"); var adminUser = manager.FindByEmail(adminEmployee.Employee_mail); if (!manager.IsInRole(adminUser.Id, AdminRole)) { manager.AddToRole(adminUser.Id, AdminRole); } return(manager); }
public void CalculateWeeklySalary(DateTime fromDate) { decimal defaultWorkTime = 5 * WORK_TIME; // Calculate sum time off EmployeeModel employee = _employeeLogic.GetByEmail(User.Identity.Name); List <TimeOffModel> timeOffModels = _timeOffLogic.GetListInWeek(employee.Employee_id, fromDate); decimal timeOffNoPay = timeOffModels .Where(q => q.TimeoffTpeId == 2) .Select(q => q.TimeoffNumberOfHours).DefaultIfEmpty() .Sum(); ViewBag.TimeOffNoPay = timeOffNoPay; ViewBag.TimeOffNoPayList = timeOffModels.Where(q => q.TimeoffTpeId == 2).ToList(); decimal timeOffPay = timeOffModels .Where(q => q.TimeoffTpeId == 1) .Select(q => q.TimeoffNumberOfHours).DefaultIfEmpty() .Sum(); var toDate = fromDate.AddDays(7); toDate = toDate <= DateTime.Now ? toDate : DateTime.Now; List <OverTimeModel> overTimeModels = _overTimeLogic.GetByEmployee(employee.Employee_id, fromDate, toDate); ViewBag.TimeOffPay = timeOffPay; ViewBag.TimeOffPayList = timeOffModels.Where(q => q.TimeoffTpeId == 1).ToList(); // Calculate sum of over time decimal overTime = overTimeModels.Select(q => q.OvertimeHours).DefaultIfEmpty(0).Sum(); ViewBag.OverTime = overTime; decimal totalTime = defaultWorkTime + overTime; ViewBag.WorkTime = defaultWorkTime - timeOffPay - timeOffNoPay; // Calculate each time percent ViewBag.timeOffNoPayPercent = (int)((timeOffNoPay / totalTime) * 100); ViewBag.timeOffPayPercent = (int)((timeOffPay / totalTime) * 100); ViewBag.normalPayPercent = (int)((defaultWorkTime / totalTime) * 100); ViewBag.overTimePayPercent = (int)((overTime / totalTime) * 100); ViewBag.TimeOffList = timeOffModels; ViewBag.OverTimeList = overTimeModels; // Caculate salary GradeLevelModel gradeLevel = _gradeLevelLogic.GetForEmployee(employee.Employee_id); decimal salary = (defaultWorkTime - timeOffNoPay) * gradeLevel.GradelevelPayRate; salary += overTime * (decimal)1.5 * gradeLevel.GradelevelPayRate; ViewBag.WeeklySalary = salary; List <DateTime> startWeekDates = new List <DateTime>(); DateTime startWeekDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); while (startWeekDate.DayOfWeek != DayOfWeek.Sunday) { startWeekDate = startWeekDate.AddDays(1); } while (startWeekDate <= DateTime.Now) { startWeekDates.Add(startWeekDate); startWeekDate = startWeekDate.AddDays(7); } ViewBag.StartWeekDates = startWeekDates.Select(q => q.ToString("yyyy-MM-dd")); ViewBag.selectedDate = fromDate.ToString("yyyy-MM-dd"); }