Exemple #1
0
        public bool AddChannel(string channelName, int sectorId)
        {
            try
            {
                RC_CHANNELS channel = new RC_CHANNELS()
                {
                    CHANNEL_NAME = channelName,
                    SECTOR_ID    = sectorId,
                    IsDelete     = false,
                    //CHANNEL_ID = _db.RC_CHANNELS.Count() + 1 //remove in production
                };

                _db.RC_CHANNELS.Add(channel);

                _db.Entry(channel).State = System.Data.Entity.EntityState.Added;

                _db.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            {
                _log.Error(ex.StackTrace);
            }

            return(false);
        }
Exemple #2
0
        public bool DeleteChannel(long channelId)
        {
            try
            {
                RC_CHANNELS channel = _db.RC_CHANNELS.Where(x => x.CHANNEL_ID == channelId).Select(x => x).FirstOrDefault();

                // _db.RC_CHANNELS.Remove(channel);
                channel.IsDelete         = true;
                _db.Entry(channel).State = System.Data.Entity.EntityState.Modified;

                _db.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            {
                _log.ErrorFormat("Unable to delete for this reason:: {0}", ex.StackTrace);
            }

            return(false);
        }
Exemple #3
0
        public bool UpdateChannel(long channelId, string channelName, long sectorId)
        {
            try
            {
                RC_CHANNELS channel = _db.RC_CHANNELS.Where(x => x.CHANNEL_ID == channelId).Select(x => x).FirstOrDefault();

                channel.CHANNEL_NAME = channelName;

                channel.SECTOR_ID = (int)sectorId;

                _db.Entry(channel).State = System.Data.Entity.EntityState.Modified;

                _db.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            {
                _log.Error(ex.StackTrace);
            }

            return(false);
        }