public HomeController(IMapper mapper, PayrollDbContext database, ICurrencyHandler currencyHandler, IActGenerator actGenerator) { _mapper = mapper; _db = database; _currencyHandler = currencyHandler; _actGenerator = actGenerator; }
public AccountController(PayrollDbContext context, UserManager <Worker> userManager, SignInManager <Worker> signInManager, RoleManager <IdentityRole> roleManager) { _context = context; _userManager = userManager; _signInManager = signInManager; _roleManager = roleManager; }
public async Task <List <EmployeeInfoWorkPlace> > EmployeeInfoWorks(PayrollDbContext dbContext) { List <EmployeeInfoWorkPlace> employeeInfo = new List <EmployeeInfoWorkPlace>(); var infoEmployee = await dbContext.Placeswork.ToListAsync(); foreach (var place in infoEmployee) { var emp = await dbContext.Employees.Where(x => x.Id == place.EmployeeId).FirstOrDefaultAsync(); var emporia = await dbContext.Emporia.Where(x => x.Id == place.EmporiumId).FirstOrDefaultAsync(); var company = await dbContext.Companies.Where(x => x.Id == emporia.CompanyId).FirstOrDefaultAsync(); var positions = await dbContext.Positions.Where(x => x.Id == place.PositionsId).FirstOrDefaultAsync(); var salary = await dbContext.EmployeeSalaries.Where(x => x.PositionsId == place.PositionsId).FirstOrDefaultAsync(); DateTime date = place.StarDate; EmployeeInfoWorkPlace infoWorkPlace = new EmployeeInfoWorkPlace { CompanyName = company.Name, EmperiumName = emporia.Name, PositionName = positions.Name, PlasierCode = emp.PlasiyerCode, Salary = salary.Salary, Name = emp.Name + " " + emp.Surname, Photo = emp.Photo, StartDate = date, id = emp.Id }; employeeInfo.Add(infoWorkPlace); } return(employeeInfo); }
public WorkerController(IHostingEnvironment env, PayrollDbContext context, UserManager <Worker> userManager, RoleManager <IdentityRole> roleManagerr) { _context = context; _userManager = userManager; _env = env; _roleManager = roleManagerr; }
internal static async Task InvokeAsync(IServiceScope scope, PayrollDbContext dbContext) { if (!dbContext.Users.Any()) { var usermanager = scope.ServiceProvider.GetService <UserManager <AppUser> >(); var roleManager = scope.ServiceProvider.GetService <RoleManager <IdentityRole> >(); var hashpassword = scope.ServiceProvider.GetRequiredService <IPasswordHasher <AppUser> >(); AppUser appUser = new AppUser { Name = "Kenan", Surname = "Behbudov", Email = "*****@*****.**", UserName = "******" }; appUser.PasswordHash = hashpassword.HashPassword(appUser, "Kenan111"); IdentityResult result = await usermanager.CreateAsync(appUser); if (result.Succeeded) { string[] vs = { "Admin", "Hr", "Payroll", "Department" }; foreach (string elm in vs) { await roleManager.CreateAsync(new IdentityRole { Name = elm }); } await usermanager.AddToRoleAsync(appUser, "Admin"); } } }
public static async Task InvokeAsync(IServiceScope scope, PayrollDbContext context) { var configuration = scope.ServiceProvider.GetRequiredService <IConfiguration>(); if (!context.Roles.Any()) { var roleManager = scope.ServiceProvider.GetRequiredService <RoleManager <IdentityRole> >(); var AdminRoleCreate = await roleManager.CreateAsync(new IdentityRole { Name = "Admin" }); var HRRoleCreate = await roleManager.CreateAsync(new IdentityRole { Name = "HR" }); } if (!context.Users.Any()) { var userManager = scope.ServiceProvider.GetRequiredService <UserManager <User> >(); User admin = new User() { Email = "*****@*****.**", Name = "Elshad", Surname = "Safarov", UserName = "******" }; User HR = new User() { Email = "*****@*****.**", Name = "Nurlan", Surname = "Badirli", UserName = "******" }; User user = new User() { Name = "Ali", Surname = "Aliyev", Email = "*****@*****.**", UserName = "******" }; var adminResult = await userManager.CreateAsync(admin, configuration["Admin:Password"]); var HRResult = await userManager.CreateAsync(HR, configuration["HR:Password"]); var userResult = await userManager.CreateAsync(user, "Ali@123"); if (adminResult.Succeeded) { var AdminRoleAdd = await userManager.AddToRoleAsync(admin, "Admin"); } if (HRResult.Succeeded) { var HRRoleAdd = await userManager.AddToRoleAsync(HR, "HR"); } } }
public EmployeeController(PayrollDbContext context, IHostingEnvironment hosting, SignInManager <User> signInManager) { dbContext = context; hostingEnvironment = hosting; _signInManager = signInManager; }
public static async Task <bool> IsEmployeeWorkEndDate(PayrollDbContext dbContext, int empId) { bool found = await dbContext .WorkEnds .AnyAsync(x => x.EmployeeId == empId); return(found); }
public AccountController(PayrollDbContext dbContext, UserManager <User> userManager, SignInManager <User> signInManager) { _dbContext = dbContext; _userManager = userManager; _signInManager = signInManager; }
public static async Task <bool> HasEmporiumAppUser(PayrollDbContext dbContext, int emporiumId) { bool found = await dbContext .EmporiumAppUsers .AnyAsync(x => x.EmporiumId == emporiumId); return(found); }
public EmployeeController(PayrollDbContext _payrollDb , IHostingEnvironment _hostingEnvironment , IFileNameGenerator _nameGenerator) { dbContext = _payrollDb; hostingEnvironment = _hostingEnvironment; nameGenerator = _nameGenerator; }
public MenecerController(PayrollDbContext _dbContext, UserManager <AppUser> _userManager, IOptions <WorkIdOptions> _options) { dbContext = _dbContext; userManager = _userManager; options = _options; }
public UnionModule(ICommandExecutor commandExecutor) : base("api/union") { Get["", true] = async(p, ct) => { string tenantId = Context.GetTenantId(); using (var context = new PayrollDbContext()) { var unions = await context.UnionDues.Include(x => x.Paycode) .Where(x => x.TenantId == tenantId) .ToArrayAsync(); var apiUnion = unions.Select(x => new Model.Union { Id = x.Id, Name = x.Name, DuesDeductionRate = x.DuesDeductionRate, DuesDeductionAmount = x.DuesDeductionAmount, MaximumDueAmount = x.MaximumDueAmount, MinimumDueAmount = x.MinimumDueAmount, PaycodeId = x.Paycode.Id }); return(Response.AsJson(apiUnion)); } }; Get["/{unionId}", true] = async(y, ct) => { string tenantId = Context.GetTenantId(); var person = await GetUnion((Guid)y.unionId, tenantId); return(Response.AsJson(person)); }; Put["/{unionId}", true] = async(p, ct) => { var incomingUnion = this.Bind <UnionDuesToUpdate>(); var tenantId = Context.GetTenantId(); await commandExecutor.Execute(new UpdateUnionDues(tenantId, incomingUnion)); return(HttpStatusCode.NoContent); }; Post["", true] = async(p, ct) => { var incomingUnion = this.Bind <UnionDuesToCreate>(); var tenantId = Context.GetTenantId(); var id = Guid.NewGuid(); await commandExecutor.Execute(new CreateUnionDues(tenantId, id, incomingUnion)); var model = await GetUnion(id, tenantId); return(Response.AsJson(model)); }; }
public static async Task <Employee> HasIdEmployee(PayrollDbContext dbContext, int UserId) { Employee employee = await dbContext.Employees.Where(x => x.Id == UserId) .Include(x => x.WorkPlaces) .ThenInclude(x => x.Emporium) .FirstOrDefaultAsync(); return(employee); }
public async Task Handle(CreateUnionDues command) { using (var context = new PayrollDbContext()) { var paycode = await context.Paycodes.SingleAsync(x => x.Id == command.UnionDuesToCreate.PaycodeId && x.TenantId == command.TenantId); var unionDues = new Model.UnionDues(command.TenantId, command.UnionDuesId, command.UnionDuesToCreate, paycode); context.UnionDues.Add(unionDues); await context.SaveChangesAsync(); } }
public static async Task EmployeePenaltySum(this PayrollDbContext payrollDb, int?count, int?employeeId, DateTime date) { if (count != null) { decimal?amount = payrollDb.Placeswork.Where(x => x.EmployeeId == employeeId) .Include(x => x.Positions) .ThenInclude(x => x.EmployeeSalaries) .Single().Positions.EmployeeSalaries.Salary; if (amount.HasValue) { var WillBeFined = await payrollDb.DisciplinePenalties.FirstOrDefaultAsync();//olunacaq cerime if (WillBeFined != null) { if (CountIsBigNumberMax((int)count, WillBeFined.MaxDay)) { var employee = await payrollDb.Employees.Where(x => x.Id == employeeId).FirstOrDefaultAsync(); Dismissed dismissed = new Dismissed() { Name = employee.Name, Surname = employee.Surname, Number = employee.Number, Photo = employee.Photo, Email = employee.Email, DistrictRegistration = employee.DistrictRegistration, IDCardSerialNumber = employee.IDCardSerialNumber, PlasiyerCode = employee.PlasiyerCode, EndDate = date.AddDays((double)-count) };//isden cixanlar payrollDb.Dismisseds.Add(dismissed); payrollDb.Employees.Remove(employee); await payrollDb.SaveChangesAsync(); } else { var penaltyAmount = SalaryPenalty((decimal)amount, (int)count, WillBeFined.PenaltyValue); Penalty penalty = new Penalty { Amount = penaltyAmount, Date = DateTime.Now.Date, EmployeeId = (int)employeeId }; await payrollDb.Penalties.AddAsync(penalty); await payrollDb.SaveChangesAsync(); } } } } }
public static void Main(string[] args) { var webHost = CreateWebHostBuilder(args).Build(); using (IServiceScope scope = webHost.Services.CreateScope()) { using (PayrollDbContext context = scope.ServiceProvider.GetRequiredService <PayrollDbContext>()) { Seed.InvokeAsync(scope, context).Wait(); } } webHost.Run(); }
public static async Task Main(string[] args) { IWebHost host = CreateWebHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { using (PayrollDbContext dbContext = scope.ServiceProvider.GetRequiredService <PayrollDbContext>()) { await Seed.InvokeAsync(scope, dbContext); } } await host.RunAsync(); }
public AccountController ( PayrollDbContext _dbContext, UserManager <AppUser> _userManager, SignInManager <AppUser> _signInManager, RoleManager <IdentityRole> _roleManager ) { userManager = _userManager; dbContext = _dbContext; signInManager = _signInManager; roleManager = _roleManager; }
public async Task Handle(UpdateUnionDues command) { using (var context = new PayrollDbContext()) { var id = command.UnionDuesToUpdate.Id; var union = await context.UnionDues.SingleAsync(p => p.Id == id && p.TenantId == command.TenantId); var paycode = await context.Paycodes.SingleAsync(x => x.Id == command.UnionDuesToUpdate.PaycodeId && x.TenantId == command.TenantId); union.Update(command.UnionDuesToUpdate, paycode); await context.SaveChangesAsync(); } }
public static dynamic GetDropDownSource(PayrollDbContext context, string type, bool addInitial = false) { var list = context.DropdownList.Where(x => x.Type == type).ToList(); if (addInitial) { list.Insert(0, new DropdownListItem { Id = Guid.NewGuid(), Type = type, Text = "Please select", Value = "" }); } return(list); }
public AccountController(UserManager <AppUser> _userManager , RoleManager <IdentityRole> _roleManager , SignInManager <AppUser> _signInManager , IPasswordHasher <AppUser> _passwordHasher , IPasswordValidator <AppUser> _passwordValidator , PayrollDbContext _payrollDb) { userManager = _userManager; roleManager = _roleManager; signInManager = _signInManager; passwordHasher = _passwordHasher; passwordValidator = _passwordValidator; payrollDb = _payrollDb; }
public PanelController(PayrollDbContext _dbContext, UserManager <AppUser> _userManager, RoleManager <IdentityRole> _roleManager, SignInManager <AppUser> _signInManager, IPasswordHasher <AppUser> _passwordHasher, IPasswordValidator <AppUser> _passwordValidator, IHostingEnvironment _hostingEnvironment, IFileNameGenerator _nameGenerator) { dbContext = _dbContext; userManager = _userManager; roleManager = _roleManager; signInManager = _signInManager; passwordHasher = _passwordHasher; passwordValidator = _passwordValidator; hostingEnvironment = _hostingEnvironment; nameGenerator = _nameGenerator; }
public AccountController(UserManager <AppUser> _userManager , RoleManager <IdentityRole> _roleManager , SignInManager <AppUser> _signInManager , IPasswordHasher <AppUser> _passwordHasher , IPasswordValidator <AppUser> _passwordValidator , PayrollDbContext _payrollDb , IHostingEnvironment _hostingEnvironment , IFileNameGenerator _nameGenerator) { userManager = _userManager; roleManager = _roleManager; signInManager = _signInManager; passwordHasher = _passwordHasher; passwordValidator = _passwordValidator; payrollDb = _payrollDb; hostingEnvironment = _hostingEnvironment; nameGenerator = _nameGenerator; }
public static async Task <AppUserRoleModel> GetAppUserAsync(PayrollDbContext dbContext) { var data = await dbContext.MessageReciurments .ToListAsync(); var role = dbContext.Roles .ToList(); var holdings = dbContext.Holdings.ToList(); AppUserRoleModel userRoleModel = new AppUserRoleModel() { MessageReciurments = data, Holdings = holdings, IdentityAllRole = role }; return(userRoleModel); }
public static async Task <AppUserRoleModel> UserRoleAsync(PayrollDbContext dbContext, string userid, UserManager <AppUser> userManager, RoleManager <IdentityRole> roleManager) { var user = await dbContext.Users .Where(x => x.Id == userid) .FirstOrDefaultAsync(); AppUserRoleModel userRoleModel = null; if (user != null) { List <IdentityRole> identityRoles = new List <IdentityRole>(); var data = await userManager .GetRolesAsync(user); foreach (var rol in data) { var rolee = roleManager.Roles.Where(x => x.Name == rol).FirstOrDefault(); identityRoles.Add(rolee); } var role = dbContext .UserRoles.Where(x => x.UserId == userid) .ToList(); var rols = dbContext.Roles .ToList(); var holdings = dbContext .Holdings .ToList(); userRoleModel = new AppUserRoleModel() { AppUser = user, Holdings = holdings, IdentityUserRoles = identityRoles, IdentityAllRole = rols }; } return(userRoleModel); }
private async Task <Model.Union> GetUnion(Guid id, string tenantId) { using (var context = new PayrollDbContext()) { var p = await context.UnionDues.Include(x => x.Paycode) .Where(x => x.TenantId == tenantId && x.Id == id) .SingleOrDefaultAsync(); var union = new Model.Union { Id = p.Id, Name = p.Name, UseAmount = p.UseAmount, DuesDeductionRate = p.DuesDeductionRate, DuesDeductionAmount = p.DuesDeductionAmount, MaximumDueAmount = p.MaximumDueAmount, MinimumDueAmount = p.MinimumDueAmount, PaycodeId = p.Paycode.Id }; return(union); } }
public static async Task <AppUser> CreateAppUserAsync(PayrollDbContext dbContext , Employee employee, UserManager <AppUser> userManager, IPasswordHasher <AppUser> passwordHasher) { AppUser user = new AppUser() { FirstName = employee.Name, SecondName = employee.Surname, Photo = employee.Photo, Adress = employee.DistrictRegistration, Birth = employee.BirthDay, UserName = employee.Name, Email = employee.Email, }; user.PasswordHash = passwordHasher.HashPassword(user, "12345"); await userManager.CreateAsync(user); await dbContext.SaveChangesAsync(); return(user); }
public static async Task <List <EmployeeInfoWorkPlace> > EmployeeSalaryAsync(PayrollDbContext dbContext, DateTime DateTime) { var data = await dbContext.Placeswork .Include(x => x.Emporium) .ThenInclude(y => y.Company) .ThenInclude(a => a.Holding) .Include(b => b.Positions) .ThenInclude(c => c.EmployeeSalaries) .Include(d => d.Employee) .ThenInclude(z => z.AccuredSalaries) .Select(w => new EmployeeInfoWorkPlace { Name = w.Employee.Name, Photo = w.Employee.Photo, CompanyName = w.Emporium.Company.Name, EmperiumName = w.Emporium.Name, PositionName = w.Positions.Name, EmployeAccuredSalaries = w.Employee.AccuredSalaries.Where(x => x.AccuredDate.Month == DateTime.Month).ToList(), Salary = w.Positions.EmployeeSalaries.Salary, id = w.EmployeeId }).ToListAsync(); return(data); }
public static async Task BoolSaveSignInOut(PayrollDbContext payrollDb, SignInOutReasonTbl model, SignInOutReasonTbl signInOut) { if (BoolAttendance.Sorry == model.RaasonName) { signInOut.SignIn = false; await payrollDb.SignInOutReasons.AddAsync(signInOut); await payrollDb.SaveChangesAsync(); } if (BoolAttendance.NotSorry == model.RaasonName) { signInOut.SignIn = false; await payrollDb.SignInOutReasons.AddAsync(signInOut); await payrollDb.SaveChangesAsync(); } if (BoolAttendance.ItWorked == model.RaasonName) { signInOut.SignIn = true; await payrollDb.SignInOutReasons.AddAsync(signInOut); await payrollDb.SaveChangesAsync(); } }