Esempio n. 1
0
        public static TReference GetReference(EnumReferenceType referenceType)
        {
            ////check in cache first
            //object obj = System.Web.HttpContext.Current.Cache[referenceType.ToString()];
            ////if not available, set it first
            //if (obj == null)
            {
                ITReferenceRepository referenceRepository = new TReferenceRepository();
                TReference            reference           = referenceRepository.GetByReferenceType(referenceType);
                if (reference == null)
                {
                    referenceRepository.DbContext.BeginTransaction();
                    reference = new TReference();
                    reference.SetAssignedIdTo(Guid.NewGuid().ToString());
                    reference.ReferenceType  = referenceType.ToString();
                    reference.ReferenceValue = "0";
                    reference.CreatedDate    = DateTime.Now;
                    reference.DataStatus     = EnumDataStatus.New.ToString();
                    referenceRepository.Save(reference);
                    referenceRepository.DbContext.CommitTransaction();
                }
                return(reference);
                //    //save to cache
                //    System.Web.HttpContext.Current.Cache[referenceType.ToString()] = reference;
            }

            ////return cache
            //return System.Web.HttpContext.Current.Cache[referenceType.ToString()] as TReference;
        }
Esempio n. 2
0
        public static TReference GetReference(EnumReferenceType referenceType)
        {
            ITReferenceRepository referenceRepository = new TReferenceRepository();
            TReference            reference           = referenceRepository.GetByReferenceType(referenceType);

            if (reference == null)
            {
                reference = new TReference();
                reference.SetAssignedIdTo(Guid.NewGuid().ToString());
                reference.ReferenceType  = referenceType.ToString();
                reference.ReferenceValue = "0";
                reference.CreatedDate    = DateTime.Now;
                reference.DataStatus     = EnumDataStatus.New.ToString();
                referenceRepository.Save(reference);
                referenceRepository.DbContext.CommitChanges();
            }
            return(reference);
        }