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(); } } }
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; } }
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(); } } }
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(); } } }
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(); } } }
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(); } }
public void InsertNews(News news) { using (ConfigurationDataContext context = new ConfigurationDataContext(Utility.GetConnectionString(configurationDataContext))) { news.CreateDate = DateTime.Now; context.AddToNews(news); context.SaveChanges(); } }
public void InsertFile(File file) { using (ConfigurationDataContext context = new ConfigurationDataContext(Utility.GetConnectionString(configurationDataContext))) { context.AddToFiles(file); context.SaveChanges(); } }
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(); } } }