public bool Add(HotelInfoDto model) { if (model == null) { return(false); } else { var hotel = ConvertFromDto(model); if (string.IsNullOrEmpty(hotel.HID)) { hotel.HID = Guid.NewGuid().ToString(); } hotel.CreateTime = DateTime.Now; hotel.UpdateTime = DateTime.Now; hotel.Status = (int)HotelStatusEnum.Trial; var reuslt = _hotelRepository.Insert(hotel); if (reuslt > 0) { var routingEntity = new RoutingAccount() { HID = hotel.HID, AccountID = model.AccountID, IsAdmin = true, IsDeleted = false, UpdateTime = DateTime.Now }; reuslt = _routingAccountRepository.Insert(routingEntity); } return(reuslt > 0); } }
private static HotelInfoDto ConvertFromRepositoryEntity(HotelInfo hotelInfo) { if (hotelInfo == null) { return(null); } var hotelDto = new HotelInfoDto { HID = hotelInfo.HID, HAddress = hotelInfo.HAddress, HFax = hotelInfo.HFax, HName = hotelInfo.HName, HPhone = hotelInfo.HPhone, IsDeleted = hotelInfo.IsDeleted.Value, Remark = hotelInfo.Remark, Status = hotelInfo.Status.Value, CreateTime = hotelInfo.CreateTime.Value, UpdateTime = hotelInfo.UpdateTime.Value, }; if (hotelInfo.HLocationX != null) { hotelDto.HLocationX = hotelInfo.HLocationX.Value; } if (hotelInfo.HLocationY != null) { hotelDto.HLocationY = hotelInfo.HLocationY.Value; } return(hotelDto); }
public int Update(HotelInfoDto model) { if (model == null) { return(0); } else { var account = ConvertFromDto(model); return(_hotelRepository.UpdateNonDefaults(account, x => x.HID == account.HID)); } }
private static HotelInfo ConvertFromDto(HotelInfoDto hotelInfoDto) { if (hotelInfoDto == null) { return(null); } var hotel = new HotelFullInfo { HID = hotelInfoDto.HID, HAddress = hotelInfoDto.HAddress, HFax = hotelInfoDto.HFax, HName = hotelInfoDto.HName, HPhone = hotelInfoDto.HPhone, Remark = hotelInfoDto.Remark }; if (hotelInfoDto.HLocationX > 0) { hotel.HLocationX = hotelInfoDto.HLocationX; } if (hotelInfoDto.HLocationY > 0) { hotel.HLocationY = hotelInfoDto.HLocationY; } if (!hotelInfoDto.IsAdmin) { hotel.IsAdmin = hotelInfoDto.IsAdmin; } if (!hotelInfoDto.IsDeleted) { hotel.IsDeleted = hotelInfoDto.IsDeleted; } if (hotelInfoDto.Status > 0) { hotel.Status = hotelInfoDto.Status; } if ((hotelInfoDto?.CreateTime ?? DateTime.MinValue) > DateTime.MinValue) { hotel.CreateTime = hotelInfoDto.CreateTime; } if ((hotelInfoDto?.UpdateTime ?? DateTime.MinValue) > DateTime.MinValue) { hotel.UpdateTime = hotelInfoDto.UpdateTime; } return(hotel); }
public List <HotelInfoDto> GetAllHotelInfo(HotelInfoDto model) { List <HotelInfoDto> list = new List <HotelInfoDto>(); if ((model == null) || (string.IsNullOrEmpty(model.AccountID))) { return(list); } var repository = (HotelBusinessRepository)IocManager.Instance.Resolve(typeof(HotelBusinessRepository)); var hotelList = repository.GetAllHotelInfo(model.AccountID); if (hotelList != null) { hotelList.ForEach(x => list.Add(ConvertFromRepositoryEntity(x))); } return(list); }
public HotelInfoDto GetHotelInfo(HotelInfoDto model) { if ((model == null) || (string.IsNullOrEmpty(model.HID))) { return(null); } var accountUser = _hotelRepository.Single(a => (a.HID == model.HID)); if (accountUser == null) { return(null); } else { return(ConvertFromRepositoryEntity(accountUser)); } }
private static shopInfo ConvertFromDto(HotelInfoDto hotelDto) { if (hotelDto == null) { return(null); } shopInfo user = new shopInfo() { Shop_Address = hotelDto.HAddress, Shop_chuanzen = hotelDto.HFax, id = hotelDto.HID, Shop_x = hotelDto.HLocationX.ToString(), Shop_y = hotelDto.HLocationY.ToString(), shop_Name = hotelDto.HName, Shop_Telphone = hotelDto.HPhone, Shop_Remaker = hotelDto.Remark, Shop_date = hotelDto.CreateTime }; return(user); }
private static HotelInfoDto ConvertFromBllEntity(shopInfo shop) { if (shop == null) { return(null); } HotelInfoDto accountDto = new HotelInfoDto() { HAddress = shop.Shop_Address, HFax = shop.Shop_chuanzen, HID = shop.id, HLocationX = float.Parse(shop.Shop_x), HLocationY = float.Parse(shop.Shop_y), HName = shop.shop_Name, HPhone = shop.Shop_Telphone, Remark = shop.Shop_Remaker, CreateTime = shop.Shop_date.Value }; return(accountDto); }
public InfoController(IOptions <HotelInfoDto> hotelInfoOptions) { _hotelInfoDto = hotelInfoOptions.Value; }