Пример #1
0
        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);
        }
Пример #2
0
 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());
     }
 }
Пример #4
0
        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();
            }
        }
Пример #5
0
        public void AddNewLocation(Location item)
        {
            using (var context = new WorkScheduleContext())
            {
                // Get the new stuff
                var added = context.Locations.Add(item);

                context.SaveChanges();
            }
        }
Пример #6
0
 public List <Employees> EmployeeList()
 {
     using (var context = new WorkScheduleContext())
     {
         var results = from item in context.Employees
                       orderby item.EmployeeID
                       select item;
         return(results.ToList());
     }
 }
Пример #7
0
 public List <PlacementContracts> PCList()
 {
     using (var context = new WorkScheduleContext())
     {
         var results = from item in context.PlacementContracts
                       orderby item.PlacementContractID
                       select item;
         return(results.ToList());
     }
 }
Пример #8
0
 public List <Location> LocationList()
 {
     using (var context = new WorkScheduleContext())
     {
         var results = from item in context.Locations
                       orderby item.LocationID
                       select item;
         return(results.ToList());
     }
 }
Пример #9
0
 public List <Shifts> ShiftList()
 {
     using (var context = new WorkScheduleContext())
     {
         var results = from item in context.Shifts
                       orderby item.ShiftID
                       select item;
         return(results.ToList());
     }
 }
Пример #10
0
        public void Location_Add(Location item)
        {
            using (WorkScheduleContext context = new WorkScheduleContext())
            {
                Location added = null;

                added = context.Locations.Add(item);

                context.SaveChanges();
            }
        }
Пример #11
0
 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());
     }
 }
Пример #12
0
 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());
     }
 }
Пример #13
0
        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();
            }
        }
Пример #14
0
 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());
            }
        }
Пример #16
0
        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
            }
        }
Пример #17
0
 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());
     }
 }
Пример #18
0
 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());
     }
 }
Пример #19
0
 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());
     }
 }
Пример #20
0
        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());
            }
        }
Пример #21
0
        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());
            }
        }
Пример #22
0
        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();
            }
        }
Пример #23
0
 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());
     }
 }
Пример #24
0
        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);
                }
            }
        }
Пример #25
0
 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);
     }
 }
Пример #26
0
        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);
            }
        }
Пример #27
0
 public ShiftTypeRepository(WorkScheduleContext context)
     : base(context)
 {
 }
Пример #28
0
 public JobScheduleRepository(WorkScheduleContext context)
 {
     _workScheduleContext = context;
 }
Пример #29
0
 public PersonShiftRepository(WorkScheduleContext context)
     : base(context)
 {
 }
Пример #30
0
 public WorkScheduleItemRepository(WorkScheduleContext context)
 {
     _workScheduleContext = context;
 }