Example #1
0
 public Chat AddChat(Chat c)
 {
     using (SportsChatQueries query = new SportsChatQueries(new SportsChatEntities()))
     {
         query.AddChat(c);
         Chat newChat = query.GetChatByNameAndDateCreated(c.Name, c.DateCreated);
         return (newChat != null) ? newChat : null;
     }
 }
Example #2
0
        public void UpdateChat(Chat c)
        {
            ctx.Entry(c).State = System.Data.Entity.EntityState.Modified;

            try
            {
                ctx.SaveChanges();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Example #3
0
        public void AddChat(Chat c)
        {
            ctx.Chats.Add(c);

            try
            {
                ctx.SaveChanges();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Example #4
0
        public void RemoveChat(Chat c)
        {
            Chat chatToRemove = ctx.Chats.Find(c.Id);
            if (chatToRemove != null)
            {
                ctx.Chats.Remove(chatToRemove);
            }

            try
            {
                ctx.SaveChanges();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }