Exemplo n.º 1
0
        public void DeleteNews(News news)
        {
            using (ConfigurationDataContext context = new ConfigurationDataContext(Utility.GetConnectionString(configurationDataContext)))
            {
                var newsEntity = from item in context.News
                                 where item.NewsID == news.NewsID
                                 select item;

                News entity = newsEntity.SingleOrDefault();

                if (entity != null)
                {
                    context.DeleteObject(entity);
                    context.SaveChanges();
                }
            }
        }
Exemplo n.º 2
0
        public string DeleteFile(File file)
        {
            using (ConfigurationDataContext context = new ConfigurationDataContext(Utility.GetConnectionString(configurationDataContext)))
            {
                var files = from item in context.Files
                            where item.FileID == file.FileID
                            select item;

                File entity = files.FirstOrDefault();

                if ((entity != null))
                {
                    context.DeleteObject(entity);
                    context.SaveChanges();
                }
                return entity.FileName;
            }
        }
Exemplo n.º 3
0
        public void UpdateUser(User user)
        {
            using (ConfigurationDataContext context = new ConfigurationDataContext(Utility.GetConnectionString(configurationDataContext)))
            {
                var users = from item in context.Users
                            where item.UserID == user.UserID
                            select item;

                User entity = users.SingleOrDefault();

                if (entity != null)
                {
                    entity.Name = user.Name;
                    entity.Password = Cryptography.EncryptData(user.Password, saltKeyword);
                    entity.Login = user.Login;
                    entity.IsEnabled = user.IsEnabled;

                    context.SaveChanges();
                }
            }
        }
Exemplo n.º 4
0
        public void UpdateNews(News news)
        {
            using (ConfigurationDataContext context = new ConfigurationDataContext(Utility.GetConnectionString(configurationDataContext)))
            {
                var newsList = from item in context.News
                               where item.NewsID == news.NewsID
                               select item;

                News entity = newsList.SingleOrDefault();

                if (entity != null)
                {
                    entity.Title = news.Title;
                    entity.Text = news.Text;
                    entity.IsEnabled = news.IsEnabled;

                    context.SaveChanges();
                }
            }
        }
Exemplo n.º 5
0
        public void UpdateFile(File file)
        {
            using (ConfigurationDataContext context = new ConfigurationDataContext(Utility.GetConnectionString(configurationDataContext)))
            {
                var files = from item in context.Files
                            where item.FileID == file.FileID
                            select item;

                File entity = files.FirstOrDefault();

                if ((entity != null))
                {
                    entity.SubTypeID = file.SubTypeID;
                    entity.IsEnabled = file.IsEnabled;

                    context.SaveChanges();
                }
            }
        }
Exemplo n.º 6
0
 public void InsertUser(User user)
 {
     using (ConfigurationDataContext context = new ConfigurationDataContext(Utility.GetConnectionString(configurationDataContext)))
     {
         user.Password = Cryptography.EncryptData(user.Password, saltKeyword);
         context.AddToUsers(user);
         context.SaveChanges();
     }
 }
Exemplo n.º 7
0
 public void InsertNews(News news)
 {
     using (ConfigurationDataContext context = new ConfigurationDataContext(Utility.GetConnectionString(configurationDataContext)))
     {
         news.CreateDate = DateTime.Now;
         context.AddToNews(news);
         context.SaveChanges();
     }
 }
Exemplo n.º 8
0
 public void InsertFile(File file)
 {
     using (ConfigurationDataContext context = new ConfigurationDataContext(Utility.GetConnectionString(configurationDataContext)))
     {
         context.AddToFiles(file);
         context.SaveChanges();
     }
 }
Exemplo n.º 9
0
        public void DeleteUser(User user)
        {
            using (ConfigurationDataContext context = new ConfigurationDataContext(Utility.GetConnectionString(configurationDataContext)))
            {
                var users = from item in context.Users
                            where item.UserID == user.UserID
                            select item;

                User entity = users.SingleOrDefault();

                if (entity != null)
                {
                    context.DeleteObject(entity);
                    context.SaveChanges();
                }
            }
        }