protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5AT_SA_1301 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); //Put your code here ORM_RES_ACT_Action_Version oldVersion = new ORM_RES_ACT_Action_Version(); ORM_RES_ACT_Action action = new ORM_RES_ACT_Action(); int versionNumber = 0; if (Parameter.RES_ACT_ActionID != Guid.Empty) { var result = action.Load(Connection, Transaction, Parameter.RES_ACT_ActionID); if (result.Status != FR_Status.Success || action.RES_ACT_ActionID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } ORM_RES_ACT_Action_Version.Query versionQuery = new ORM_RES_ACT_Action_Version.Query(); versionQuery.Tenant_RefID = securityTicket.TenantID; versionQuery.IsDeleted = false; versionQuery.Action_RefID = action.RES_ACT_ActionID; List <ORM_RES_ACT_Action_Version> versions = ORM_RES_ACT_Action_Version.Query.Search(Connection, Transaction, versionQuery); action.RES_ACT_ActionID = Parameter.RES_ACT_ActionID; versionNumber = versions.Max(i => i.Action_Version); oldVersion = versions.FirstOrDefault(i => i.Action_Version == versionNumber); versionNumber++; } else { versionNumber = 1; action.Tenant_RefID = securityTicket.TenantID; } action.ActionType_RefID = Parameter.ActionType_RefID; ORM_CMN_Price price = new ORM_CMN_Price(); if (Parameter.Default_PricePerUnit_RefID != Guid.Empty) { var result = price.Load(Connection, Transaction, Parameter.Default_PricePerUnit_RefID); if (result.Status != FR_Status.Success || action.RES_ACT_ActionID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } price.Tenant_RefID = securityTicket.TenantID; price.Save(Connection, Transaction); ORM_CMN_Price_Value.Query priceQuery = new ORM_CMN_Price_Value.Query(); priceQuery.Tenant_RefID = securityTicket.TenantID; priceQuery.Price_RefID = price.CMN_PriceID; priceQuery.IsDeleted = false; List <ORM_CMN_Price_Value> priceValueList = ORM_CMN_Price_Value.Query.Search(Connection, Transaction, priceQuery); ORM_CMN_Price_Value priceValue = new ORM_CMN_Price_Value(); if (priceValueList.Count != 0) { priceValue.Load(Connection, Transaction, priceValueList[0].CMN_Price_ValueID); } priceValue.Tenant_RefID = securityTicket.TenantID; priceValue.Price_RefID = price.CMN_PriceID; priceValue.PriceValue_Amount = Parameter.Default_PricePerUnit; priceValue.Save(Connection, Transaction); ORM_RES_ACT_Action_Version version = new ORM_RES_ACT_Action_Version(); version.Action_Description = Parameter.Action_Description_DictID; version.Action_Name = Parameter.Action_Name_DictID; version.Action_RefID = action.RES_ACT_ActionID; version.Action_Version = Parameter.Action_Version; version.Default_PricePerUnit_RefID = price.CMN_PriceID; version.Default_Unit_RefID = Parameter.Default_Unit_RefID; version.Default_UnitAmount = Parameter.Default_UnitAmount; version.Tenant_RefID = securityTicket.TenantID; version.Action_Version = versionNumber; version.Save(Connection, Transaction); action.CurrentVersion_RefID = version.RES_ACT_Action_VersionID; action.Save(Connection, Transaction); if (Parameter.RES_ACT_ActionID != Guid.Empty) { ORM_RES_STR_OutdoorFacility_Property_AvailableAction.Query query1 = new ORM_RES_STR_OutdoorFacility_Property_AvailableAction.Query(); query1.RES_ACT_Action_RefID = Parameter.RES_ACT_ActionID; ORM_RES_STR_OutdoorFacility_Property_AvailableAction.Query.SoftDelete(Connection, Transaction, query1); ORM_RES_STR_Facade_Property_AvailableAction.Query query2 = new ORM_RES_STR_Facade_Property_AvailableAction.Query(); query2.RES_ACT_Action_RefID = Parameter.RES_ACT_ActionID; ORM_RES_STR_Facade_Property_AvailableAction.Query.SoftDelete(Connection, Transaction, query2); ORM_RES_STR_Roof_Property_AvailableAction.Query query3 = new ORM_RES_STR_Roof_Property_AvailableAction.Query(); query3.RES_ACT_Action_RefID = Parameter.RES_ACT_ActionID; ORM_RES_STR_Roof_Property_AvailableAction.Query.SoftDelete(Connection, Transaction, query3); ORM_RES_STR_Attic_Property_AvailableAction.Query query4 = new ORM_RES_STR_Attic_Property_AvailableAction.Query(); query4.RES_ACT_Action_RefID = Parameter.RES_ACT_ActionID; ORM_RES_STR_Attic_Property_AvailableAction.Query.SoftDelete(Connection, Transaction, query4); ORM_RES_STR_Staircase_Property_AvailableAction.Query query5 = new ORM_RES_STR_Staircase_Property_AvailableAction.Query(); query5.RES_ACT_Action_RefID = Parameter.RES_ACT_ActionID; ORM_RES_STR_Staircase_Property_AvailableAction.Query.SoftDelete(Connection, Transaction, query5); ORM_RES_STR_Basement_Property_AvailableAction.Query query6 = new ORM_RES_STR_Basement_Property_AvailableAction.Query(); query6.RES_ACT_Action_RefID = Parameter.RES_ACT_ActionID; ORM_RES_STR_Basement_Property_AvailableAction.Query.SoftDelete(Connection, Transaction, query6); ORM_RES_STR_HVACR_Property_AvailableAction.Query query7 = new ORM_RES_STR_HVACR_Property_AvailableAction.Query(); query7.RES_ACT_Action_RefID = Parameter.RES_ACT_ActionID; ORM_RES_STR_HVACR_Property_AvailableAction.Query.SoftDelete(Connection, Transaction, query7); ORM_RES_STR_Apartment_Property_AvailableAction.Query query8 = new ORM_RES_STR_Apartment_Property_AvailableAction.Query(); query8.RES_ACT_Action_RefID = Parameter.RES_ACT_ActionID; ORM_RES_STR_Apartment_Property_AvailableAction.Query.SoftDelete(Connection, Transaction, query8); } if (Parameter.availableQuestions != null) { foreach (var question in Parameter.availableQuestions) { if (question.questionType == "OutdoorFacility") { ORM_RES_STR_OutdoorFacility_Property_AvailableAction item = new ORM_RES_STR_OutdoorFacility_Property_AvailableAction(); item.RES_STR_OutdoorFacility_Property_RefID = question.questionID; item.RES_ACT_Action_RefID = action.RES_ACT_ActionID; item.Tenant_RefID = securityTicket.TenantID; item.Save(Connection, Transaction); } if (question.questionType == "Facade") { ORM_RES_STR_Facade_Property_AvailableAction item = new ORM_RES_STR_Facade_Property_AvailableAction(); item.RES_STR_Facade_Property_RefID = question.questionID; item.RES_ACT_Action_RefID = action.RES_ACT_ActionID; item.Tenant_RefID = securityTicket.TenantID; item.Save(Connection, Transaction); } if (question.questionType == "Roof") { ORM_RES_STR_Roof_Property_AvailableAction item = new ORM_RES_STR_Roof_Property_AvailableAction(); item.RES_STR_Roof_Property_RefID = question.questionID; item.RES_ACT_Action_RefID = action.RES_ACT_ActionID; item.Tenant_RefID = securityTicket.TenantID; item.Save(Connection, Transaction); } if (question.questionType == "Attic") { ORM_RES_STR_Attic_Property_AvailableAction item = new ORM_RES_STR_Attic_Property_AvailableAction(); item.RES_STR_Attic_Property_RefID = question.questionID; item.RES_ACT_Action_RefID = action.RES_ACT_ActionID; item.Tenant_RefID = securityTicket.TenantID; item.Save(Connection, Transaction); } if (question.questionType == "Staircase") { ORM_RES_STR_Staircase_Property_AvailableAction item = new ORM_RES_STR_Staircase_Property_AvailableAction(); item.RES_STR_Staircase_Property_RefID = question.questionID; item.RES_ACT_Action_RefID = action.RES_ACT_ActionID; item.Tenant_RefID = securityTicket.TenantID; item.Save(Connection, Transaction); } if (question.questionType == "Basement") { ORM_RES_STR_Basement_Property_AvailableAction item = new ORM_RES_STR_Basement_Property_AvailableAction(); item.RES_STR_Basement_Property_RefID = question.questionID; item.RES_ACT_Action_RefID = action.RES_ACT_ActionID; item.Tenant_RefID = securityTicket.TenantID; item.Save(Connection, Transaction); } if (question.questionType == "HVCAR") { ORM_RES_STR_HVACR_Property_AvailableAction item = new ORM_RES_STR_HVACR_Property_AvailableAction(); item.RES_STR_HVACR_Property_RefID = question.questionID; item.RES_ACT_Action_RefID = action.RES_ACT_ActionID; item.Tenant_RefID = securityTicket.TenantID; item.Save(Connection, Transaction); } if (question.questionType == "Apartment") { ORM_RES_STR_Apartment_Property_AvailableAction item = new ORM_RES_STR_Apartment_Property_AvailableAction(); item.RES_STR_Apartment_Property_RefID = question.questionID; item.RES_ACT_Action_RefID = action.RES_ACT_ActionID; item.Tenant_RefID = securityTicket.TenantID; item.Save(Connection, Transaction); } } } returnValue.Result = action.RES_ACT_ActionID; return(returnValue); #endregion UserCode }
protected static FR_L5AT_GAFA_1001 Execute(DbConnection Connection, DbTransaction Transaction, P_L5AT_GAFA_1001 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5AT_GAFA_1001(); //Put your code here returnValue.Result = new L5AT_GAFA_1001(); ORM_RES_ACT_Action action = new ORM_RES_ACT_Action(); action.Load(Connection, Transaction, Parameter.ActionID); ORM_RES_ACT_Action_Version version = new ORM_RES_ACT_Action_Version(); version.Load(Connection, Transaction, action.CurrentVersion_RefID); returnValue.Result.RES_ACT_ActionID = action.RES_ACT_ActionID; returnValue.Result.RES_ACT_Action_VersionID = action.CurrentVersion_RefID; returnValue.Result.Action_Name = version.Action_Name; returnValue.Result.Action_Description = version.Action_Description; returnValue.Result.Default_PricePerUnit_RefID = version.Default_PricePerUnit_RefID; returnValue.Result.Default_Unit_RefID = version.Default_Unit_RefID; returnValue.Result.Default_UnitAmount = version.Default_UnitAmount; returnValue.Result.Action_Version = version.Action_Version; ORM_RES_STR_Apartment_Property_AvailableAction.Query apartmentQuery = new ORM_RES_STR_Apartment_Property_AvailableAction.Query(); apartmentQuery.Tenant_RefID = securityTicket.TenantID; apartmentQuery.IsDeleted = false; apartmentQuery.RES_ACT_Action_RefID = action.RES_ACT_ActionID; List <ORM_RES_STR_Apartment_Property_AvailableAction> apartments = ORM_RES_STR_Apartment_Property_AvailableAction.Query.Search(Connection, Transaction, apartmentQuery); List <L5AT_GAFA_1001_Apartment_Property> apartmentList = new List <L5AT_GAFA_1001_Apartment_Property>(); foreach (var buildingPart in apartments) { L5AT_GAFA_1001_Apartment_Property item = new L5AT_GAFA_1001_Apartment_Property(); item.RES_STR_Apartment_Property_AvailableActionID = buildingPart.RES_STR_Apartment_Property_AvailableActionID; item.RES_STR_Apartment_Property_RefID = buildingPart.RES_STR_Apartment_Property_RefID; apartmentList.Add(item); } returnValue.Result.Apartment_Property = apartmentList.ToArray(); ORM_RES_STR_Attic_Property_AvailableAction.Query atticQuery = new ORM_RES_STR_Attic_Property_AvailableAction.Query(); atticQuery.Tenant_RefID = securityTicket.TenantID; atticQuery.IsDeleted = false; atticQuery.RES_ACT_Action_RefID = action.RES_ACT_ActionID; List <ORM_RES_STR_Attic_Property_AvailableAction> attics = ORM_RES_STR_Attic_Property_AvailableAction.Query.Search(Connection, Transaction, atticQuery); List <L5AT_GAFA_1001_Attic_Property> atticList = new List <L5AT_GAFA_1001_Attic_Property>(); foreach (var buildingPart in attics) { L5AT_GAFA_1001_Attic_Property item = new L5AT_GAFA_1001_Attic_Property(); item.RES_STR_Attic_Property_AvailableActionID = buildingPart.RES_STR_Attic_Property_AvailableActionID; item.RES_STR_Attic_Property_RefID = buildingPart.RES_STR_Attic_Property_RefID; atticList.Add(item); } returnValue.Result.Attic_Property = atticList.ToArray(); ORM_RES_STR_Basement_Property_AvailableAction.Query basementQuery = new ORM_RES_STR_Basement_Property_AvailableAction.Query(); basementQuery.Tenant_RefID = securityTicket.TenantID; basementQuery.IsDeleted = false; basementQuery.RES_ACT_Action_RefID = action.RES_ACT_ActionID; List <ORM_RES_STR_Basement_Property_AvailableAction> basements = ORM_RES_STR_Basement_Property_AvailableAction.Query.Search(Connection, Transaction, basementQuery); List <L5AT_GAFA_1001_Basement_Property> basementList = new List <L5AT_GAFA_1001_Basement_Property>(); foreach (var buildingPart in basements) { L5AT_GAFA_1001_Basement_Property item = new L5AT_GAFA_1001_Basement_Property(); item.RES_STR_Basement_Property_AvailableActionID = buildingPart.RES_STR_Basement_Property_AvailableActionID; item.RES_STR_Basement_Property_RefID = buildingPart.RES_STR_Basement_Property_RefID; basementList.Add(item); } returnValue.Result.Basement_Property = basementList.ToArray(); ORM_RES_STR_Facade_Property_AvailableAction.Query facadeQuery = new ORM_RES_STR_Facade_Property_AvailableAction.Query(); facadeQuery.Tenant_RefID = securityTicket.TenantID; facadeQuery.IsDeleted = false; facadeQuery.RES_ACT_Action_RefID = action.RES_ACT_ActionID; List <ORM_RES_STR_Facade_Property_AvailableAction> facades = ORM_RES_STR_Facade_Property_AvailableAction.Query.Search(Connection, Transaction, facadeQuery); List <L5AT_GAFA_1001_Facade_Property> facadeList = new List <L5AT_GAFA_1001_Facade_Property>(); foreach (var buildingPart in facades) { L5AT_GAFA_1001_Facade_Property item = new L5AT_GAFA_1001_Facade_Property(); item.RES_STR_Facade_Property_AvailableActionID = buildingPart.RES_STR_Facade_Property_AvailableActionID; item.RES_STR_Facade_Property_RefID = buildingPart.RES_STR_Facade_Property_RefID; facadeList.Add(item); } returnValue.Result.Facade_Property = facadeList.ToArray(); ORM_RES_STR_HVACR_Property_AvailableAction.Query hvacrQuery = new ORM_RES_STR_HVACR_Property_AvailableAction.Query(); hvacrQuery.Tenant_RefID = securityTicket.TenantID; hvacrQuery.IsDeleted = false; hvacrQuery.RES_ACT_Action_RefID = action.RES_ACT_ActionID; List <ORM_RES_STR_HVACR_Property_AvailableAction> hvacrs = ORM_RES_STR_HVACR_Property_AvailableAction.Query.Search(Connection, Transaction, hvacrQuery); List <L5AT_GAFA_1001_HVACR_Property> hvacrList = new List <L5AT_GAFA_1001_HVACR_Property>(); foreach (var buildingPart in hvacrs) { L5AT_GAFA_1001_HVACR_Property item = new L5AT_GAFA_1001_HVACR_Property(); item.RES_STR_HVACR_Property_AvailableActionID = buildingPart.RES_STR_HVACR_Property_AvailableActionID; item.RES_STR_HVACR_Property_RefID = buildingPart.RES_STR_HVACR_Property_RefID; hvacrList.Add(item); } returnValue.Result.HVACR_Property = hvacrList.ToArray(); ORM_RES_STR_OutdoorFacility_Property_AvailableAction.Query outdoorQuery = new ORM_RES_STR_OutdoorFacility_Property_AvailableAction.Query(); outdoorQuery.Tenant_RefID = securityTicket.TenantID; outdoorQuery.IsDeleted = false; outdoorQuery.RES_ACT_Action_RefID = action.RES_ACT_ActionID; List <ORM_RES_STR_OutdoorFacility_Property_AvailableAction> outdoors = ORM_RES_STR_OutdoorFacility_Property_AvailableAction.Query.Search(Connection, Transaction, outdoorQuery); List <L5AT_GAFA_1001_OutdoorFacility_Property> outdoorList = new List <L5AT_GAFA_1001_OutdoorFacility_Property>(); foreach (var buildingPart in outdoors) { L5AT_GAFA_1001_OutdoorFacility_Property item = new L5AT_GAFA_1001_OutdoorFacility_Property(); item.RES_STR_OutdoorFacility_Property_AvailableActionID = buildingPart.RES_STR_OutdoorFacility_Property_AvailableActionID; item.RES_STR_OutdoorFacility_Property_RefID = buildingPart.RES_STR_OutdoorFacility_Property_RefID; outdoorList.Add(item); } returnValue.Result.OutdoorFacility_Property = outdoorList.ToArray(); ORM_RES_STR_Roof_Property_AvailableAction.Query roofQuery = new ORM_RES_STR_Roof_Property_AvailableAction.Query(); roofQuery.Tenant_RefID = securityTicket.TenantID; roofQuery.IsDeleted = false; roofQuery.RES_ACT_Action_RefID = action.RES_ACT_ActionID; List <ORM_RES_STR_Roof_Property_AvailableAction> roofs = ORM_RES_STR_Roof_Property_AvailableAction.Query.Search(Connection, Transaction, roofQuery); List <L5AT_GAFA_1001_Roof_Property> roofList = new List <L5AT_GAFA_1001_Roof_Property>(); foreach (var buildingPart in roofs) { L5AT_GAFA_1001_Roof_Property item = new L5AT_GAFA_1001_Roof_Property(); item.RES_STR_Roof_Property_AvailableActionID = buildingPart.RES_STR_Roof_Property_AvailableActionID; item.RES_STR_Roof_Property_RefID = buildingPart.RES_STR_Roof_Property_RefID; roofList.Add(item); } returnValue.Result.Roof_Property = roofList.ToArray(); ORM_RES_STR_Staircase_Property_AvailableAction.Query staircaseQuery = new ORM_RES_STR_Staircase_Property_AvailableAction.Query(); staircaseQuery.Tenant_RefID = securityTicket.TenantID; staircaseQuery.IsDeleted = false; staircaseQuery.RES_ACT_Action_RefID = action.RES_ACT_ActionID; List <ORM_RES_STR_Staircase_Property_AvailableAction> staircases = ORM_RES_STR_Staircase_Property_AvailableAction.Query.Search(Connection, Transaction, staircaseQuery); List <L5AT_GAFA_1001_Staircase_Property> staircaseList = new List <L5AT_GAFA_1001_Staircase_Property>(); foreach (var buildingPart in staircases) { L5AT_GAFA_1001_Staircase_Property item = new L5AT_GAFA_1001_Staircase_Property(); item.RES_STR_Staircase_Property_AvailableActionsID = action.RES_ACT_ActionID; item.RES_STR_Staircase_Property_RefID = buildingPart.RES_STR_Staircase_Property_RefID; staircaseList.Add(item); } returnValue.Result.Staircase_Property = staircaseList.ToArray(); return(returnValue); #endregion UserCode }