Example #1
0
 public void Update(HouseFindDTO house)
 {
     using (ZSZDbContext ctx = new ZSZDbContext())
     {
         CommonService <HouseEntity> bs = new CommonService <HouseEntity>(ctx);
         HouseEntity entity             = bs.GetById(house.Id);
         entity.Address = house.Address;
         entity.Area    = house.Area;
         entity.Attachments.Clear();
         var atts = ctx.Attachments.Where(a => a.IsDeleted == false &&
                                          house.AttachmentIds.Contains(a.Id));
         foreach (AttachmentEntity att in atts)
         {
             entity.Attachments.Add(att);
         }
         entity.CheckInDateTime  = house.CheckInDateTime;
         entity.CommunityId      = house.CommunityId;
         entity.DecorateStatusId = house.DecorateStatusId;
         entity.Description      = house.Description;
         entity.Direction        = house.Direction;
         entity.FloorIndex       = house.FloorIndex;
         entity.LookableDateTime = house.LookableDateTime;
         entity.MonthRent        = house.MonthRent;
         entity.OwnerName        = house.OwnerName;
         entity.OwnerPhoneNum    = house.OwnerPhoneNum;
         entity.RoomTypeId       = house.RoomTypeId;
         entity.StatusId         = house.StatusId;
         entity.TotalFloorCount  = house.TotalFloorCount;
         entity.TypeId           = house.TypeId;
         ctx.SaveChanges();
     }
 }
Example #2
0
        private HouseFindDTO ToDTO(HouseEntity entity)
        {
            HouseFindDTO dto = new HouseFindDTO();

            dto.Address            = entity.Address;
            dto.Area               = entity.Area;
            dto.AttachmentIds      = entity.Attachments.Select(a => a.Id).ToArray();
            dto.CheckInDateTime    = entity.CheckInDateTime;
            dto.CityId             = entity.Community.Region.CityId;
            dto.CityName           = entity.Community.Region.City.Name;
            dto.CommunityBuiltYear = entity.Community.BuiltYear;
            dto.CommunityId        = entity.CommunityId;
            dto.CommunityLocation  = entity.Community.Location;
            dto.CommunityName      = entity.Community.Name;
            dto.CommunityTraffic   = entity.Community.Traffic;
            dto.CreateDateTime     = entity.CreateDateTime;
            dto.DecorateStatusId   = entity.DecorateStatusId;
            dto.DecorateStatusName = entity.DecorateStatus.Name;
            dto.Description        = entity.Description;
            dto.Direction          = entity.Direction;
            var firstPic = entity.HousePics.FirstOrDefault();

            if (firstPic != null)
            {
                dto.FirstThumbUrl = firstPic.ThumbUrl;
            }
            dto.FloorIndex       = entity.FloorIndex;
            dto.Id               = entity.Id;
            dto.LookableDateTime = entity.LookableDateTime;
            dto.MonthRent        = entity.MonthRent;
            dto.OwnerName        = entity.OwnerName;
            dto.OwnerPhoneNum    = entity.OwnerPhoneNum;
            dto.RegionId         = entity.Community.RegionId;
            dto.RegionName       = entity.Community.Region.Name;
            dto.RoomTypeId       = entity.RoomTypeId;
            dto.RoomTypeName     = entity.RoomType.Name;
            dto.StatusId         = entity.StatusId;
            dto.StatusName       = entity.Status.Name;
            dto.TotalFloorCount  = entity.TotalFloorCount;
            dto.TypeId           = entity.TypeId;
            dto.TypeName         = entity.Type.Name;
            return(dto);
        }