Пример #1
0
 public void Delete(T entity)
 {
     if (entity == null)
     {
         throw new ArgumentNullException("entity");
     }
     entities.Remove(entity);
     context.SaveChanges();
 }
Пример #2
0
        private void AddLocalisedData()
        {
            if (!_context.Cultures.Any())
            {
                var translations = _hostingEnvironment.GetTranslationFile();

                var locales = translations.First().Split(",").Skip(1).ToList();

                var currentLocale = 0;

                locales.ForEach(locale =>
                {
                    currentLocale += 1;

                    var culture = new Culture
                    {
                        Name = locale
                    };
                    var resources = new List <Resource>();
                    translations.Skip(1).ToList().ForEach(t =>
                    {
                        var line = t.Split(",");
                        resources.Add(new Resource
                        {
                            Culture = culture,
                            Key     = line[0],
                            Value   = line[currentLocale]
                        });
                    });

                    culture.Resources = resources;

                    _context.Cultures.Add(culture);

                    _context.SaveChanges();
                });
            }
        }
Пример #3
0
 public void SaveUserGraph(Subscriber subscriber)
 {
     _context.ChangeTracker.TrackGraph
         (subscriber, e => ApplyStateUsingIsKeySet(e.Entry));
     _context.SaveChanges();
 }
Пример #4
0
 public int SaveChanges()
 {
     return(_context.SaveChanges());
 }