public async Task <int> CreateAsync(Employee employee) { using var context = new AotDBContext(); await context.Employee.AddAsync(employee); return(await context.SaveChangesAsync()); }
public async Task <int> CreateAsync(Skill skill) { using var context = new AotDBContext(); await context.Skill.AddAsync(skill); return(await context.SaveChangesAsync()); }
public async Task <int> CreateAsync(Entities.User user) { using var context = new AotDBContext(); await context.User.AddAsync(user); return(await context.SaveChangesAsync()); }
public IList <Skill> GetAll() { var skills = new List <Skill>(); using var context = new AotDBContext(); skills = context.Skill.ToList(); return(skills); }
public IList <EmployeeSkill> GetBySkillId(string skillId) { using var context = new AotDBContext(); return((from empSkills in context.EmployeeSkills join emp in context.Employee on empSkills.EmployeeId equals emp.Id where empSkills.SkillId == skillId select new EmployeeSkill { Id = empSkills.Id, Employee = emp })?.ToList()); }
public IList <EmployeeSkill> GetByEmployeeId(string employeeId) { using var context = new AotDBContext(); return((from empSkills in context.EmployeeSkills join skl in context.Skill on empSkills.SkillId equals skl.Id where empSkills.EmployeeId == employeeId select new EmployeeSkill { Id = empSkills.Id, Skill = skl })?.ToList()); }
public async Task <int> CreateManyAsync(List <Entities.EmployeeSkill> employeeSkills) { using var context = new AotDBContext(); var currentSkills = context.EmployeeSkills.Where(x => x.EmployeeId == employeeSkills.First().EmployeeId); context.EmployeeSkills.RemoveRange(currentSkills); foreach (var employeeSkill in employeeSkills) { await context.EmployeeSkills.AddAsync(employeeSkill); } return(await context.SaveChangesAsync()); }
public static void Initialize(string hashKey) { using (var context = new AotDBContext()) { context.Database.EnsureCreated(); if (!context.User.Any(x => x.Username == "admin")) { var employeeId = Guid.NewGuid().ToString(); context.Employee.Add(new Entities.Employee { Id = employeeId, CreatedBy = employeeId, CreateOn = DateTime.Now, Email = "*****@*****.**", IsActive = true, IsAdmin = true, Name = "admin", IsEmailVerified = true }); var userId = Guid.NewGuid().ToString(); var username = "******"; var password = CryptoHelper.Hash(userId + username, hashKey); context.User.Add(new Entities.User { Id = userId, CreatedBy = employeeId, CreateOn = DateTime.Now, EmployeeId = employeeId, IsActive = true, Name = username, Username = username, Password = password, Email = "*****@*****.**" }); } context.SaveChanges(); } }
public Skill GetSkillByTitle(string title) { using var context = new AotDBContext(); return(context.Skill.SingleOrDefault(x => x.Title.ToLower() == title.ToLower())); }
public Employee GetByEmail(string email) { using var context = new AotDBContext(); return(context.Employee.SingleOrDefault(x => x.Email == email)); }
public Employee GetById(string id) { using var context = new AotDBContext(); return(context.Employee.SingleOrDefault(x => x.Id == id && x.IsActive)); }
public async Task <int> UpdateAsync(EmployeeSkill employeeSkill) { using var context = new AotDBContext(); context.EmployeeSkills.Update(employeeSkill); return(await context.SaveChangesAsync()); }
public User GetUserByUsername(string username) { using var context = new AotDBContext(); return(context.User.SingleOrDefault(x => x.Username.ToLower() == username.ToLower())); }
public User GetUserByEmployeeId(string employeeId) { using var context = new AotDBContext(); return(context.User.SingleOrDefault(x => x.EmployeeId == employeeId)); }
public Entities.User GetUser(string username, string password) { using var context = new AotDBContext(); return(context.User.SingleOrDefault(x => x.Username.ToLower() == username.ToLower() && x.Password == password)); }