Beispiel #1
0
 public static async Task <Location> GetLocation(int locationId)
 {
     using (AwesomeContext context = new AwesomeContext())
     {
         return(await context.Locations.FirstAsync(a => a.Id == locationId));
     }
 }
        public async Task TestReadAndWrite()
        {
            var factory = AwesomeEntityFramework.DefaultFactory <TestDbContext>(
                new DbContextOptionsBuilder <TestDbContext>()
                .UseInMemoryDatabase(Guid.NewGuid().ToString())
                .ConfigureWarnings(x => x.Ignore(InMemoryEventId.TransactionIgnoredWarning))
                .Options, options => new TestDbContext(options));

            var logger  = new LoggerFactory().CreateLogger <AwesomeContext <TestDbContext> >();
            var context = new AwesomeContext <TestDbContext>(logger, factory);
            var id      = Guid.NewGuid();
            var added   = await context.Write(async db =>
            {
                var result = await db.AddAsync(new AwesomeModel
                {
                    Id   = id,
                    Name = "Bob"
                });
                return(result.Entity);
            });

            Assert.Equal("Bob", added.Name);
            var read = await context.Read(async db => await db.FindAsync <AwesomeModel>(id));

            Assert.Equal("Bob", read.Name);
        }
Beispiel #3
0
 public static async Task CreateLocation(Location location)
 {
     using (AwesomeContext context = new AwesomeContext())
     {
         context.Locations.Add(location);
         await context.SaveChangesAsync();
     }
 }
Beispiel #4
0
 public static async Task CreateParticipant(Participant participant)
 {
     using (AwesomeContext context = new AwesomeContext())
     {
         context.Participants.Add(participant);
         await context.SaveChangesAsync();
     }
 }
Beispiel #5
0
 public static async Task CreateMeeting(Meeting meeting)
 {
     using (AwesomeContext awesomeContext = new AwesomeContext())
     {
         awesomeContext.Meetings.Add(meeting);
         await awesomeContext.SaveChangesAsync();
     }
 }
Beispiel #6
0
 /// <summary>
 /// Update by overwriting everything
 /// </summary>
 /// <param name="newLocation"></param>
 /// <returns></returns>
 public static async Task UpdateLocation(Location newLocation)
 {
     using (AwesomeContext context = new AwesomeContext())
     {
         context.Locations.Attach(newLocation);
         context.Entry(newLocation).State = EntityState.Modified;
         await context.SaveChangesAsync();
     }
 }
Beispiel #7
0
 /// <summary>
 /// Update by overwriting everything
 /// </summary>
 /// <param name="meeting"></param>
 /// <returns></returns>
 public static async Task UpdateMeeting(Meeting meeting)
 {
     using (AwesomeContext context = new AwesomeContext())
     {
         context.Meetings.Attach(meeting);
         context.Entry(meeting).State = EntityState.Modified;
         await context.SaveChangesAsync();
     }
 }
Beispiel #8
0
 /// <summary>
 /// Update by overwriting everything
 /// </summary>
 /// <param name="newParticipant"></param>
 /// <returns></returns>
 public static async Task UpdateParticipant(Participant newParticipant)
 {
     using (AwesomeContext context = new AwesomeContext())
     {
         context.Participants.Attach(newParticipant);
         context.Entry(newParticipant).State = EntityState.Modified;
         await context.SaveChangesAsync();
     }
 }
Beispiel #9
0
 public static async Task AddParticipantToMeeting(Participant participant, Meeting meeting)
 {
     using (AwesomeContext context = new AwesomeContext())
     {
         context.Meetings.Attach(meeting);
         context.Participants.Attach(participant);
         meeting.Participants.Add(participant);
         await context.SaveChangesAsync();
     }
 }
Beispiel #10
0
        public static async Task <Participant> GetParticipant(int participantId, params Expression <Func <Participant, object> >[] includes)
        {
            using (AwesomeContext context = new AwesomeContext())
            {
                Participant result = await context.Participants
                                     .IncludeRange(includes)
                                     .FirstAsync(a => a.Id == participantId);

                return(result);
            }
        }
Beispiel #11
0
        public static async Task <List <Meeting> > GetMeetingsForParticipant(int participantId)
        {
            using (AwesomeContext context = new AwesomeContext())
            {
                List <Meeting> result = await context.Participants
                                        .Where(a => a.Id == participantId)
                                        .SelectMany(a => a.EnrolledMeetings)
                                        .ToListAsync();

                return(result);
            }
        }
Beispiel #12
0
        public static async Task <Meeting> GetMeeting(int id, params Expression <Func <Meeting, object> >[] includes)
        {
            Meeting result;

            using (AwesomeContext context = new AwesomeContext())
            {
                result = await context.Meetings
                         .IncludeRange(includes)
                         .FirstOrDefaultAsync(a => a.Id == id);
            }
            return(result);
        }
Beispiel #13
0
        public static async Task <List <Meeting> > GetAllMeetings(params Expression <Func <Meeting, object> >[] includes)
        {
            List <Meeting> result;

            using (AwesomeContext context = new AwesomeContext())
            {
                result = await context.Meetings
                         .IncludeRange(includes)
                         .ToListAsync();
            }
            return(result);
        }
Beispiel #14
0
        public static async Task <List <Meeting> > GetFutureMeetings()
        {
            using (AwesomeContext context = new AwesomeContext())
            {
                List <Meeting> futureMeetings = await context.Meetings
                                                .Include(a => a.Participants)
                                                .Include(a => a.Location)
                                                .Where(a => a.MeetingStart > DateTime.Now)
                                                .ToListAsync();

                return(futureMeetings);
            }
        }
        public AddProjectForm(Models.Project project, AwesomeContext db)
        {
            InitializeComponent();

            // TODO: Complete member initialization
            this.project = project;
            this.db = db;
            this.projectBindingSource.Add(project);

            var clientList = db.Clients.OrderBy(x => x.Name);

            comboBox1.Items.AddRange(clientList.Select(x => x.Name).ToArray());
            comboBox1.SelectedIndex = comboBox1.FindStringExact(project.Client.Name);
        }
Beispiel #16
0
 public ChannelsController(AwesomeContext context)
 {
     _context = context;
 }
Beispiel #17
0
 public UserStatusesController(AwesomeContext context)
 {
     _context = context;
 }
 public MessageTypesController(AwesomeContext context)
 {
     _context = context;
 }
 public ACLPermissionsController(AwesomeContext context)
 {
     _context = context;
 }
Beispiel #20
0
 public ACLRolesController(AwesomeContext context)
 {
     _context = context;
 }
Beispiel #21
0
 public IdentityUsersController(AwesomeContext context)
 {
     _context = context;
 }