public static bool CreateUser(DBO.User user) { try { using (MeditateBookEntities bdd = new MeditateBookEntities()) { T_User newUser = new T_User() { email = user.Email, firstname = user.Firstname, lastname = user.Lastname, password = user.Password, role = (int)user.Role }; bdd.T_User.Add(newUser); bdd.SaveChanges(); return(true); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); return(false); } }
public static bool UpdateArticle(DBO.Article article) { try { using (MeditateBookEntities bdd = new MeditateBookEntities()) { T_Article oldarticle = bdd.T_Article.Where(x => x.id == article.Id).FirstOrDefault(); if (oldarticle != null) { oldarticle.title = article.Title; oldarticle.content = article.Content; oldarticle.id_creator = article.IdCreator; oldarticle.validated = article.Validated; oldarticle.created_date = article.CreatedDate; bdd.SaveChanges(); return(true); } return(false); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); return(false); } }
public static bool CreateMessage(DBO.Message message) { try { using (MeditateBookEntities bdd = new MeditateBookEntities()) { T_Message newMessage = new T_Message() { content = message.Content, date = message.Date, id_receiver = message.IdReceiver, id_sender = message.IdSender, isSeen = message.IsSeen }; bdd.T_Message.Add(newMessage); bdd.SaveChanges(); return(true); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); return(false); } }
public static bool CreateArticle(ref DBO.Article article) { try { using (MeditateBookEntities bdd = new MeditateBookEntities()) { T_Article newArticle = new T_Article() { title = article.Title, content = article.Content, id_creator = article.IdCreator, created_date = article.CreatedDate, validated = article.Validated }; bdd.T_Article.Add(newArticle); bdd.SaveChanges(); article.Id = newArticle.id; return(true); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.ToString()); return(false); } }
public static bool CreateTranslation(DBO.Translation translation) { try { using (MeditateBookEntities bdd = new MeditateBookEntities()) { T_Translation newTranslation = new T_Translation() { content = translation.Content, id_article = translation.IdArticle, id_language = translation.IdLanguage, id_translator = translation.IdTranslator, validated = translation.Validated }; bdd.T_Translation.Add(newTranslation); bdd.SaveChanges(); return(true); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); return(false); } }
public static bool UpdateTranslation(DBO.Translation translation) { try { using (MeditateBookEntities bdd = new MeditateBookEntities()) { T_Translation oldTranslation = bdd.T_Translation.Where(x => x.id == translation.Id).FirstOrDefault(); if (oldTranslation != null) { oldTranslation.content = translation.Content; oldTranslation.id_article = translation.IdArticle; oldTranslation.id_language = translation.IdLanguage; oldTranslation.id_translator = translation.IdTranslator; oldTranslation.validated = translation.Validated; bdd.SaveChanges(); return(true); } return(false); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); return(false); } }
public static bool DeleteUser(long id) { try { using (MeditateBookEntities bdd = new MeditateBookEntities()) { bdd.T_User.Remove(bdd.T_User.Where(x => x.id == id).FirstOrDefault()); bdd.SaveChanges(); return(true); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); return(false); } }
public static bool UpdateComment(DBO.Comment comment) { try { using (MeditateBookEntities bdd = new MeditateBookEntities()) { T_Comment oldComment = bdd.T_Comment.Where(x => x.id == comment.Id).FirstOrDefault(); oldComment.content = comment.Content; oldComment.id_article = comment.IdArticle; oldComment.id_user = comment.IdUser; oldComment.date = comment.Date; bdd.SaveChanges(); return(true); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); return(false); } }
public static bool UpdateMessage(DBO.Message message) { try { using (MeditateBookEntities bdd = new MeditateBookEntities()) { T_Message oldMessage = bdd.T_Message.Where(x => x.id == message.Id).FirstOrDefault(); oldMessage.content = message.Content; oldMessage.date = message.Date; oldMessage.id_receiver = message.IdReceiver; oldMessage.id_sender = message.IdSender; oldMessage.isSeen = message.IsSeen; bdd.SaveChanges(); return(true); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); return(false); } }
public static bool CreateLanguage(DBO.Language language) { try { using (MeditateBookEntities bdd = new MeditateBookEntities()) { T_Language newLanguage = new T_Language() { name = language.Name, shortname = language.ShortName }; bdd.T_Language.Add(newLanguage); bdd.SaveChanges(); return(true); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); return(false); } }
public static bool CreateArticleImage(DBO.ArticleImage articleImage) { try { using (MeditateBookEntities bdd = new MeditateBookEntities()) { T_Article_Image newArticleAttach = new T_Article_Image() { id_article = articleImage.IdArticle, image_path = articleImage.ImagePath, name = articleImage.Name }; bdd.T_Article_Image.Add(newArticleAttach); bdd.SaveChanges(); return(true); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); return(false); } }
public static bool CreateUserLike(DBO.UserLike userLike) { try { using (MeditateBookEntities bdd = new MeditateBookEntities()) { T_User_Like newUserLike = new T_User_Like() { id_article = userLike.IdArticle, id_user = userLike.IdUser }; bdd.T_User_Like.Add(newUserLike); bdd.SaveChanges(); return(true); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); return(false); } }
public static bool UpdateLanguage(DBO.Language language) { try { using (MeditateBookEntities bdd = new MeditateBookEntities()) { T_Language oldLanguage = bdd.T_Language.Where(x => x.id == language.Id).FirstOrDefault(); if (oldLanguage != null) { oldLanguage.name = language.Name; oldLanguage.shortname = language.ShortName; bdd.SaveChanges(); return(true); } return(false); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); return(false); } }
public static bool UpdateUser(DBO.User user) { try { using (MeditateBookEntities bdd = new MeditateBookEntities()) { T_User oldUser = bdd.T_User.Where(x => x.id == user.Id).FirstOrDefault(); oldUser.firstname = user.Firstname; oldUser.email = user.Email; oldUser.lastname = user.Lastname; oldUser.password = user.Password; oldUser.role = (int)user.Role; bdd.SaveChanges(); return(true); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); return(false); } }
public static bool UpdateArticleImage(DBO.ArticleImage articleImage) { try { using (MeditateBookEntities bdd = new MeditateBookEntities()) { T_Article_Image old = bdd.T_Article_Image.Where(x => x.id == articleImage.Id).FirstOrDefault(); if (old != null) { old.id_article = articleImage.IdArticle; old.image_path = articleImage.ImagePath; old.name = articleImage.Name; bdd.SaveChanges(); return(true); } return(false); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); return(false); } }
public static bool CreateComment(DBO.Comment comment) { try { using (MeditateBookEntities bdd = new MeditateBookEntities()) { T_Comment newComment = new T_Comment() { content = comment.Content, id_user = comment.IdUser, id_article = comment.IdArticle, date = comment.Date }; bdd.T_Comment.Add(newComment); bdd.SaveChanges(); return(true); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); return(false); } }