public string GetUserEmailByID(string id) { var appDbContext = new LeaveManagementDbContext(); var user = appDbContext.ApplicationUser.Where(t => t.Id == id).FirstOrDefault(); return(user.Email); }
public List <ApplicationUser> GetUsersByRole(string RoleName) { var appDbContext = new LeaveManagementDbContext(); List <ApplicationUser> user = appDbContext.ApplicationUser.Where(t => t.RoleName == RoleName).ToList(); return(user); }
public ApplicationUser GetUsersByName(string UserName) { var appDbContext = new LeaveManagementDbContext(); ApplicationUser user = appDbContext.ApplicationUser.Where(t => t.UserName == UserName).FirstOrDefault(); return(user); }
public List <ApplicationUser> ListAllEmployeeProfile() { var appDbContext = new LeaveManagementDbContext(); var userStore = new ApplicationUserStore(appDbContext); var userManager = new ApplicationUserManager(userStore); List <ApplicationUser> Users = appDbContext.ApplicationUser.ToList(); return(Users); }
public ActionResult EditInfo() { var appDbContext = new LeaveManagementDbContext(); var userStore = new ApplicationUserStore(appDbContext); var userManager = new ApplicationUserManager(userStore); string uid = _employeeService.GetUserID(); EmployeeInfoViewModel ivm = _employeeService.ViewEmployeeInfo(uid); return(View(ivm)); }
public void OnActionExecuting(ActionExecutingContext filterContext) { var appDbContext = new LeaveManagementDbContext(); var userStore = new ApplicationUserStore(appDbContext); var userManager = new ApplicationUserManager(userStore); var user = userManager.FindById(filterContext.HttpContext.User.Identity.GetUserId()); if (filterContext.HttpContext.User.IsInRole("ProjectManager") == false && user.IsSpecialPermission == false) { filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Home", action = "Index" })); } }
public IdentityResult DeleteEmployeeProfile(string Id) { var appDbContext = new LeaveManagementDbContext(); var userStore = new ApplicationUserStore(appDbContext); var userManager = new ApplicationUserManager(userStore); var user = userManager.FindById(Id); EmployeeInfo ei = appDbContext.EmployeeInfo.Where(t => t.ApplicationUser.Id == Id).FirstOrDefault(); appDbContext.EmployeeInfo.Remove(ei); //var roleId = userManager.GetRoles(Id).FirstOrDefault(); //userManager.RemoveFromRole(user.Id,roleId); var result = userManager.Delete(user); return(result); }
public void EmployeeLogin(LoginViewModel lvm) { var appDbContext = new LeaveManagementDbContext(); var userStore = new ApplicationUserStore(appDbContext); var userManager = new ApplicationUserManager(userStore); var user = userManager.Find(userManager.FindByEmail(lvm.Email).UserName, lvm.Password); if (user != null) { //login var authenticationManager = HttpContext.Current.GetOwinContext().Authentication; var userIdentity = userManager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie); authenticationManager.SignIn(new AuthenticationProperties(), userIdentity); } }
public void CreateRolesAndUsers() { var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(new LeaveManagementDbContext())); var appDbContext = new LeaveManagementDbContext(); var appUserStore = new ApplicationUserStore(appDbContext); var userManager = new ApplicationUserManager(appUserStore); //Create Admin Role if (!roleManager.RoleExists("Employee")) { var role = new IdentityRole(); role.Name = "Employee"; roleManager.Create(role); } }
public IdentityResult RegisterEmployeeProfile(RegisterViewModel rvm) { var appDbContext = new LeaveManagementDbContext(); var userStore = new ApplicationUserStore(appDbContext); var userManager = new ApplicationUserManager(userStore); var passwordHash = Crypto.HashPassword(rvm.Password); var user = new ApplicationUser() { Email = rvm.Email, UserName = rvm.Name, PasswordHash = passwordHash, PhoneNumber = rvm.Contact, RoleName = rvm.RoleName, IsSpecialPermission = rvm.IsSpecialPermission, EmployeeInfo = new EmployeeInfo() }; var result = userManager.Create(user); if (result.Succeeded) { userManager.AddToRole(user.Id, rvm.RoleName); } return(result); }
public void CreateLeaveType() { var appDbContext = new LeaveManagementDbContext(); LeaveType l = new LeaveType(); l = appDbContext.LeaveTypes.Where(t => t.LeaveTypeName == "Loss of Pay").FirstOrDefault(); if (l == null) { LeaveType l1 = new LeaveType(); l1.LeaveTypeName = "Loss of Pay"; appDbContext.LeaveTypes.Add(l1); appDbContext.SaveChanges(); } l = appDbContext.LeaveTypes.Where(t => t.LeaveTypeName == "Compensatory").FirstOrDefault(); if (l == null) { LeaveType l1 = new LeaveType(); l1.LeaveTypeName = "Compensatory"; appDbContext.LeaveTypes.Add(l1); appDbContext.SaveChanges(); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, LeaveManagementDbContext context) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseRouting(); app.UseCors(MyAllowSpecificOrigins); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); app.UseOpenApi(); app.UseSwaggerUi3(); //Update database on project startup context.Database.Migrate(); }
public void CreateRolesAndUsers() { var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(new LeaveManagementDbContext())); var appDbContext = new LeaveManagementDbContext(); var appUserStore = new ApplicationUserStore(appDbContext); var userManager = new ApplicationUserManager(appUserStore); //Create Admin Role if (!roleManager.RoleExists("HumanResources")) { var role = new IdentityRole(); role.Name = "HumanResources"; var rolecreate = roleManager.Create(role); } //Create Admin User if (userManager.FindByName("HumanResources") == null) { var passwordHash = Crypto.HashPassword("humanresources123"); var user = new ApplicationUser() { Email = "*****@*****.**", UserName = "******", PasswordHash = passwordHash, PhoneNumber = "0000", RoleName = "HumanResources", EmployeeInfo = new EmployeeInfo() }; var chkUser = userManager.Create(user); if (chkUser.Succeeded) { userManager.AddToRole(user.Id, "HumanResources"); } } //Create Manager Role if (!roleManager.RoleExists("ProjectManager")) { var role = new IdentityRole(); role.Name = "ProjectManager"; roleManager.Create(role); } //Create Manager User if (userManager.FindByName("ProjectManager") == null) { var passwordHash = Crypto.HashPassword("projectmanager123"); var user = new ApplicationUser() { Email = "*****@*****.**", UserName = "******", PasswordHash = passwordHash, PhoneNumber = "0000", RoleName = "ProjectManager", EmployeeInfo = new EmployeeInfo() }; var chkUser = userManager.Create(user); if (chkUser.Succeeded) { userManager.AddToRole(user.Id, "ProjectManager"); } } //Create Customer Role if (!roleManager.RoleExists("Employee")) { var role = new IdentityRole(); role.Name = "Employee"; roleManager.Create(role); } }
public EmployeeController(LeaveManagementDbContext leaveManagementDbContext) { _dbContext = leaveManagementDbContext; _empRepo = new EmployeeRepository(_dbContext); }
public LeaveInfoRepository(LeaveManagementDbContext dbContext) { _dbContext = dbContext; }
public ReportingController(LeaveManagementDbContext leaveManagementDbContext) { _dbContext = leaveManagementDbContext; _repRepo = new ReportingRepository(_dbContext); }
public RemainingHourController(LeaveManagementDbContext leaveManagementDbContext) { _dbContext = leaveManagementDbContext; _remRepo = new RemainingHourRepository(_dbContext); }
public RemainingHourRepository(LeaveManagementDbContext dbContext) { _dbContext = dbContext; }
public HRService(IEmployeeService employeeService, LeaveManagementDbContext db) { _employeeService = employeeService; _db = db; }
public Repository(LeaveManagementDbContext context) { this._context = context; }
public EmployeeRepository() { db = new LeaveManagementDbContext(); userStore = new ApplicationUserStore(db); userManager = new ApplicationUserManager(userStore); }
public LeavesController(LeaveManagementDbContext leaveInfo) { _dbContext = leaveInfo; _leaveRepo = new LeaveInfoRepository(_dbContext); }
public EmployeeRepository(LeaveManagementDbContext dbContext) { _dbContext = dbContext; }