using NPOI.Util;
namespace HStation.WinFrmUI
{
///
///
///
public class CreateXhsSchemeHelper
{
public static async Task Create(CreateXhsSchemeViewModel vm)
{
if (vm == null)
return false;
var hydro_model_id = await Yw.BLLFactory.Instance.Copy(vm.HydroInfo.ID);
if (hydro_model_id > 0)
{
var xhs_scheme_id = await Yw.BLLFactory.Instance.Insert(vm.Scheme);
if (xhs_scheme_id < 0)
{
await Yw.BLLFactory.Instance.DeleteByID(hydro_model_id);
return false;
}
var hydro_relation = new Yw.Vmo.HydroModelRelationVmo();
hydro_relation.ObjectType = HStation.Xhs.DataType.XhsScheme;
hydro_relation.ObjectID = xhs_scheme_id;
hydro_relation.ModelID = hydro_model_id;
hydro_relation.Purpose = HStation.Xhs.Purpose.Simulation;
hydro_relation.Content = null;
hydro_relation.Description = vm.Scheme.Description;
var hydro_relation_id = await BLLFactory.Instance.Insert(hydro_relation);
if (hydro_relation_id < 1)
{
await Yw.BLLFactory.Instance.DeleteByID(hydro_model_id);
await Yw.BLLFactory.Instance.DeleteByID(xhs_scheme_id);
return false;
}
vm.Scheme = await BLLFactory.Instance.GetByID(xhs_scheme_id);
}
return true;
}
}
}