/// <summary> /// Gets last stage history record /// </summary> /// <param name="lastStageHistoryRecordId"> Stage history record Id </param> /// <returns> Last stage history record </returns> private Entity GetLastStageHistoryRecord(Guid lastStageHistoryRecordId) { Entity lastStageHistoryRecord = StageHistorySchema.CreateEntity(UserConnection); if (!lastStageHistoryRecord.FetchFromDB(lastStageHistoryRecordId, false)) { lastStageHistoryRecord.SetDefColumnValues(); } return(lastStageHistoryRecord); }
/// <summary> /// Creates new record /// </summary> /// <param name="stageHistoryData"> Stage history data to create </param> /// <param name="isIntermediateStage"> Shows if this stage intemediate </param> /// <returns>Stage entity</returns> protected virtual Entity CreateStageHistoryRecord(StageHistoryData stageHistoryData, bool isIntermediateStage = false) { DateTime currentDate = stageHistoryData.Date ?? UserConnection.CurrentUser.GetCurrentDateTime(); Entity newEntity = StageHistorySchema.CreateEntity(UserConnection); newEntity.SetColumnValue("Id", Guid.NewGuid()); newEntity.SetColumnValue("RootEntityId", stageHistoryData.EntityId); newEntity.SetColumnValue("OwnerId", stageHistoryData.OwnerId); newEntity.SetColumnValue("StageId", stageHistoryData.Stage.StageId); newEntity.SetColumnValue("StartDate", currentDate); if (stageHistoryData.Stage.End || isIntermediateStage) { newEntity.SetColumnValue("DueDate", currentDate); } return(newEntity); }