public string Add(FullHouse house) { ISqlMapper mapper = MapperHelper.GetMapper(); House_OtherFeeDao hofdao = new House_OtherFeeDao(mapper); RentFeeDao rfdao = new RentFeeDao(mapper); House_CustomerDao hcdao = new House_CustomerDao(mapper); RentFee rf = null; house.RentFee.HouseOrRoomID = house.House.ID; if (!string.IsNullOrEmpty(house.RentFee.ID)) rf = rfdao.Query(new RentFeeQueryForm { HouseOrRoomID = house.House.ID, Enabled = 1, IsDeleted = 0 }).FirstOrDefault(); string id = house.RentFee.ID; if (rf != null) rfdao.Update(new RentFeeUpdateForm { Entity = new RentFee { Enabled = 0 }, RentFeeQueryForm = new RentFeeQueryForm { ID = rf.ID } }); id = rfdao.Add(house.RentFee); if (house.OtherFees != null) { foreach (var of in house.OtherFees) { hofdao.Add(new House_OtherFee { HouseOrRoomID = house.House.ID, OtherFeeID = of.ID, Type = (int)HouseOrRoomType.House }); } } if (house.Renter != null) hcdao.Add(new House_Customer { HouseOrRoomID = house.House.ID, CustomerID = house.Renter.ID, Type = (int)CustomerType.租客 }); return id; }
public List<FullHouse> QueryFullHouse(QueryHouseServiceForm form) { List<FullHouse> list = new List<FullHouse>(); ISqlMapper mapper = MapperHelper.GetMapper(); HouseDao dao = new HouseDao(mapper); House_CustomerDao hcdao = new House_CustomerDao(mapper); CustomerDao customerdao = new CustomerDao(mapper); BuildingDao buildingdao = new BuildingDao(mapper); RentFeeDao rfdao = new RentFeeDao(mapper); House_OtherFeeDao hofdao = new House_OtherFeeDao(mapper); OtherFeeDao ofdao = new OtherFeeDao(mapper); var house = dao.QueryFullHouse(form); var houseids = (from h in house select h.ID).ToList(); var hcs = hcdao.Query(new House_CustomerQueryForm { HouseOrRoomIDs = houseids }); var customerids = (from ho in hcs select ho.CustomerID).Distinct().ToList(); var customers = customerdao.Query(new CustomerQueryForm { IDs = customerids, Enabled = 1, IsDeleted = 0, }); var buildingids = (from h in house select h.BuildingID).Distinct().ToList(); var buidlings = buildingdao.Query(new BuildingQueryForm { IDs = buildingids }); var rentfees = rfdao.Query(new RentFeeQueryForm { HouseOrRoomIDs = houseids, Enabled = 1, IsDeleted = 0 }); var rentfeeids = (from rf in rentfees select rf.ID).ToList(); var hos = hofdao.Query(new House_OtherFeeQueryForm { HouseOrRoomIDs = houseids }); var otherfeeids = (from ho in hos select ho.OtherFeeID).Distinct().ToList(); var ofs = ofdao.Query(new OtherFeeQueryForm { IDs = otherfeeids }); foreach (var h in house) { FullHouse fh = new FullHouse { House = h, Customer = (from ho in hcs join c in customers on ho.CustomerID equals c.ID where ho.HouseOrRoomID.Equals(h.ID) && c.Type == (int)CustomerType.业主 select c).FirstOrDefault(), Building = buidlings.Find(t => t.ID.Equals(h.BuildingID)), RentFee = rentfees.Find(t => t.HouseOrRoomID.Equals(h.ID)), OtherFees = (from ho in hos join of in ofs on ho.OtherFeeID equals of.ID where ho.HouseOrRoomID.Equals(h.ID) select of).ToList(), Renter = (from ho in hcs join c in customers on ho.CustomerID equals c.ID where ho.HouseOrRoomID.Equals(h.ID) && c.Type == (int)CustomerType.租客 select c).FirstOrDefault(), }; list.Add(fh); } return list; }
public List<RentFee> Query(RentFeeQueryForm form) { ISqlMapper mapper = MapperHelper.GetMapper(); RentFeeDao dao = new RentFeeDao(mapper); return dao.Query(form); }
public string Add(RentFee fee) { ISqlMapper mapper = MapperHelper.GetMapper(); RentFeeDao dao = new RentFeeDao(mapper); return dao.Add(fee); }
public bool Update(RentFee fee) { //if (string.IsNullOrEmpty(fee.ID)) throw new Exception("房租ID不能为空"); ISqlMapper mapper = MapperHelper.GetMapper(); RentFeeDao dao = new RentFeeDao(mapper); return dao.Update(new RentFeeUpdateForm { Entity = fee, RentFeeQueryForm = new RentFeeQueryForm { ID = fee.ID }, }); }