public long GetTotalCount(long cityId, string status)
 {
     using (MyDbContext ctx = new MyDbContext())
     {
         BaseService <HouseAppointmentEntity> bs
             = new BaseService <HouseAppointmentEntity>(ctx);
         var count = bs.GetAll().LongCount(c => c.House.Communitie.Region.CityId == cityId && c.Status == status);
         return(count);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 获取指定城市的管理员
 /// </summary>
 /// <param name="cityId">如果为null则获取总部管理员;否则获取某个地区的</param>
 /// <returns></returns>
 public AdminUserDTO[] GetAll(long?cityId)
 {
     using (ZSZDbContext ctx = new ZSZDbContext())
     {
         BaseService <AdminUserEntity> bs = new BaseService <AdminUserEntity>(ctx);
         var all = bs.GetAll().Include(u => u.City)
                   .AsNoTracking().Where(u => u.CityId == cityId);
         return(all.ToList().Select(u => ToDTO(u)).ToArray());
     }
 }
Ejemplo n.º 3
0
 public IdNameDTO[] GetAll(string typeName)
 {
     using (ZSZDbContext ctx = new ZSZDbContext())
     {
         BaseService <IdNameEntity> bs
             = new BaseService <IdNameEntity>(ctx);
         return(bs.GetAll().Where(e => e.TypeName == typeName)
                .ToList().Select(e => ToDTO(e)).ToArray());
     }
 }
Ejemplo n.º 4
0
 public long GetCount(long cityId, DateTime startDateTome, DateTime endDateTime)
 {
     using (MyDbContext ctx = new MyDbContext())
     {
         BaseService <HouseEntity> houseBs = new BaseService <HouseEntity>(ctx);
         return(houseBs.GetAll().Count(h => h.Communitie.Region.CityId == cityId &&
                                       h.CreateDateTime >= startDateTome &&
                                       h.CreateDateTime <= endDateTime));
     }
 }
Ejemplo n.º 5
0
 public int GetTodayNewHouseCount(long cityId)
 {
     using (var ctx = new ZSZDbContext())
     {
         BaseService <HouseEntity> bs = new BaseService <HouseEntity>(ctx);
         return(bs.GetAll().Where(p => p.Community.Region.CityId == cityId &&
                                  SqlFunctions.DateDiff("hh", p.CreateDateTime, DateTime.Now) <= 24)
                .Count());
     }
 }
Ejemplo n.º 6
0
 public CityDTO[] GetAll()
 {
     using (ZSZDbContext ctx = new ZSZDbContext())
     {
         BaseService <CityEntity> bs
             = new BaseService <CityEntity>(ctx);
         return(bs.GetAll().AsNoTracking().ToList()
                .Select(c => ToDTO(c)).ToArray());
     }
 }
Ejemplo n.º 7
0
 public AttachmentDTO[] GetAll()
 {
     using (ZSZDbContext ctx = new ZSZDbContext())
     {
         BaseService <AttachmentEntity> bs
             = new BaseService <AttachmentEntity>(ctx);
         var items = bs.GetAll().AsNoTracking();
         return(items.ToList().Select(a => ToDTO(a)).ToArray());
     }
 }
Ejemplo n.º 8
0
 public IdNameDTO[] GetAll(string typeName)
 {
     using (MyDbContext ctx = new MyDbContext())
     {
         BaseService <IdNameEntity> bs
             = new BaseService <IdNameEntity>(ctx);
         return(bs.GetAll().Where(e => e.TypeName == typeName)
                .ToList().Select(e => ToDTO(e)).ToArray());
         //EF有可能翻译不成SQL语句,通过ToList拿到内存中操作。
     }
 }
Ejemplo n.º 9
0
 public bool CheckLogin(string phoneNum, string password)
 {
     using (ZSZDbContext ctx = new ZSZDbContext())
     {
         BaseService <UserEntity> bs = new BaseService <UserEntity>(ctx);
         var theuser = bs.GetAll().ToList();
         var user    = bs.GetAll().SingleOrDefault(u => u.PhoneNum == phoneNum);
         if (user == null)
         {
             return(false);
         }
         else
         {
             string dbPwdHash   = user.PasswordHash;
             string salt        = user.PasswordSalt;
             string userPwdHash = CommonHelper.CalcMD5(salt + password);
             return(dbPwdHash == userPwdHash);
         }
     }
 }
Ejemplo n.º 10
0
 public AdminUserDTO[] GetAll()
 {
     using (ZSZDbContext ctx = new ZSZDbContext())
     {
         //using System.Data.Entity;才能在IQueryable中用Include、AsNoTracking
         BaseService <AdminUserEntity> bs
             = new BaseService <AdminUserEntity>(ctx);
         return(bs.GetAll().Include(u => u.City)
                .AsNoTracking().ToList().Select(u => ToDTO(u)).ToArray());
     }
 }
Ejemplo n.º 11
0
 public CityDTO[] GetAll()
 {
     using (ZSZDbContext context = new ZSZDbContext())
     {
         BaseService <CityEntity> service = new BaseService <CityEntity>(context);
         return(service.GetAll().AsNoTracking().Select(p => new CityDTO {
             Name = p.Name,
             Id = p.Id
         }).ToArray());
     }
 }
Ejemplo n.º 12
0
 /// <summary>
 /// 通过城市id获得所有的区域
 /// </summary>
 /// <param name="cityId"></param>
 /// <returns></returns>
 public RegionDTO[] GetAll(long cityId)
 {
     using (ZSZDbContext ctx = new ZSZDbContext())
     {
         BaseService <RegionEntity> bs
             = new BaseService <RegionEntity>(ctx);
         return(bs.GetAll().Include(r => r.City)
                .Where(r => r.CityId == cityId).ToList()
                .Select(r => ToDTO(r)).ToArray());
     }
 }
Ejemplo n.º 13
0
 public RegionDTO GetById(long id)
 {
     using (MyDbContext ctx = new MyDbContext())
     {
         BaseService <RegionEntity> bs
             = new BaseService <RegionEntity>(ctx);
         var region = bs.GetAll().Include(r => r.City)
                      .SingleOrDefault(r => r.Id == id);
         return(region == null ? null : ToDTO(region));
     }
 }
Ejemplo n.º 14
0
 public long GetTotalCount(long cityId, string status)
 {
     using (ZSZDbContext ctx = new ZSZDbContext())
     {
         BaseService <HouseAppointmentEntity> bs
             = new BaseService <HouseAppointmentEntity>(ctx);
         var count = bs.GetAll()
                     //Where(a => a.House.Community.Region.CityId == cityId && a.Status == status).LongCount()
                     .LongCount(a => a.House.Community.Region.CityId == cityId && a.Status == status);
         return(count);
     }
 }
Ejemplo n.º 15
0
 //获得某一城市管理员
 //如果为null就获取总部管理员
 //否则就是某个地区的
 public AdminUserDTO[] GetAll(long?cityId)
 {
     //如果ciityid为null会翻译成city is null??;city=3
     using (MyDbContext ctx = new MyDbContext())
     {
         BaseService <AdminUserEntity> bs = new BaseService <AdminUserEntity>(ctx);
         var all = bs.GetAll().Include(u => u.City)
                   .AsNoTracking().Where(u => u.CityId == cityId);
         return(all.ToList().Select(u => ToDto(u)).ToArray());
         //EF有可能翻译不成SQL语句,通过ToList拿到内存中操作。
     }
 }
Ejemplo n.º 16
0
 public AttachementDTO[] GetAll()
 {
     using (MyDbContext ctx = new MyDbContext())
     {
         BaseService <AttachmentEntity> bs = new BaseService <AttachmentEntity>(ctx);
         var items = bs.GetAll().AsNoTracking();
         //asnotracking数据只用于显示
         //return items.Select(a => ToDTO(a)).ToArray();
         return(items.ToList().Select(a => ToDTO(a)).ToArray());
         //EF有可能翻译不成SQL语句,通过ToList拿到内存中操作。
     }
 }
Ejemplo n.º 17
0
 public RegionDTO[] GetAll(long cityId)
 {
     using (MyDbContext ctx = new MyDbContext())
     {
         BaseService <RegionEntity> bs
             = new BaseService <RegionEntity>(ctx);
         return(bs.GetAll().Include(r => r.City)
                .Where(r => r.CityId == cityId).ToList()
                .Select(r => ToDTO(r)).ToArray());
         //EF有可能翻译不成SQL语句,通过ToList拿到内存中操作。
     }
 }
Ejemplo n.º 18
0
 public RoleDTO GetByName(string name)
 {
     using (ZSZDbContext ctx = new ZSZDbContext())
     {
         BaseService <RoleEntity> userBs = new BaseService <RoleEntity>(ctx);
         var user = userBs.GetAll().SingleOrDefault(r => r.Name == name);
         if (user == null)
         {
             return(null);
         }
         return(ToDTO(user));
     }
 }
Ejemplo n.º 19
0
 public bool HasPermission(long adminUserId, string permissionName)
 {
     using (ZSZDbContext ctx = new ZSZDbContext())
     {
         BaseService <AdminUserEntity> bs = new BaseService <AdminUserEntity>(ctx);
         var user = bs.GetAll().Include(a => a.Roles).AsNoTracking().SingleOrDefault(a => a.Id == adminUserId);
         if (user == null)
         {
             throw new ArgumentException("找不到id=" + adminUserId + "的用户");
         }
         return(user.Roles.SelectMany(r => r.Permissions).Any(p => p.Name == permissionName));
     }
 }
Ejemplo n.º 20
0
 public long GetTotalCount(string keyWords)
 {
     using (ZSZContext zsz = new ZSZContext())
     {
         BaseService <AdminUserEntity> bsAdmin = new BaseService <AdminUserEntity>(zsz);
         if (!string.IsNullOrEmpty(keyWords))
         {
             var list = bsAdmin.GetAll().Where(e => e.Name.Contains(keyWords) || e.PhoneNum.Contains(keyWords));
             return(list.LongCount());
         }
         return(bsAdmin.GetTotalCount());
     }
 }
Ejemplo n.º 21
0
 /// <summary>
 /// 根据id获取AdminUserDTO
 /// </summary>
 /// <param name="id">id</param>
 /// <returns></returns>
 public AdminUserDTO GetById(long id)
 {
     using (ZSZDbContext ctx = new ZSZDbContext())
     {
         BaseService <AdminUserEntity> service = new BaseService <AdminUserEntity>(ctx);
         AdminUserEntity user = service.GetAll().Include(u => u.City).AsNoTracking().SingleOrDefault(u => u.Id == id);
         if (user == null)
         {
             return(null);
         }
         return(ToDTO(user));
     }
 }
Ejemplo n.º 22
0
 public HouseAppointmentDTO[] GetPagedData(long cityId, string status, int pageSize, int currentIndex)
 {
     using (ZSZDbContext ctx = new ZSZDbContext())
     {
         BaseService <HouseAppointmentEntity> bs = new BaseService <HouseAppointmentEntity>(ctx);
         var apps = bs.GetAll().Include(a => a.House).Include(nameof(HouseAppointmentEntity.House) + "." + nameof(HouseEntity.Community))
                    .Include(a => a.FollowAdminUser).
                    Include(a => a.FollowAdminUser).Include(nameof(HouseAppointmentEntity.House) + "." + nameof(HouseEntity.Community) + "." + nameof(CommunityEntity.Region))
                    .AsNoTracking().Where(a => a.House.Community.Region.CityId == cityId && a.Status == status)
                    .OrderByDescending(a => a.CreateDateTime).Skip(currentIndex).Take(pageSize);//skip之前要先排序
         return(apps.ToList().Select(a => ToDTO(a)).ToArray());
     }
 }
Ejemplo n.º 23
0
 //获得所有管理员
 public AdminUserDTO[] GetAll()
 {
     //using System.Data.Entity;才能在IQuerable中用Include
     //关联属性会引发延迟加载,通过Include避免延迟加载
     //asnotracking:取出来的数据只是显示,不用修改可稍微调高性能
     using (MyDbContext ctx = new MyDbContext())
     {
         BaseService <AdminUserEntity> bs = new BaseService <AdminUserEntity>(ctx);
         return(bs.GetAll().Include(u => u.City).AsNoTracking()
                .ToList().Select(u => ToDto(u)).ToArray());
         //EF有可能翻译不成SQL语句,通过ToList拿到内存中操作。
     }
 }
Ejemplo n.º 24
0
 public AttachmentDTO[] GetAttachments(long houseId)
 {
     using (ZSZDbContext ctx = new Service.ZSZDbContext())
     {
         BaseService <HouseEntity> bs = new BaseService <HouseEntity>(ctx);
         var house = bs.GetAll().Include(h => h.Attachments).AsNoTracking().SingleOrDefault(h => h.Id == houseId);
         if (house == null)
         {
             throw new ArgumentException("houseId" + houseId + "不存在");
         }
         return(house.Attachments.ToList().Select(a => ToDTO(a)).ToArray());
     }
 }
Ejemplo n.º 25
0
 public HouseDTO GetById(long id)
 {
     using (ZSZDbContext ctx = new ZSZDbContext())
     {
         BaseService <HouseEntity> service = new BaseService <HouseEntity>(ctx);
         var house = service.GetAll().Include(u => u.Attachments).Include(h => h.Community).Include(nameof(HouseEntity.Community) + "." + nameof(CommunityEntity.Region) + "." + nameof(RegionEntity.City)).Include(nameof(HouseEntity.Community) + "." + nameof(CommunityEntity.Region)).Include(h => h.DecorateStatus).Include(h => h.RoomType).Include(h => h.Status).Include(h => h.Type).Include(h => h.HousePics).SingleOrDefault(u => u.Id == id);
         if (house == null)
         {
             return(null);
         }
         return(ToDTO(house));
     }
 }
Ejemplo n.º 26
0
 public AttachmentDTO[] GetAttachments(long houseId)
 {
     using (var ctx = new ZSZDbContext())
     {
         var bs    = new BaseService <HouseEntity>(ctx);
         var house = bs.GetAll().Include(p => p.Attachments)
                     .AsNoTracking().SingleOrDefault();
         if (house == null)
         {
             throw new ArgumentException($"House:{houseId}不存在");
         }
         return(house.Attachments.Select(p => ToDTO(p)).ToArray());
     }
 }
Ejemplo n.º 27
0
 public SettingDTO[] GetAll()
 {
     using (ZSZDbContext context = new ZSZDbContext())
     {
         BaseService <SettingEntity> service = new BaseService <SettingEntity>(context);
         return(service.GetAll().AsNoTracking().Select(p => new SettingDTO
         {
             Id = p.Id,
             CreateDateTime = p.CreateDateTime,
             Name = p.Name,
             Value = p.Value
         }).ToArray());
     }
 }
Ejemplo n.º 28
0
        public AdminUserDTO[] GetAllAdmin(int pageSize, int currentIndex, string keyWords)
        {
            using (ZSZContext context = new ZSZContext())
            {
                BaseService <AdminUserEntity> adbs = new BaseService <AdminUserEntity>(context);
                var items = adbs.GetAll();
                if (!string.IsNullOrEmpty(keyWords))
                {
                    items = items.Where(e => e.Name.Contains(keyWords) || e.PhoneNum.Contains(keyWords));
                }

                return(items.AsNoTracking().OrderByDescending(m => m.CreateDateTime).Skip(currentIndex).Take(pageSize).ToList().Select(u => ToDTO(u)).ToArray());
            }
        }
Ejemplo n.º 29
0
 public AttachmentDTO[] GetAttachments(long houseId)
 {
     using (ZSZDbContext ctx = new ZSZDbContext())
     {
         BaseService <HouseEntity> houseBS
             = new BaseService <HouseEntity>(ctx);
         var house = houseBS.GetAll().Include(a => a.Attachments)
                     .AsNoTracking().SingleOrDefault(h => h.Id == houseId);
         if (house == null)
         {
         }
         return(house.Attachments.ToList().Select(a => ToDTO(a)).ToArray());
     }
 }
Ejemplo n.º 30
0
 public AdminUserDTO GetById(long id)
 {
     using (ZSZDbContext ctx = new ZSZDbContext())
     {
         BaseService <AdminUserEntity> bs = new BaseService <AdminUserEntity>(ctx);
         //这里不能用bs.GetById(id);因为无法Include、AsNoTracking()等
         var user = bs.GetAll().Include(u => u.City).AsNoTracking().SingleOrDefault(a => a.Id == id);
         if (user == null)
         {
             return(null);
         }
         return(ToDTO(user));
     }
 }