Beispiel #1
0
 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.AccountHraChatQuestionnaire
                                                     where aqh.AccountId == accountId
                                                     orderby aqh.CreatedOn descending
                                                     select aqh.Id).FirstOrDefault();
         if (accountHraChatQuestionnaireHistoryId > 0)
         {
             var entity = new AccountHraChatQuestionnaireEntity()
             {
                 EndDate    = (questionnaireType == (long)QuestionnaireType.ChatQuestionnaire && startDate.HasValue) ? startDate.Value : DateTime.Today,
                 ModifiedBy = orgUserId,
                 ModifiedOn = DateTime.Now,
             };
             adapter.UpdateEntitiesDirectly(entity, new RelationPredicateBucket(AccountHraChatQuestionnaireFields.Id == accountHraChatQuestionnaireHistoryId));
         }
         var entityInsert = new AccountHraChatQuestionnaireEntity()
         {
             AccountId         = accountId,
             QuestionnaireType = questionnaireType,
             StartDate         = (questionnaireType == (long)QuestionnaireType.ChatQuestionnaire && startDate.HasValue) ? startDate.Value : DateTime.Today,
             CreatedBy         = orgUserId,
             CreatedOn         = DateTime.Now,
         };
         adapter.SaveEntity(entityInsert);
     }
 }
Beispiel #2
0
 public void DeactivateLast(long accountId, DateTime endDate, long orgUserId)
 {
     using (var adapter = PersistenceLayer.GetDataAccessAdapter())
     {
         var linqMetaData = new LinqMetaData(adapter);
         var accountHraChatQuestionnaireHistoryId = (from aqh in linqMetaData.AccountHraChatQuestionnaire
                                                     where aqh.AccountId == accountId && aqh.EndDate == null
                                                     orderby aqh.CreatedOn descending
                                                     select aqh.Id).FirstOrDefault();
         if (accountHraChatQuestionnaireHistoryId > 0)
         {
             var entity = new AccountHraChatQuestionnaireEntity()
             {
                 EndDate    = endDate,
                 ModifiedBy = orgUserId,
                 ModifiedOn = DateTime.Now,
             };
             adapter.UpdateEntitiesDirectly(entity, new RelationPredicateBucket(AccountHraChatQuestionnaireFields.Id == accountHraChatQuestionnaireHistoryId));
         }
     }
 }