public async Task <PartnerUser> AddPartnerUser(PartnerUser partnerUser) { partnerUser.CreatedDate = DateTimeOffset.UtcNow; partnerUser.LastUpdatedByUserId = partnerUser.CreatedByUserId; partnerUser.LastUpdatedDate = DateTimeOffset.UtcNow; mobDbContext.PartnerUsers.Add(partnerUser); await mobDbContext.SaveChangesAsync().ConfigureAwait(false); return(await mobDbContext.PartnerUsers.FindAsync(partnerUser.PartnerId, partnerUser.UserId).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); }
public async Task <PartnerRequest> AddPartnerRequest(PartnerRequest partnerRequest) { partnerRequest.Id = Guid.NewGuid(); partnerRequest.CreatedDate = DateTimeOffset.UtcNow; partnerRequest.LastUpdatedByUserId = partnerRequest.CreatedByUserId; partnerRequest.LastUpdatedDate = DateTimeOffset.UtcNow; mobDbContext.PartnerRequests.Add(partnerRequest); await mobDbContext.SaveChangesAsync().ConfigureAwait(false); return(await mobDbContext.PartnerRequests.FindAsync(partnerRequest.Id).ConfigureAwait(false)); }
public async Task <PartnerLocation> AddPartnerLocation(PartnerLocation partnerLocation) { if (partnerLocation.Id == Guid.Empty) { partnerLocation.Id = Guid.NewGuid(); } partnerLocation.CreatedDate = DateTimeOffset.UtcNow; partnerLocation.LastUpdatedByUserId = partnerLocation.CreatedByUserId; partnerLocation.LastUpdatedDate = DateTimeOffset.UtcNow; mobDbContext.PartnerLocations.Add(partnerLocation); await mobDbContext.SaveChangesAsync().ConfigureAwait(false); return(await mobDbContext.PartnerLocations.FindAsync(partnerLocation.Id).ConfigureAwait(false)); }
public async Task <UserNotification> AddUserNotification(UserNotification userNotification) { userNotification.Id = Guid.NewGuid(); userNotification.SentDate = DateTimeOffset.UtcNow; mobDbContext.UserNotifications.Add(userNotification); await mobDbContext.SaveChangesAsync().ConfigureAwait(false); return(await mobDbContext.UserNotifications.FindAsync(userNotification.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)); }
public async Task <ContactRequest> AddContactRequest(ContactRequest contactRequest) { contactRequest.Id = Guid.NewGuid(); contactRequest.CreatedDate = DateTimeOffset.UtcNow; mobDbContext.ContactRequests.Add(contactRequest); await mobDbContext.SaveChangesAsync().ConfigureAwait(false); return(await mobDbContext.ContactRequests.FindAsync(contactRequest.Id).ConfigureAwait(false)); }
// Add new Event record public async Task <Event> AddEvent(Event mobEvent) { mobEvent.Id = Guid.NewGuid(); mobEvent.EventStatusId = (int)EventStatusEnum.Active; mobDbContext.Events.Add(mobEvent); var eventHistory = mobEvent.ToEventHistory(); mobDbContext.EventHistories.Add(eventHistory); var newAttendee = new EventAttendee { EventId = mobEvent.Id, UserId = mobEvent.CreatedByUserId, SignUpDate = DateTimeOffset.UtcNow }; mobDbContext.EventAttendees.Add(newAttendee); await mobDbContext.SaveChangesAsync().ConfigureAwait(false); return(await mobDbContext.Events.FindAsync(mobEvent.Id).ConfigureAwait(false)); }
public async Task <EventPartner> AddEventPartner(EventPartner eventPartner) { try { eventPartner.CreatedDate = DateTimeOffset.UtcNow; eventPartner.LastUpdatedDate = DateTimeOffset.UtcNow; mobDbContext.EventPartners.Add(eventPartner); await mobDbContext.SaveChangesAsync().ConfigureAwait(false); return(await mobDbContext.EventPartners.FindAsync(eventPartner.EventId, eventPartner.PartnerId, eventPartner.PartnerLocationId).ConfigureAwait(false)); } catch (DbUpdateException ex) { if ((ex.InnerException.InnerException is SqlException innerException) && (innerException.Number == 2627 || innerException.Number == 2601)) { return(null); }
// Add new User record public async Task <User> AddUser(User user) { user.Id = Guid.NewGuid(); user.MemberSince = DateTimeOffset.UtcNow; user.DateAgreedToPrivacyPolicy = DateTimeOffset.MinValue; user.DateAgreedToTermsOfService = DateTimeOffset.MinValue; user.PrivacyPolicyVersion = string.Empty; user.TermsOfServiceVersion = string.Empty; user.IsSiteAdmin = false; mobDbContext.Users.Add(user); await mobDbContext.SaveChangesAsync().ConfigureAwait(false); return(await mobDbContext.Users.FindAsync(user.Id).ConfigureAwait(false)); }
public async Task <UserNotificationPreference> AddUpdateUserNotificationPreference(UserNotificationPreference userNotificationPreference) { var unp = mobDbContext.UserNotificationPreferences.Where(u => u.UserId == userNotificationPreference.UserId && u.UserNotificationTypeId == userNotificationPreference.UserNotificationTypeId).FirstOrDefault(); if (unp == null) { userNotificationPreference.Id = Guid.NewGuid(); userNotificationPreference.LastUpdatedDate = DateTimeOffset.UtcNow; mobDbContext.UserNotificationPreferences.Add(userNotificationPreference); } else { unp.IsOptedOut = userNotificationPreference.IsOptedOut; unp.LastUpdatedDate = DateTimeOffset.UtcNow; } await mobDbContext.SaveChangesAsync().ConfigureAwait(false); return(await mobDbContext.UserNotificationPreferences.FindAsync(userNotificationPreference.Id).ConfigureAwait(false)); }
public async Task <EventAttendee> AddEventAttendee(Guid eventId, Guid attendeeId) { var eventAttendee = new EventAttendee { EventId = eventId, UserId = attendeeId, SignUpDate = DateTimeOffset.UtcNow, }; try { mobDbContext.EventAttendees.Add(eventAttendee); await mobDbContext.SaveChangesAsync().ConfigureAwait(false); return(await mobDbContext.EventAttendees.FindAsync(eventId, attendeeId).ConfigureAwait(false)); } catch (DbUpdateException ex) { if ((ex.InnerException.InnerException is SqlException innerException) && (innerException.Number == 2627 || innerException.Number == 2601)) { return(null); }