Example #1
0
        public static int GetChannelId(string value, int typeId, int defaultId)
        {
            if (string.IsNullOrEmpty(value)) return defaultId;
            if (_Channels.IsNullOrEmpty()) _Channels = ChannelRepository.GetAll();
            var entity = _Channels
                .Where(c => c.SourceTypeId == typeId)
                .FirstOrDefault(c => c.Name.Equals(value, StringComparison.CurrentCultureIgnoreCase));
            if (entity == null)
            {
                entity = new ChannelInfo
                {
                    Name = value,
                    CreatedBy = 1,
                    ChangedBy = 1,
                    SourceTypeId = typeId,
                    Description = string.Empty,
                    CreatedDate = DateTime.Now,
                    ChangedDate = DateTime.Now,
                };
                var index = entity.Name.IndexOf(".");
                if (index > -1) entity.Code = entity.Name.Substring(0, index);

                entity.ChannelId = ChannelRepository.Create(entity);
                _Channels.Add(entity);
            }
            return entity.ChannelId;
        }
Example #2
0
 public static void Update(ChannelInfo info)
 {
     DataProvider.Instance().Channels_Update(info.ChannelId, info.Name, info.Code, info.Description, info.SourceTypeId, info.ChangedBy);
 }
Example #3
0
 public static int Create(ChannelInfo info)
 {
     return DataProvider.Instance().Channels_Insert(info.Name, info.Code, info.Description, info.SourceTypeId, info.CreatedBy);
 }