private static HotelInfoDto ConvertFromRepositoryEntity(HotelFullInfo 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, IsAdmin = hotelInfo.IsAdmin.Value, 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 ActionResult <string> UpdateHotelFullInfo([FromBody] HotelFullInfo hotel, [FromRoute] string country, [FromRoute] string id) { FullInfoRepository repository = new FullInfoRepository(); repository.UpdateHotel(id, country, hotel); return(Ok(hotel)); }
public HotelFullInfo UpdateHotel(string id, string country, HotelFullInfo hotel) { var collection = base._database.GetCollection <HotelFullInfo>("Hotel" + FirstCharToUpper(country)); var uptHotel = collection.Find(x => x.ofrgId == id).FirstOrDefault(); uptHotel = hotel; collection.ReplaceOne(HotelFullInfo => HotelFullInfo.ofrgId == hotel.ofrgId, uptHotel); return(uptHotel); }
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); }