public string GenerateToken(User user) { var securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(configuration["Jwt:key"])); var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256); WorkScheduleContext context = new WorkScheduleContext(); RoleRepository roleRepository = new RoleRepository(context); RoleService roleService = new RoleService(roleRepository); var expires = DateTime.Now.AddMinutes(30); var claims = new List <Claim> { new Claim(JwtRegisteredClaimNames.Email, user.Email), new Claim(JwtRegisteredClaimNames.Jti, user.Id.ToString()), new Claim(ClaimTypes.Role, roleService.GetById(user.RoleId).Name) }; var token = new JwtSecurityToken( issuer: configuration["Jwt:Issuer"], audience: configuration["Jwt:Issuer"], claims: claims, expires: expires, signingCredentials: credentials ); var tokenString = new JwtSecurityTokenHandler().WriteToken(token); return(tokenString); }
public List <Location> ListLocations() { using (WorkScheduleContext context = new WorkScheduleContext()) { return(context.Locations.ToList()); } }
public List <Skill> SkillList() { using (var context = new WorkScheduleContext()) { return(context.Skills.ToList()); } }
public void Location_Update(Location item) { using (WorkScheduleContext context = new WorkScheduleContext()) { context.Entry <Location>(context.Locations.Attach(item)).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public void AddNewLocation(Location item) { using (var context = new WorkScheduleContext()) { // Get the new stuff var added = context.Locations.Add(item); context.SaveChanges(); } }
public List <Employees> EmployeeList() { using (var context = new WorkScheduleContext()) { var results = from item in context.Employees orderby item.EmployeeID select item; return(results.ToList()); } }
public List <PlacementContracts> PCList() { using (var context = new WorkScheduleContext()) { var results = from item in context.PlacementContracts orderby item.PlacementContractID select item; return(results.ToList()); } }
public List <Location> LocationList() { using (var context = new WorkScheduleContext()) { var results = from item in context.Locations orderby item.LocationID select item; return(results.ToList()); } }
public List <Shifts> ShiftList() { using (var context = new WorkScheduleContext()) { var results = from item in context.Shifts orderby item.ShiftID select item; return(results.ToList()); } }
public void Location_Add(Location item) { using (WorkScheduleContext context = new WorkScheduleContext()) { Location added = null; added = context.Locations.Add(item); context.SaveChanges(); } }
public List <SelectionList> Skills_DDLLists() { using (var context = new WorkScheduleContext()) { IEnumerable <SelectionList> results = from x in context.Skills select new SelectionList { ValueField = x.SkillID, DisplayField = x.Description }; return(results.ToList()); } }
public List <SkillsList> SkillsList_Get(int employeeID) { using (var context = new WorkScheduleContext()) { var results = from x in context.EmployeeSkills where x.EmployeeID == employeeID select new SkillsList { ID = x.SkillID, Description = x.Skill.Description }; return(results.ToList()); } }
public void UpdateLocation(Location item) { using (var context = new WorkScheduleContext()) { // Edit current location var attached = context.Locations.Attach(item); var existing = context.Entry <Location>(attached); existing.State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public List <EmployeeNamesList> EmployeeNamesList_Get() { using (var context = new WorkScheduleContext()) { var results = from x in context.Employees orderby x.LastName select new EmployeeNamesList { ID = x.EmployeeID, Name = x.LastName + "," + x.FirstName }; return(results.ToList()); } }
public List <SkillSet> Skills_List() { using (var context = new WorkScheduleContext()) { var results = from x in context.Skills orderby x.Description select new SkillSet { SkillId = x.SkillID, Description = x.Description }; return(results.ToList()); } }
public void EmployeeSkill_Delete(int employeeskillid) { using (var context = new WorkScheduleContext()) { //example of a physical delete //retrieve the current entity instance based on the incoming parameter var exists = context.EmployeeSkills.Find(employeeskillid); //staged the remove context.EmployeeSkills.Remove(exists); //commit the remove context.SaveChanges(); //a logical delete is actually an update of the instance } }
public List <EmployeeSkillItem> EmployeesSkills_List() { using (var context = new WorkScheduleContext()) { IEnumerable <EmployeeSkillItem> results = from x in context.EmployeeSkills select new EmployeeSkillItem { EmployeeSkillID = x.EmployeeSkillID, Employee = x.Employee.LastName + ", " + x.Employee.FirstName, Skill = x.Skill.Description, Level = x.Level, YearsOfService = x.YearsOfExperience, HourlyWage = x.HourlyWage }; return(results.ToList()); } }
public List <POCOs.EmployeeSkillsMenuItem> GetReportESMenuItems() { using (WorkScheduleContext context = new WorkScheduleContext()) { var results = from cat in context.EmployeeSkills orderby cat.Skills.Description select new POCOs.EmployeeSkillsMenuItem { SkillDescription = cat.Skills.Description, FullName = cat.Employee.LastName + ", " + cat.Employee.FirstName, Phone = cat.Employee.HomePhone, Level = cat.Level.ToString(), YOE = Convert.ToInt32(cat.YearsOfExperience) }; return(results.ToList()); } }
public List <EmployeeSkillPOCO> GetReportEmployeeSkill() { using (var context = new WorkScheduleContext()) { var results = from row in context.EmployeeSkills orderby row.Skill.Description select new EmployeeSkillPOCO() { Description = row.Skill.Description, Name = row.Employee.FirstName + " " + row.Employee.LastName, Phone = row.Employee.HomePhone, Level = row.Level.ToString(), YearsExperience = row.YearsOfExperience }; return(results.ToList()); } }
public List <SkillCategoryEmployee> GetReportEmployeeSkill() { using (var context = new WorkScheduleContext()) { var results = from x in context.EmployeeSkills orderby x.Skill.Description select new SkillCategoryEmployee { Skill = x.Skill.Description, Name = x.Employee.LastName + ", " + x.Employee.FirstName, Phone = x.Employee.HomePhone, Level = x.Level == 1? "Novice": x.Level == 2? "Proficent": "Expert", YOE = x.YearsOfExperience }; return(results.ToList()); } }
public List <SkillEmployee> Employees_GetBySkill(int skillId) { using (var context = new WorkScheduleContext()) { var results = from x in context.EmployeeSkills where x.Skill.SkillID == skillId select new SkillEmployee { FirstName = x.Employee.FirstName, LastName = x.Employee.LastName, HomePhone = x.Employee.HomePhone, Active = x.Employee.Active, Level = x.Level, YearsOfExperience = x.YearsOfExperience }; return(results.ToList()); } }
public void EmployeeSkill_Update(EmployeeSkillItem item) { using (var context = new WorkScheduleContext()) { EmployeeSkill updateItem = new EmployeeSkill { //for an update, you need to supply your PK value EmployeeSkillID = item.EmployeeSkillID, EmployeeID = item.EmployeeID, SkillID = item.SkillID, Level = item.Level, YearsOfExperience = item.YearsOfService, HourlyWage = item.HourlyWage }; context.Entry(updateItem).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public List <EmployeeSkillVM> Employees_GetEmployeesFromSkill(int skillid) { using (var context = new WorkScheduleContext()) { IEnumerable <EmployeeSkillVM> results = from x in context.EmployeeSkills where x.SkillID == skillid select new EmployeeSkillVM { //FullName = x.Employee.FullName, FullName = x.Employee.LastName + ", " + x.Employee.FirstName, HomePhone = x.Employee.HomePhone, Active = x.Employee.Active, Level = x.Level, YearsOfExperience = x.YearsOfExperience, SkillID = x.SkillID }; return(results.ToList()); } }
public void Register_Employee(Employee employee, List <SkillSet> skillset) { using (var context = new WorkScheduleContext()) { Employee newEmployee = new Employee(); newEmployee.FirstName = employee.FirstName; newEmployee.LastName = employee.LastName; newEmployee.HomePhone = employee.HomePhone; newEmployee = context.Employees.Add(newEmployee); foreach (var skill in skillset) { EmployeeSkill newEmployeeSkill = new EmployeeSkill(); newEmployeeSkill.EmployeeID = newEmployee.EmployeeID; newEmployeeSkill.HourlyWage = skill.HourlyWage; newEmployeeSkill.Level = skill.Level; newEmployeeSkill.YearsOfExperience = skill.YOE; newEmployeeSkill = context.EmployeeSkills.Add(newEmployeeSkill); } } }
public EmployeeSkillItem EmployeesSkills_FindById(int employeeskillid) //this is just a single record thats why List<> and IEnumerable<> is not used { using (var context = new WorkScheduleContext()) { // (...).FirstOrDefault will return either // a) the first record matching the where condition // b) a null value EmployeeSkillItem results = (from x in context.EmployeeSkills where x.EmployeeSkillID == employeeskillid select new EmployeeSkillItem { EmployeeSkillID = x.EmployeeSkillID, Employee = x.Employee.LastName + ", " + x.Employee.FirstName, Skill = x.Skill.Description, Level = x.Level, YearsOfService = x.YearsOfExperience, HourlyWage = x.HourlyWage }).FirstOrDefault(); return(results); } }
public int EmployeeSkill_Add(EmployeeSkillItem item) // this will return PK { using (var context = new WorkScheduleContext()) { EmployeeSkill addItem = new EmployeeSkill { //why no PK set? //PK is an identity PK, no value is needed //However, if PK is NOT an identity spec(Identity Specification = No in the DB), ADD PK here!!! EmployeeID = item.EmployeeID, SkillID = item.SkillID, Level = item.Level, YearsOfExperience = item.YearsOfService, HourlyWage = item.HourlyWage }; context.EmployeeSkills.Add(addItem); context.SaveChanges(); return(addItem.EmployeeSkillID); } }
public ShiftTypeRepository(WorkScheduleContext context) : base(context) { }
public JobScheduleRepository(WorkScheduleContext context) { _workScheduleContext = context; }
public PersonShiftRepository(WorkScheduleContext context) : base(context) { }
public WorkScheduleItemRepository(WorkScheduleContext context) { _workScheduleContext = context; }