public IEnumerable <userRole> GetAllUserRoles() { using (IOPContext db = new IOPContext()) { UserRoleConverter converter = new UserRoleConverter(db); var list = db.UserRoles.ToList(); return(list.Select(p => converter.ToDto(p))); } }
public IEnumerable <department> GetDepartmentTree() { using (IOPContext cxt = new IOPContext()) { List <Department> departments = cxt.Departments.ToList(); DepartmentConverter depCvt = new DepartmentConverter(cxt); return(depCvt.ConvertToDtoTree(departments)); } }
public int AddJobPositionLevels(IEnumerable <jobPositionLevel> items) { using (IOPContext db = new IOPContext()) { JobPositionLevelConverter converter = new JobPositionLevelConverter(db); IEnumerable <JobPostionLevel> list = items.Select(p => converter.FromDto(p)); db.JobPositionLevels.AddRange(list); return(db.SaveChanges()); } }
public void AddEmployee() { using (IOPContext context = new IOPContext()) { context.Employees.Add(new Employee { Id = Guid.NewGuid().ToString(), Name = "张三", Department = null }); context.SaveChanges(); } }
public int AddHireTypes(IEnumerable <hireType> items) { using (IOPContext db = new IOPContext()) { HireTypeConverter converter = new HireTypeConverter(db); IEnumerable <HireType> list = items.Select(p => converter.FromDto(p)); db.HireTypes.AddRange(list); return(db.SaveChanges()); } }
public IEnumerable <jobPositionLevel> GetAllJobPositionLevels() { using (IOPContext db = new IOPContext()) { JobPositionLevelConverter converter = new JobPositionLevelConverter(db); var items = db.JobPositionLevels.ToList(); ICollection <jobPositionLevel> list = items.Select(p => converter.ToDto(p)).ToList(); return(list); } }
public IEnumerable <hireType> GetAllHireTypes() { using (IOPContext db = new IOPContext()) { HireTypeConverter converter = new HireTypeConverter(db); var hireTypes = db.HireTypes.ToList(); ICollection <hireType> list = hireTypes.Select(p => converter.ToDto(p)).ToList(); return(list); } }
public void AddDepartment() { using (IOPContext context = new IOPContext()) { Department d = new Department(); d.Description = "键身房门店"; d.Id = Guid.NewGuid().ToString(); d.Name = "金奥健身房"; context.Departments.Add(d); context.SaveChanges(); } }
public int UpdateJobTypes(IEnumerable <jobType> jobTypes) { using (IOPContext db = new IOPContext()) { JobTypeConverter jtC = new JobTypeConverter(db); foreach (var jt in jobTypes) { var model = jtC.FromDto(jt); db.Entry(model).State = System.Data.Entity.EntityState.Modified; } return(db.SaveChanges()); } }
public int UpdateVipCards(IEnumerable <vipCard> items) { using (IOPContext db = new IOPContext()) { VipCardConverter converter = new VipCardConverter(db); foreach (var item in items) { var model = converter.FromDto(item); db.Entry(model).State = System.Data.Entity.EntityState.Modified; } return(db.SaveChanges()); } }
public int UpdateJobPositionLevels(IEnumerable <jobPositionLevel> items) { using (IOPContext db = new IOPContext()) { JobPositionLevelConverter converter = new JobPositionLevelConverter(db); foreach (var item in items) { var model = converter.FromDto(item); db.Entry(model).State = System.Data.Entity.EntityState.Modified; } return(db.SaveChanges()); } }
public int DeleteUserRoles(IEnumerable <userRole> items) { using (IOPContext db = new IOPContext()) { UserRoleConverter converter = new UserRoleConverter(db); foreach (var item in items) { var model = converter.FromDto(item); db.Entry(model).State = System.Data.Entity.EntityState.Deleted; } return(db.SaveChanges()); } }
public int AddEmployees(IEnumerable <employee> items) { using (IOPContext db = new IOPContext()) { EmployeeConverter converter = new EmployeeConverter(db); foreach (var item in items) { var model = converter.FromDto(item); db.Entry(model).State = System.Data.Entity.EntityState.Added; } return(db.SaveChanges()); } }
public IEnumerable <vipCard> GetAllVipCards() { using (IOPContext db = new IOPContext()) { List <VipCard> list = db.VipCards.ToList(); ICollection <vipCard> items = new List <vipCard>(); VipCardConverter converter = new VipCardConverter(db); foreach (var item in list) { var dto = converter.ToDto(item); items.Add(dto); } return(items); } }
public int AddJobTypes(IEnumerable <jobType> jobTypes) { using (IOPContext db = new IOPContext()) { List <JobType> jtList = new List <JobType>(); JobTypeConverter jtC = new JobTypeConverter(db); foreach (var jt in jobTypes) { var model = jtC.FromDto(jt); jtList.Add(model); } db.JobTypes.AddRange(jtList); return(db.SaveChanges()); } }
public int DeleteVipCards(IEnumerable <string> Ids) { using (IOPContext db = new IOPContext()) { foreach (var id in Ids) { var model = db.VipCards.Find(id); if (model != null) { db.Entry(model).State = System.Data.Entity.EntityState.Deleted; } } return(db.SaveChanges()); } }
public int AddVipCards(IEnumerable <vipCard> items) { using (IOPContext db = new IOPContext()) { List <VipCard> list = new List <VipCard>(); VipCardConverter converter = new VipCardConverter(db); foreach (var item in items) { var model = converter.FromDto(item); list.Add(model); } db.VipCards.AddRange(list); return(db.SaveChanges()); } }
public IEnumerable <jobType> GetAllJobTypes() { using (IOPContext db = new IOPContext()) { List <JobType> jtList = db.JobTypes.ToList(); ICollection <jobType> jobTypes = new List <jobType>(); JobTypeConverter jtC = new JobTypeConverter(db); foreach (var jt in jtList) { var dto = jtC.ToDto(jt); jobTypes.Add(dto); } return(jobTypes); } }
/// <summary> /// /// </summary> /// <param name="departments"></param> /// <param name="recursive">是否把所有子级的也删除</param> /// <returns></returns> public int DeleteDepartments(ICollection <department> departments, bool recursive) { using (IOPContext cxt = new IOPContext()) { foreach (var item in departments) { Department d = cxt.Departments.Find(item.id); if (d == null) { continue; } DeleteDepartment(cxt, d, recursive); } return(cxt.SaveChanges()); } }
public int UpdateDepartments(department[] departments) { if (departments == null) { return(0); } using (IOPContext cxt = new IOPContext()) { DepartmentConverter depCvt = new DepartmentConverter(cxt); foreach (var d in departments) { Department dep = depCvt.FromDto(d, cxt.Departments.Find(d.id)); cxt.Entry(dep).State = System.Data.Entity.EntityState.Modified; } return(cxt.SaveChanges()); } }
public resultForEmployees QueryEmployees(criteriaForEmployees criteria) { using (IOPContext db = new IOPContext()) { int pageSize = criteria.pageSize; int pageIndex = criteria.pageIndex; criteria.employeeCode = criteria.employeeCode == null ? "" : criteria.employeeCode; criteria.employeeName = criteria.employeeName == null ? "" : criteria.employeeName; int totalCount = 0; EmployeeConverter converter = new EmployeeConverter(db); IList <Employee> list = Utils.LoadPageItems <Employee, string>(db, pageSize, pageIndex, out totalCount, e => e.Code.Contains(criteria.employeeCode) && e.Name.Contains(criteria.employeeName), e => e.Code, true).ToList(); resultForEmployees result = new resultForEmployees(); result.employees = list.Select(i => converter.ToDto(i)).ToArray(); result.totalCount = totalCount; result.currentIndex = result.currentIndex; return(result); } }
public resultForCustomers QueryCustomers(criteriaForCustomer criteria) { using (IOPContext db = new IOPContext()) { int pageSize = criteria.pageSize; int pageIndex = criteria.pageIndex; criteria.customerCode = criteria.customerCode == null ? "" : criteria.customerCode; criteria.customerName = criteria.customerName == null ? "" : criteria.customerName; int totalCount = 0; CustomerConverter converter = new CustomerConverter(db); IList <Customer> list = Utils.LoadPageItems <Customer, string>(db, pageSize, pageIndex, out totalCount, e => e.Code.Contains(criteria.customerCode) && e.Name.Contains(criteria.customerName) && (criteria.customerType & e.CustomerType) > 0, e => e.Code, true).ToList(); resultForCustomers result = new resultForCustomers(); result.customers = list.Select(i => converter.ToDto(i)).ToArray(); result.totalCount = totalCount; result.currentIndex = result.currentIndex; return(result); } }
public int AddDepartments(IEnumerable <department> departments) { if (departments == null) { return(0); } using (IOPContext cxt = new IOPContext()) { List <Department> dList = new List <Department>(); DepartmentConverter depCvt = new DepartmentConverter(cxt); foreach (var d in departments) { Department dep = depCvt.FromDto(d); dList.Add(dep); } cxt.Departments.AddRange(dList); return(cxt.SaveChanges()); } }
private void DeleteDepartment(IOPContext cxt, Department d, bool recursive) { cxt.JobPositions.RemoveRange(d.JobPositions); if (recursive) { if (d.SubDepartments.Count() > 0) { var items = d.SubDepartments.ToArray(); foreach (var item in items) { DeleteDepartment(cxt, item, recursive); } } } else { d.SubDepartments.Clear(); } cxt.Entry(d).State = System.Data.Entity.EntityState.Deleted; }
/// <summary> /// 分页查询 + 条件查询 + 排序 /// </summary> /// <typeparam name="Tkey">泛型</typeparam> /// <param name="pageSize">每页大小</param> /// <param name="pageIndex">当前页码</param> /// <param name="total">总数量</param> /// <param name="whereLambda">查询条件</param> /// <param name="orderbyLambda">排序条件</param> /// <param name="isAsc">是否升序</param> /// <returns>IQueryable 泛型集合</returns> public static IEnumerable <T> LoadPageItems <T, Tkey>(IOPContext context, int pageSize, int pageIndex, out int total, Expression <Func <T, bool> > whereLambda, Func <T, Tkey> orderbyLambda, bool isAsc) where T : EntityBase { total = context.Set <T>().Where(whereLambda).Count(); if (isAsc) { var temp = context.Set <T>().Where(whereLambda) .OrderBy <T, Tkey>(orderbyLambda) .Skip(pageSize * (pageIndex - 1)) .Take(pageSize); return(temp); } else { var temp = context.Set <T>().Where(whereLambda) .OrderByDescending <T, Tkey>(orderbyLambda) .Skip(pageSize * (pageIndex - 1)) .Take(pageSize); return(temp); } }
public ConverterBase(IOPContext ctx) { DbContext = ctx; }
public VipCardConverter(IOPContext ctx) : base(ctx) { }
public UserRoleConverter(IOPContext ctx) : base(ctx) { }
public HireTypeConverter(IOPContext ctx) : base(ctx) { }
public DepartmentConverter(IOPContext ctx) : base(ctx) { }