123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- using CZFW.Framework.Logic;
- using CZFW.Framework.Model.ViewModel;
- using CZKJ.GBRS2.Entity;
- using CZKJ.GBRS2.Interface;
- using System.Linq;
- using CZFW.Framework.Model.Entity;
- using System.Collections.Generic;
- namespace CZKJ.GBRS2.Logic
- {
- public class PositionLogic : LogicBase<PositionEntity>, IPosition
- {
- public PositionEntity GetItem(int id)
- {
- var result = Queryable.Where(x => x.Id == id).Join(DbContext.Set<TypeEntity>(), x => x.TypeId, y => y.Id, (x, y) => new { x, TypeName = y.Name }).Join(DbContext.Set<DictItemEntity>(), x => x.x.DepartmentId, y => y.Id, (x, y) => new { x, Department = y.Name }).Join(DbContext.Set<DictItemEntity>(), x => x.x.x.AddressId, y => y.Id, (x, y) => new { x, Address = y.Name }).FirstOrDefault();
- return new PositionEntity
- {
- Id = result.x.x.x.Id,
- AddressId = result.x.x.x.AddressId,
- DepartmentId = result.x.x.x.DepartmentId,
- Name = result.x.x.x.Name,
- Number = result.x.x.x.Number,
- Respons = result.x.x.x.Respons,
- Requirement = result.x.x.x.Requirement,
- SeoTitle = result.x.x.x.SeoTitle,
- SeoDescription = result.x.x.x.SeoDescription,
- SeoKeywords = result.x.x.x.SeoKeywords,
- ShareDescription = result.x.x.x.ShareDescription,
- ShareImage = result.x.x.x.ShareImage,
- ShareTitle = result.x.x.x.ShareTitle,
- ShareUrl = result.x.x.x.ShareUrl,
- TypeId = result.x.x.x.TypeId,
- Address = result.Address,
- Department = result.x.Department,
- TypeName = result.x.x.TypeName
- };
- }
- public IList<PositionEntity> GetPositionList(string name, int typeId, int? addressId, int? deptId, int pageIndex, int pageSize, out int rowsCount)
- {
- var queryable = Queryable.Where(x => x.TypeId == typeId);
- if (!string.IsNullOrWhiteSpace(name))
- {
- queryable = queryable.Where(x => x.Name.Contains(name.Trim()));
- }
- if (addressId.HasValue)
- {
- queryable = queryable.Where(x => x.AddressId == addressId);
- }
- if (deptId.HasValue)
- {
- queryable = queryable.Where(x => x.DepartmentId == deptId);
- }
-
- rowsCount = queryable.Count();
- var result = queryable.OrderByDescending(x => x.SortOrder).Skip((pageIndex - 1) * pageSize).Take(pageSize);
- var data = (from x in result
- join ty in DbContext.Set<TypeEntity>() on x.TypeId equals ty.Id
- join de in DbContext.Set<DictItemEntity>() on x.DepartmentId equals de.Id
- join ci in DbContext.Set<DictItemEntity>() on x.AddressId equals ci.Id
- select new PositionEntity
- {
- Id = x.Id,
- TypeId = x.TypeId,
- TypeName = ty.Name,
- Name = x.Name,
- Number = x.Number,
- AddressId = x.AddressId,
- Address = ci.Name,
- DepartmentId = x.DepartmentId,
- Department = de.Name,
- Respons = x.Respons,
- Requirement = x.Requirement,
- SortOrder = x.SortOrder
- }).ToList();
- return data;
- }
- public IList<PositionEntity> GetPositionList(int id, int typeId, int deptId)
- {
- var queryable = Queryable.Where(x => x.Id != id && x.TypeId == typeId && x.DepartmentId == deptId);
- var data = (from x in queryable
- join ty in DbContext.Set<TypeEntity>() on x.TypeId equals ty.Id
- join de in DbContext.Set<DictItemEntity>() on x.DepartmentId equals de.Id
- join ci in DbContext.Set<DictItemEntity>() on x.AddressId equals ci.Id
- select new PositionEntity
- {
- Id = x.Id,
- TypeId = x.TypeId,
- TypeName = ty.Name,
- Name = x.Name,
- Number = x.Number,
- AddressId = x.AddressId,
- Address = ci.Name,
- DepartmentId = x.DepartmentId,
- Department = de.Name,
- Respons = x.Respons,
- Requirement = x.Requirement
- }).ToList();
- return data;
- }
- }
- }
|