Esempio n. 1
0
        // Update the records of a particular Event
        public async Task <Event> UpdateEvent(Event mobEvent)
        {
            mobDbContext.Entry(mobEvent).State = EntityState.Modified;
            var eventHistory = mobEvent.ToEventHistory();

            mobDbContext.EventHistories.Add(eventHistory);
            await mobDbContext.SaveChangesAsync().ConfigureAwait(false);

            return(await mobDbContext.Events.FindAsync(mobEvent.Id).ConfigureAwait(false));
        }
        // Add new EventSummary record
        public async Task <EventSummary> AddEventSummary(EventSummary eventSummary)
        {
            eventSummary.CreatedDate     = DateTimeOffset.UtcNow;
            eventSummary.LastUpdatedDate = DateTimeOffset.UtcNow;
            mobDbContext.EventSummaries.Add(eventSummary);
            await mobDbContext.SaveChangesAsync().ConfigureAwait(false);

            var summary = await mobDbContext.EventSummaries.FindAsync(eventSummary.EventId).ConfigureAwait(false);

            mobDbContext.Entry(summary).State = EntityState.Detached;
            return(summary);
        }
Esempio n. 3
0
        // Update the records of a particular Partner
        public async Task <Partner> UpdatePartner(Partner partner)
        {
            mobDbContext.Entry(partner).State = EntityState.Modified;
            partner.LastUpdatedDate           = DateTimeOffset.UtcNow;
            await mobDbContext.SaveChangesAsync().ConfigureAwait(false);

            return(await mobDbContext.Partners.FindAsync(partner.Id).ConfigureAwait(false));
        }
Esempio n. 4
0
        // Update the records of a particular user
        public async Task <User> UpdateUser(User user)
        {
            mobDbContext.Entry(user).State = EntityState.Modified;

            // The IsSiteAdmin flag can only be changed directly in the database, so once set, we need to preserve that, no matter what the user passes in
            var matchedUser = await GetUserByInternalId(user.Id).ConfigureAwait(false);

            user.IsSiteAdmin = matchedUser.IsSiteAdmin;

            await mobDbContext.SaveChangesAsync().ConfigureAwait(false);

            return(await mobDbContext.Users.FindAsync(user.Id).ConfigureAwait(false));
        }
        // Add new EventMedia record
        public async Task <EventMedia> AddUpdateEventMedia(EventMedia eventMedia)
        {
            if (eventMedia.Id == Guid.Empty)
            {
                eventMedia.Id              = Guid.NewGuid();
                eventMedia.CreatedDate     = DateTimeOffset.UtcNow;
                eventMedia.LastUpdatedDate = DateTimeOffset.UtcNow;
                mobDbContext.EventMedias.Add(eventMedia);
            }
            else
            {
                mobDbContext.Entry(eventMedia).State = EntityState.Modified;
                eventMedia.LastUpdatedDate           = DateTimeOffset.UtcNow;
            }

            await mobDbContext.SaveChangesAsync().ConfigureAwait(false);

            return(await mobDbContext.EventMedias.FindAsync(eventMedia.Id).ConfigureAwait(false));
        }