public void Save(long accountId, long questionnaireType, DateTime?startDate, long orgUserId) { using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { var linqMetaData = new LinqMetaData(adapter); var accountHraChatQuestionnaireHistoryId = (from aqh in linqMetaData.AccountHraChatQuestionnaireHistory where aqh.AccountId == accountId orderby aqh.CreatedOn descending select aqh.Id).FirstOrDefault(); if (accountHraChatQuestionnaireHistoryId > 0) { var entity = new AccountHraChatQuestionnaireHistoryEntity() { EndDate = (questionnaireType == (long)QuestionnaireType.ChatQuestionnaire && startDate.HasValue) ? startDate.Value : DateTime.Today, ModifiedBy = orgUserId, ModifiedOn = DateTime.Now, }; adapter.UpdateEntitiesDirectly(entity, new RelationPredicateBucket(AccountHraChatQuestionnaireHistoryFields.Id == accountHraChatQuestionnaireHistoryId)); } var entityInsert = new AccountHraChatQuestionnaireHistoryEntity() { AccountId = accountId, QuestionnaireType = questionnaireType, StartDate = (questionnaireType == (long)QuestionnaireType.ChatQuestionnaire && startDate.HasValue) ? startDate.Value : DateTime.Today, CreatedBy = orgUserId, CreatedOn = DateTime.Now, }; adapter.SaveEntity(entityInsert); } }
public void UpdateIfnotHealthPlan(long accountId, long orgUserId) { using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { var linqMetaData = new LinqMetaData(adapter); var accountHraChatQuestionnaireHistoryId = (from aqh in linqMetaData.AccountHraChatQuestionnaireHistory where aqh.AccountId == accountId && aqh.EndDate == null orderby aqh.CreatedOn descending select aqh.Id).FirstOrDefault(); if (accountHraChatQuestionnaireHistoryId > 0) { var entity = new AccountHraChatQuestionnaireHistoryEntity() { EndDate = DateTime.Today, ModifiedBy = orgUserId, ModifiedOn = DateTime.Now, }; adapter.UpdateEntitiesDirectly(entity, new RelationPredicateBucket(AccountHraChatQuestionnaireHistoryFields.Id == accountHraChatQuestionnaireHistoryId)); } } }