69 lines
3.1 KiB
C#
69 lines
3.1 KiB
C#
using Google.Protobuf.WellKnownTypes;
|
|
using ServerCommon;
|
|
using ServerCore; using ServerBase;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace GameServer
|
|
{
|
|
internal static class BuildingRentalHistoryHelper
|
|
{
|
|
public static async Task<BuildingRentalHistoryInfo> toBuildingRentalHistoryInfo(this BuildingRentalHistory buildingRentalHistory)
|
|
{
|
|
var result = new Result();
|
|
|
|
var building_rental_history_attribute = buildingRentalHistory.getEntityAttribute<BuildingRentalHistoryAttribute>();
|
|
NullReferenceCheckHelper.throwIfNull(building_rental_history_attribute, () => $"building_rental_history_attribute is null !!!");
|
|
|
|
var building_rental_history_info = new BuildingRentalHistoryInfo
|
|
{
|
|
HistoryDate = building_rental_history_attribute.RentalTime.ToTimestamp(),
|
|
UserGuid = building_rental_history_attribute.RenteeUserGuid,
|
|
RentalPeriod = building_rental_history_attribute.RentalPeriod,
|
|
Floor = (int)building_rental_history_attribute.Floor,
|
|
};
|
|
|
|
(result, var nickname_attrib) = await NicknameDoc.findNicknameFromGuid(building_rental_history_attribute.RenteeUserGuid);
|
|
if (result.isSuccess() && nickname_attrib != null)
|
|
{
|
|
building_rental_history_info.UserName = nickname_attrib.Nickname;
|
|
}
|
|
|
|
return building_rental_history_info;
|
|
}
|
|
|
|
public static async Task<(Result, BuildingRentalHistory?, DynamoDbDocBase?)> tryMakeBuildingRentalHistory(Building building, int buildingMetaId, int floor, string userGuid, DateTime rentalTime, int rentalPeriod)
|
|
{
|
|
var result = new Result();
|
|
var err_msg = string.Empty;
|
|
|
|
var building_rental_history = new BuildingRentalHistory(building);
|
|
await building_rental_history.onInit();
|
|
|
|
var building_rental_history_attribute = building_rental_history.getEntityAttribute<BuildingRentalHistoryAttribute>();
|
|
NullReferenceCheckHelper.throwIfNull(building_rental_history_attribute, () => $"building_profit_history_attribute is null !!!");
|
|
|
|
building_rental_history_attribute.BuildingMetaId = buildingMetaId;
|
|
building_rental_history_attribute.Floor = floor;
|
|
building_rental_history_attribute.RenteeUserGuid = userGuid;
|
|
building_rental_history_attribute.RentalTime = rentalTime;
|
|
building_rental_history_attribute.RentalPeriod = rentalPeriod;
|
|
building_rental_history_attribute.newEntityAttribute();
|
|
|
|
(result, var building_rental_history_doc) = await building_rental_history_attribute.toDocBase();
|
|
if (result.isFail())
|
|
{
|
|
err_msg = $"Failed to toDocBase() !!! : {result.toBasicString()}";
|
|
Log.getLogger().error(err_msg);
|
|
|
|
return (result, null, null);
|
|
}
|
|
|
|
return (result, building_rental_history, building_rental_history_doc);
|
|
}
|
|
}
|
|
}
|