Beispiel #1
0
 public async void CreateGeneralMessageAsync(GeneralMessage generalMessage)
 {
     using (GeneralMessageRepository db = GetUnit().GeneralMessage)
     {
         await Task.Run(
             () =>
         {
             db.Add(generalMessage);
             db.Save();
         });
     }
 }
Beispiel #2
0
        public async Task <List <GeneralMessage> > GetGeneralMessageAsync()
        {
            var returnGeneralMessage = new List <GeneralMessage>();

            using (GeneralMessageRepository db = GetUnit().GeneralMessage)
            {
                await Task.Run(
                    () =>
                {
                    foreach (GeneralMessage message in db.GetAll())
                    {
                        db.GrammesDbContext.Entry(message).Reference(u => u.User).Load();
                        returnGeneralMessage.Add(message);
                    }
                });
            }

            return(returnGeneralMessage);
        }
Beispiel #3
0
        public Unit(string dataSource, string catalog)
        {
            if (string.IsNullOrEmpty(dataSource))
            {
                dataSource = @"(localdb)\MSSQLLocalDB";
            }

            if (string.IsNullOrEmpty(catalog))
            {
                catalog = "GrammesDb";
            }

            string connectionString = $"Data Source={dataSource};Initial Catalog={catalog};Integrated Security=True;";
            var    context          = new GrammesDbContext(connectionString);

            User           = new UserRepository(context);
            GeneralMessage = new GeneralMessageRepository(context);
            PrivateMessage = new PrivateMessageRepository(context);
            Event          = new EventRepository(context);
        }