public DocStateType TryLoadById(Guid stateId)
        {
            var cached = DocStateTypeCache.Find(stateId);

            if (cached != null)
            {
                return(cached.CachedObject);
            }

            var state = DataContext.GetEntityDataContext().Entities.Object_Defs.OfType <Document_State_Type>().FirstOrDefault(s => s.Id == stateId);

            if (state != null)
            {
                var stateType = new DocStateType
                {
                    Id       = stateId,
                    Name     = state.Full_Name,
                    ReadOnly = state.Read_Only ?? false
                };

                DocStateTypeCache.Add(stateType, stateId);

                return(stateType);
            }
            return(null);
        }
        public DocStateType TryLoadByName(string stateName)
        {
            var cached =
                DocStateTypeCache./*GetItems().*/ FirstOrDefault(
                    co => String.Equals(co.CachedObject.Name, stateName, StringComparison.OrdinalIgnoreCase));

            if (cached != null)
            {
                return(cached.CachedObject);
            }

            var state =
                DataContext.GetEntityDataContext().Entities.Object_Defs.OfType <Document_State_Type>().FirstOrDefault(
                    s => s.Full_Name.ToUpper() == stateName.ToUpper());

            if (state != null)
            {
                var stateType = new DocStateType
                {
                    Id       = state.Id,
                    Name     = state.Full_Name,
                    ReadOnly = state.Read_Only ?? false
                };

                DocStateTypeCache.Add(stateType, state.Id);

                return(stateType);
            }
            return(null);
        }
Exemple #3
0
 public DocumentState(DocStateType type)
 {
     this.Type   = type;
     this.TypeId = (int)type;
 }