Example #1
0
 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)));
     }
 }
Example #2
0
 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());
     }
 }
Example #4
0
 public void AddEmployee()
 {
     using (IOPContext context = new IOPContext())
     {
         context.Employees.Add(new Employee {
             Id = Guid.NewGuid().ToString(), Name = "张三", Department = null
         });
         context.SaveChanges();
     }
 }
Example #5
0
 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);
     }
 }
Example #7
0
 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);
     }
 }
Example #8
0
 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();
     }
 }
Example #9
0
 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());
     }
 }
Example #10
0
 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());
     }
 }
Example #12
0
 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());
     }
 }
Example #13
0
 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());
     }
 }
Example #14
0
 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);
     }
 }
Example #15
0
 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());
     }
 }
Example #16
0
 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());
     }
 }
Example #17
0
 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());
     }
 }
Example #18
0
 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);
     }
 }
Example #19
0
 /// <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());
     }
 }
Example #20
0
 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());
     }
 }
Example #21
0
 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);
     }
 }
Example #22
0
 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);
     }
 }
Example #23
0
 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());
     }
 }
Example #24
0
 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;
 }
Example #25
0
 /// <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);
     }
 }
Example #26
0
 public ConverterBase(IOPContext ctx)
 {
     DbContext = ctx;
 }
Example #27
0
 public VipCardConverter(IOPContext ctx) : base(ctx)
 {
 }
Example #28
0
 public UserRoleConverter(IOPContext ctx) : base(ctx)
 {
 }
Example #29
0
 public HireTypeConverter(IOPContext ctx) : base(ctx)
 {
 }
Example #30
0
 public DepartmentConverter(IOPContext ctx) : base(ctx)
 {
 }