コード例 #1
0
 public static List <User> GetAllUsers()
 {
     using (var db = new ChatFormEntities())
     {
         return(db.Users.ToList());
     }
 }
コード例 #2
0
 public static List <ViewForm> GetAllViewForms()
 {
     using (var db = new ChatFormEntities())
     {
         return(db.ViewForms.ToList());
     }
 }
コード例 #3
0
 public static List <Message> GetAllMessages()
 {
     using (var db = new ChatFormEntities())
     {
         return(db.Messages.ToList());
     }
 }
コード例 #4
0
 public static string DeleteUser(User user)
 {
     using (var db = new ChatFormEntities())
     {
         db.Entry(user).State = System.Data.Entity.EntityState.Deleted;
         db.SaveChanges();
         return("User deleted");
     }
 }
コード例 #5
0
 public static string EditMessage(Message message)
 {
     using (var db = new ChatFormEntities())
     {
         try
         {
             db.Entry(message).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
             return("Message edited");
         }
         catch (System.Data.Entity.Infrastructure.DbUpdateException ex)
         {
             return($"Error!!! {ex.Message}");
         }
     }
 }
コード例 #6
0
 public static string AddViewForm(ViewForm viewForm)
 {
     using (var db = new ChatFormEntities())
     {
         try
         {
             db.ViewForms.Add(viewForm);
             db.SaveChanges();
             return("ViewForm added");
         }
         catch (System.Data.Entity.Infrastructure.DbUpdateException ex)
         {
             return($"Error!!! {ex.Message}");
         }
     }
 }
コード例 #7
0
 public static string AddMessage(Message message)
 {
     using (var db = new ChatFormEntities())
     {
         try
         {
             db.Messages.Add(message);
             db.SaveChanges();
             return("Message added");
         }
         catch (System.Data.Entity.Infrastructure.DbUpdateException ex)
         {
             return($"Error!!! {ex.Message}");
         }
     }
 }