コード例 #1
0
        public static bool deleteSource(Models.Source source)
        {
            bool result = false;

            try
            {
                using (var _db = new Models.BleacherDb())
                {
                    _db.MCSImports.RemoveRange(_db.MCSImports.Where(x => x.SourceId == source.Id).Select(x => x));
                    int rowsAff = _db.SaveChanges();
                    if (rowsAff > 0)
                    {
                        _db.Sources.Remove(_db.Sources.Where(x => x.Id == source.Id).Select(x => x).Take(1).FirstOrDefault());

                        _db.SaveChanges();

                        result = true;
                    }
                }
            } catch (Exception e)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(e);
            }

            return(result);
        }
コード例 #2
0
        public static bool editSource(Models.SourceCrud source)
        {
            bool result = false;

            try
            {
                using (var _db = new Models.BleacherDb())
                {
                    var sourceObj = (from x in _db.Sources where x.Id == source.Id select x).FirstOrDefault();

                    if (sourceObj != null)
                    {
                        sourceObj.Name   = source.Name;
                        sourceObj.Active = source.Active;
                        int aff = _db.SaveChanges();

                        if (aff > 0)
                        {
                            result = true;
                        }
                    }
                }
            } catch (Exception e)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(e);
            }
            return(result);
        }
コード例 #3
0
 private static void addEvent(int sourceId, string location, int rows)
 {
     using (var _db = new Models.BleacherDb())
     {
         Models.eventLog record = new Models.eventLog();
         record.SourceId    = sourceId;
         record.Action      = "Add To Import";
         record.Description = rows.ToString() + " rows";
         record.Timestamp   = DateTime.Now;
         _db.eventLogs.Add(record);
         _db.SaveChanges();
     }
 }
コード例 #4
0
        public static int AddLineBlobs(List <MCS.Models.MCSImport> records, int sourceId, string location)
        {
            int rowsAff = 0;

            if (records != null && records.Count() > 0)
            {
                using (var _db = new Models.BleacherDb())
                {
                    _db.MCSImports.AddRange(records);
                    rowsAff = _db.SaveChanges();
                }
                try
                {
                    addEvent(sourceId, location, rowsAff);
                } catch (Exception e)
                {
                }
            }
            return(rowsAff);
        }