Пример #1
0
        internal void AddDisplayAttribute(string typeName, string newDisplayValue)
        {
            var sqlQuery = SqlOptions.GenerateInsertIntoAttributesScript(typeName,
                                                                         "display",
                                                                         newDisplayValue);

            _context.Database.ExecuteSqlCommand(new RawSqlString(sqlQuery));
            _context.SaveChanges();
        }
Пример #2
0
 public bool Delete(int id)
 {
     try
     {
         _context.Entities.Remove(_context.Entities.Find(id));
         _context.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(false);
     }
 }
Пример #3
0
 public Role Create(string name, bool canRead, bool canWrite)
 {
     try
     {
         var entry = _context.Roles.Add(new Role(name, canRead, canWrite));
         _context.SaveChanges();
         return(entry.Entity);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(null);
     }
 }
Пример #4
0
 public User Register(string login, string password, Role role = null)
 {
     try
     {
         var entityEntry = _context.Users.Add(new User(login, password, role));
         _context.SaveChanges();
         return(entityEntry.Entity);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(null);
     }
 }
Пример #5
0
 private void ExecuteSqlAndSave(string sqlQuery)
 {
     _context.Database.ExecuteSqlCommand(new RawSqlString(sqlQuery));
     _context.SaveChanges();
 }